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

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Thu, 7 Jan 1999 12:03:47 +0100 (CET)


Hi!

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.
As far as I have checked, IA32 modules should be upwards compatible, so i386
modules should be insmodable everywhere, i486 on i486+ compiled kernels, etc., so
this patch would come along with that quite nicely.
It does not cost anything, unless some module multiplies/divides/shifts
PAGE_OFFSET, but AFAIK nearly nobody does that outside of core kernel.
Otherwise insmod takes care of everything by relocating the module to the
PAGE_OFFSET used in the kernel.
Especially if Ingo comes again with a memsize selectable in CONFIG patch,
this could come handy.

--- linux/include/asm-i386/page.h.jj Thu Apr 9 03:05:18 1998
+++ linux/include/asm-i386/page.h Thu Jan 7 12:49:40 1999
@@ -80,9 +80,17 @@ typedef unsigned long pgprot_t;
*
* which has the same constant encoded..
*/
+#ifndef MODULE
#define __PAGE_OFFSET (0xC0000000)

#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
+#else
+#ifndef __ASSEMBLY__
+extern unsigned char page_offset[];
+#define PAGE_OFFSET ((unsigned long)page_offset)
+#endif /* __ASSEMBLY__ */
+#endif /* MODULE */
+
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
#define MAP_NR(addr) (__pa(addr) >> PAGE_SHIFT)
--- linux/arch/i386/kernel/i386_ksyms.c.jj Tue Dec 29 20:18:18 1998
+++ linux/arch/i386/kernel/i386_ksyms.c Thu Jan 7 13:01:25 1999
@@ -41,6 +41,7 @@ EXPORT_SYMBOL(enable_irq);
EXPORT_SYMBOL(disable_irq);
EXPORT_SYMBOL(kernel_thread);

+EXPORT_SYMBOL_NOVERS(page_offset);
EXPORT_SYMBOL_NOVERS(__down_failed);
EXPORT_SYMBOL_NOVERS(__down_failed_interruptible);
EXPORT_SYMBOL_NOVERS(__up_wakeup);
--- linux/arch/i386/vmlinux.lds.jj Mon Dec 28 07:45:13 1998
+++ linux/arch/i386/vmlinux.lds Thu Jan 7 12:51:22 1999
@@ -6,7 +6,8 @@ OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
- . = 0xC0000000 + 0x100000;
+ page_offset = 0xC0000000;
+ . = page_offset + 0x100000;
_text = .; /* Text and read-only data */
.text : {
*(.text)

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.2.0-pre4 on a sparc64 machine (3958.37 BogoMips)
___________________________________________________________________

-
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/