Skip to content

Commit

Permalink
[ARM] initrd: claim initrd memory exclusively
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Russell King authored and Russell King committed Jul 30, 2008
1 parent 905a09d commit b962a28
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions arch/arm/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit b962a28

Please sign in to comment.