aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/setup.c')
-rw-r--r--arch/x86/kernel/setup.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ebb0a2bcdc08..c5330f601b68 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -3,6 +3,7 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/bootmem.h> 4#include <linux/bootmem.h>
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/kexec.h>
6#include <asm/smp.h> 7#include <asm/smp.h>
7#include <asm/percpu.h> 8#include <asm/percpu.h>
8#include <asm/sections.h> 9#include <asm/sections.h>
@@ -11,6 +12,7 @@
11#include <asm/topology.h> 12#include <asm/topology.h>
12#include <asm/mpspec.h> 13#include <asm/mpspec.h>
13#include <asm/apicdef.h> 14#include <asm/apicdef.h>
15#include <asm/highmem.h>
14 16
15#ifdef CONFIG_X86_LOCAL_APIC 17#ifdef CONFIG_X86_LOCAL_APIC
16unsigned int num_processors; 18unsigned int num_processors;
@@ -404,3 +406,62 @@ EXPORT_SYMBOL(node_to_cpumask);
404#endif /* CONFIG_DEBUG_PER_CPU_MAPS */ 406#endif /* CONFIG_DEBUG_PER_CPU_MAPS */
405 407
406#endif /* X86_64_NUMA */ 408#endif /* X86_64_NUMA */
409
410
411/*
412 * --------- Crashkernel reservation ------------------------------
413 */
414
415static inline unsigned long long get_total_mem(void)
416{
417 unsigned long long total;
418
419 total = max_low_pfn - min_low_pfn;
420#ifdef CONFIG_HIGHMEM
421 total += highend_pfn - highstart_pfn;
422#endif
423
424 return total << PAGE_SHIFT;
425}
426
427#ifdef CONFIG_KEXEC
428void __init reserve_crashkernel(void)
429{
430 unsigned long long total_mem;
431 unsigned long long crash_size, crash_base;
432 int ret;
433
434 total_mem = get_total_mem();
435
436 ret = parse_crashkernel(boot_command_line, total_mem,
437 &crash_size, &crash_base);
438 if (ret == 0 && crash_size > 0) {
439 if (crash_base <= 0) {
440 printk(KERN_INFO "crashkernel reservation failed - "
441 "you have to specify a base address\n");
442 return;
443 }
444
445 if (reserve_bootmem_generic(crash_base, crash_size,
446 BOOTMEM_EXCLUSIVE) < 0) {
447 printk(KERN_INFO "crashkernel reservation failed - "
448 "memory is in use\n");
449 return;
450 }
451
452 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
453 "for crashkernel (System RAM: %ldMB)\n",
454 (unsigned long)(crash_size >> 20),
455 (unsigned long)(crash_base >> 20),
456 (unsigned long)(total_mem >> 20));
457
458 crashk_res.start = crash_base;
459 crashk_res.end = crash_base + crash_size - 1;
460 insert_resource(&iomem_resource, &crashk_res);
461 }
462}
463#else
464void __init reserve_crashkernel(void)
465{}
466#endif
467