Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Nov 1996 17:21:31 -0600 (CST)
From:      Mark Tinguely <tinguely@plains.nodak.edu>
To:        freebsd-hackers@freebsd.org
Subject:   Virtual/phyical alignments.
Message-ID:  <199611042321.RAA10608@plains.nodak.edu>

next in thread | raw e-mail | index | archive | help

I allocated a contiguous block that needs to be 8k aligned. I needed
to calculate the current offset to keep to use with a hardware head/tail
combination. I have been using:

		/* rsqh == virtual address of head pointer */
	idt->rsqh = ((u_long) rsq) & 0x1ffc;

This has been working for several weeks and then today, after a compile
that added more paranoid checks, everything started failing. It took me at
least an hour to discover that (rsq & 0x1000) == 0x1000 not 0 as I would have
assumed. The physical address is 8k aligned but the virtual address is not.
A substitution of :

	idt->rsqh = vtophys((u_long) rsq) & 0x1ffc;

I know it is too difficult to assure alignments of physical/virtual are
the same in the kernel (we demanding people always have these "it would be
nice if" thoughts). Yes, I am glad it happened during developement instead of
hate mail and in the very least let this be a warning to others...
don't assume virtual alignment when allocating for physical alignment.

--mark "in the belltower with a high powered rifle :)".



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611042321.RAA10608>