diff options
Diffstat (limited to 'arch/x86/kernel/setup.c')
-rw-r--r-- | arch/x86/kernel/setup.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index ebb0a2bcdc0..c5330f601b6 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -3,6 +3,7 @@ #include <linux/init.h> #include <linux/bootmem.h> #include <linux/percpu.h> +#include <linux/kexec.h> #include <asm/smp.h> #include <asm/percpu.h> #include <asm/sections.h> @@ -11,6 +12,7 @@ #include <asm/topology.h> #include <asm/mpspec.h> #include <asm/apicdef.h> +#include <asm/highmem.h> #ifdef CONFIG_X86_LOCAL_APIC unsigned int num_processors; @@ -404,3 +406,62 @@ EXPORT_SYMBOL(node_to_cpumask); #endif /* CONFIG_DEBUG_PER_CPU_MAPS */ #endif /* X86_64_NUMA */ + + +/* + * --------- Crashkernel reservation ------------------------------ + */ + +static inline unsigned long long get_total_mem(void) +{ + unsigned long long total; + + total = max_low_pfn - min_low_pfn; +#ifdef CONFIG_HIGHMEM + total += highend_pfn - highstart_pfn; +#endif + + return total << PAGE_SHIFT; +} + +#ifdef CONFIG_KEXEC +void __init reserve_crashkernel(void) +{ + unsigned long long total_mem; + unsigned long long crash_size, crash_base; + int ret; + + total_mem = get_total_mem(); + + 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 "crashkernel reservation failed - " + "you have to specify a base address\n"); + return; + } + + if (reserve_bootmem_generic(crash_base, crash_size, + BOOTMEM_EXCLUSIVE) < 0) { + printk(KERN_INFO "crashkernel reservation failed - " + "memory is in use\n"); + 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; + insert_resource(&iomem_resource, &crashk_res); + } +} +#else +void __init reserve_crashkernel(void) +{} +#endif + |