From owner-freebsd-hackers Mon Nov 4 15:21:43 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id PAA11369 for hackers-outgoing; Mon, 4 Nov 1996 15:21:43 -0800 (PST) Received: from plains.nodak.edu (tinguely@plains.NoDak.edu [134.129.111.64]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id PAA11348 for ; Mon, 4 Nov 1996 15:21:37 -0800 (PST) Received: (from tinguely@localhost) by plains.nodak.edu (8.7.6/8.7.3) id RAA10608 for freebsd-hackers@freebsd.org; Mon, 4 Nov 1996 17:21:31 -0600 (CST) Date: Mon, 4 Nov 1996 17:21:31 -0600 (CST) From: Mark Tinguely Message-Id: <199611042321.RAA10608@plains.nodak.edu> To: freebsd-hackers@freebsd.org Subject: Virtual/phyical alignments. Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 :)".