This patch checks if the crashkernel base address is after the end of BSS on i386 and x86_64. Having "Kernel bss" in the resource tree is not sufficient since that only prevents "crash kernel" from appearing in the resource tree and therefore kexec from loading the crashdump kernel since it checks /proc/iomem. However, the crashkernel memory would still be reserved. Signed-off-by: Bernhard Walle --- arch/x86/kernel/setup_32.c | 31 +++++++++++++++++++++---------- arch/x86/kernel/setup_64.c | 31 +++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 20 deletions(-) --- a/arch/x86/kernel/setup_32.c +++ b/arch/x86/kernel/setup_32.c @@ -403,18 +403,29 @@ static void __init reserve_crashkernel(v ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base); if (ret == 0 && crash_size > 0) { - if (crash_base > 0) { - printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " - "for crashkernel (System RAM: %ldMB)\n", - (unsigned long)(crash_size >> 20), - (unsigned long)(crash_base >> 20), - (unsigned long)(total_mem >> 20)); - crashk_res.start = crash_base; - crashk_res.end = crash_base + crash_size - 1; - reserve_bootmem(crash_base, crash_size); - } else + if (crash_base <= 0) { printk(KERN_INFO "crashkernel reservation failed - " "you have to specify a base address\n"); + return; + } + + if (base < virt_to_phys(&_end)) { + printk(KERN_WARNING "base address for crashkernel " + "(%luMB) is too low -- 0M-%luMB area " + "is needed by the kernel\n", + base >> 20, virt_to_phys(&_end) << 20); + return; + } + + printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " + "for crashkernel (System RAM: %ldMB)\n", + (unsigned long)(crash_size >> 20), + (unsigned long)(crash_base >> 20), + (unsigned long)(total_mem >> 20)); + + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; + reserve_bootmem(crash_base, crash_size); } } #else --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c @@ -210,18 +210,29 @@ static void __init reserve_crashkernel(v ret = parse_crashkernel(boot_command_line, free_mem, &crash_size, &crash_base); if (ret == 0 && crash_size) { - if (crash_base > 0) { - printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " - "for crashkernel (System RAM: %ldMB)\n", - (unsigned long)(crash_size >> 20), - (unsigned long)(crash_base >> 20), - (unsigned long)(free_mem >> 20)); - crashk_res.start = crash_base; - crashk_res.end = crash_base + crash_size - 1; - reserve_bootmem(crash_base, crash_size); - } else + if (crash_base <= 0) { printk(KERN_INFO "crashkernel reservation failed - " "you have to specify a base address\n"); + return; + } + + if (crash_base < virt_to_phys(&_end)) { + printk(KERN_WARNING "base address for crashkernel " + "(%lluMB) is too low -- 0M-%luMB area " + "is needed by the kernel\n", + crash_base >> 20, + virt_to_phys(&_end) << 20); + return; + } + + printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " + "for crashkernel (System RAM: %ldMB)\n", + (unsigned long)(crash_size >> 20), + (unsigned long)(crash_base >> 20), + (unsigned long)(free_mem >> 20)); + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; + reserve_bootmem(crash_base, crash_size); } } #else -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/