[ARM] initrd: claim initrd memory exclusively
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Wed, 30 Jul 2008 20:24:56 +0000 (21:24 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 30 Jul 2008 20:24:56 +0000 (21:24 +0100)
Claim the initrd memory exclusively, and order other memory
reservations beforehand.  This allows us to determine whether
the initrd memory was overwritten, and disable the initrd in
that case.

This avoids a 'bad page state' bug.

Tested-by: Ralph Siemsen <ralphs@netwinder.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mm/init.c

index e6352946dde020e04c3461b2f074972592b74710..30a69d67d673ed80f122900223249e94ec6a4890 100644 (file)
@@ -156,9 +156,9 @@ static int __init check_initrd(struct meminfo *mi)
        }
 
        if (initrd_node == -1) {
-               printk(KERN_ERR "initrd (0x%08lx - 0x%08lx) extends beyond "
+               printk(KERN_ERR "INITRD: 0x%08lx+0x%08lx extends beyond "
                       "physical memory - disabling initrd\n",
-                      phys_initrd_start, end);
+                      phys_initrd_start, phys_initrd_size);
                phys_initrd_start = phys_initrd_size = 0;
        }
 #endif
@@ -239,24 +239,32 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
        reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT,
                             boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
 
+       /*
+        * Reserve any special node zero regions.
+        */
+       if (node == 0)
+               reserve_node_zero(pgdat);
+
 #ifdef CONFIG_BLK_DEV_INITRD
        /*
         * If the initrd is in this node, reserve its memory.
         */
        if (node == initrd_node) {
-               reserve_bootmem_node(pgdat, phys_initrd_start,
-                                    phys_initrd_size, BOOTMEM_DEFAULT);
-               initrd_start = __phys_to_virt(phys_initrd_start);
-               initrd_end = initrd_start + phys_initrd_size;
+               int res = reserve_bootmem_node(pgdat, phys_initrd_start,
+                                    phys_initrd_size, BOOTMEM_EXCLUSIVE);
+
+               if (res == 0) {
+                       initrd_start = __phys_to_virt(phys_initrd_start);
+                       initrd_end = initrd_start + phys_initrd_size;
+               } else {
+                       printk(KERN_ERR
+                               "INITRD: 0x%08lx+0x%08lx overlaps in-use "
+                               "memory region - disabling initrd\n",
+                               phys_initrd_start, phys_initrd_size);
+               }
        }
 #endif
 
-       /*
-        * Finally, reserve any node zero regions.
-        */
-       if (node == 0)
-               reserve_node_zero(pgdat);
-
        /*
         * initialise the zones within this node.
         */