Re: [PATCH] Tiny fix to make modules independent on PAGE_OFFSET value without any performance lost

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Sat, 9 Jan 1999 23:39:56 +0000


On Thu, Jan 07, 1999 at 12:03:47PM +0100, Jakub Jelinek wrote:
> As the patch I've sent yesterday to l-k is quite controversial and I
> don't expect it to go into 2.2, I'd like to ask if the following patch
> could make it into it. It makes modules independent on the actual
> value of PAGE_OFFSET, so that one can e.g. have two kernels, a 960M
> one and a 2G one, but just one set of modules which is binary
> compatible with both.

I like the way this patch works, however the modules will silently fail
to work (i.e. probably crash, screw up MMIO or whatever) with many
page_offset addresses unless you include this too (from your other
patch):

- --- linux-2.2.0-pre3/include/asm-i386/io.h.jj Fri Jan 1 20:56:23 1999
+++ linux-2.2.0-pre3/include/asm-i386/io.h Sat Jan 2 12:29:27 1999
@@ -101,8 +101,8 @@ __OUTS(l)
#include <linux/vmalloc.h>
#include <asm/page.h>

- -#define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
- -#define __io_phys(x) ((unsigned long)(x) & ~PAGE_OFFSET)
+#define __io_virt(x) ((void *)(PAGE_OFFSET + (unsigned long)(x)))
+#define __io_phys(x) ((unsigned long)(x) - PAGE_OFFSET)
/*
* Change virtual addresses to physical addresses and vv.
* These are pretty trivial

As a nice side effect, this will also compile to better code in some
cases. Unfortunately, this is reputed to cause problems with some
broken drivers; looks like the only way to win here is fix those
drivers.

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/