[openfirmware] r950 - cpu/x86/pc

svn at openfirmware.info svn at openfirmware.info
Tue Sep 30 22:27:58 CEST 2008


Author: wmb
Date: 2008-09-30 22:27:58 +0200 (Tue, 30 Sep 2008)
New Revision: 950

Modified:
   cpu/x86/pc/linux.fth
Log:
Linux support - move ramdisk to top of memory for compatibility
with recent kernels that use boot protocols >= 2.03 .  The previous
ramdisk location (at load-base, e.g. 0x800000) was vulnerable to
being overwritten by kernel initialization, especially for large kernels.
This helps when using recent Fedora kernels, for example.


Modified: cpu/x86/pc/linux.fth
===================================================================
--- cpu/x86/pc/linux.fth	2008-09-30 20:23:34 UTC (rev 949)
+++ cpu/x86/pc/linux.fth	2008-09-30 20:27:58 UTC (rev 950)
@@ -167,7 +167,19 @@
    cr                                             ( throw-code r: xt )
    r> to load-path                                ( throw-code )
    throw
-   loaded to /ramdisk  to ramdisk-adr
+
+   loaded to /ramdisk                             ( adr )
+
+   \ Move ramdisk to top of memory
+
+   \ The initrd_addr_max field appeared in boot protocol 2.03
+   h# 22c +lp l@                                  ( adr ramdisk-limit )
+   ?dup  if  1+  else  h# 8000.0000  then         ( adr ramdisk-limit )
+
+   memory-limit  umin  /ramdisk -                 ( adr new-ramdisk-adr )
+   dup to ramdisk-adr                             ( adr new-ramdisk-adr )
+
+   /ramdisk move                                  ( )
 ;
 : cv-load-ramdisk  ( -- )
    " ramdisk" eval  dup 0=  if  2drop exit  then  ( name$ )
@@ -180,7 +192,6 @@
    0 0 1meg -1 mmu-map     ( )		\ Make the parameter area accessible
 [then]
    0 +lp  h# 1000 0 mem-claim drop      \ Play nice with memory reporting
-   0 +lp  h# 1000  erase
 ;
 
 0 value linux-loaded?




More information about the openfirmware mailing list