aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorBernhard Walle <bwalle@suse.de>2008-06-20 09:38:22 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 06:45:44 -0400
commit1ecd27657b735128a728ebf0c31fce5e1456718a (patch)
treef49fba5bd4a7a640b738a0f225ff3304ab9af877 /arch/x86
parent6236af82d8a989e150a02800c210eb61cb1e17be (diff)
x86: unify crashkernel reservation for 32 and 64 bit
This patch moves the reserve_crashkernel() to setup.c and removes the architecture-specific version. Both versions were more or less the same. I tested it on both x86-64 and i386, with CONFIG_KEXEC on and off (so that it compiles). Signed-off-by: Bernhard Walle <bwalle@suse.de> Cc: yhlu.kernel@gmail.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/setup.c61
-rw-r--r--arch/x86/kernel/setup_32.c53
-rw-r--r--arch/x86/kernel/setup_64.c40
3 files changed, 61 insertions, 93 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
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index a9b19ad24edb..369d0fe1ff9c 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -429,59 +429,6 @@ extern unsigned long __init setup_memory(void);
429extern void zone_sizes_init(void); 429extern void zone_sizes_init(void);
430#endif /* !CONFIG_NEED_MULTIPLE_NODES */ 430#endif /* !CONFIG_NEED_MULTIPLE_NODES */
431 431
432static inline unsigned long long get_total_mem(void)
433{
434 unsigned long long total;
435
436 total = max_low_pfn - min_low_pfn;
437#ifdef CONFIG_HIGHMEM
438 total += highend_pfn - highstart_pfn;
439#endif
440
441 return total << PAGE_SHIFT;
442}
443
444#ifdef CONFIG_KEXEC
445static void __init reserve_crashkernel(void)
446{
447 unsigned long long total_mem;
448 unsigned long long crash_size, crash_base;
449 int ret;
450
451 total_mem = get_total_mem();
452
453 ret = parse_crashkernel(boot_command_line, total_mem,
454 &crash_size, &crash_base);
455 if (ret == 0 && crash_size > 0) {
456 if (crash_base <= 0) {
457 printk(KERN_INFO "crashkernel reservation failed - "
458 "you have to specify a base address\n");
459 return;
460 }
461
462 if (reserve_bootmem_generic(crash_base, crash_size,
463 BOOTMEM_EXCLUSIVE) < 0) {
464 printk(KERN_INFO "crashkernel reservation failed - "
465 "memory is in use\n");
466 return;
467 }
468
469 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
470 "for crashkernel (System RAM: %ldMB)\n",
471 (unsigned long)(crash_size >> 20),
472 (unsigned long)(crash_base >> 20),
473 (unsigned long)(total_mem >> 20));
474
475 crashk_res.start = crash_base;
476 crashk_res.end = crash_base + crash_size - 1;
477 insert_resource(&iomem_resource, &crashk_res);
478 }
479}
480#else
481static inline void __init reserve_crashkernel(void)
482{}
483#endif
484
485#ifdef CONFIG_BLK_DEV_INITRD 432#ifdef CONFIG_BLK_DEV_INITRD
486 433
487static bool do_relocate_initrd = false; 434static bool do_relocate_initrd = false;
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 16ef53ab538a..504caeaffd58 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -228,46 +228,6 @@ static inline void copy_edd(void)
228} 228}
229#endif 229#endif
230 230
231#ifdef CONFIG_KEXEC
232static void __init reserve_crashkernel(void)
233{
234 unsigned long long total_mem;
235 unsigned long long crash_size, crash_base;
236 int ret;
237
238 total_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
239
240 ret = parse_crashkernel(boot_command_line, total_mem,
241 &crash_size, &crash_base);
242 if (ret == 0 && crash_size) {
243 if (crash_base <= 0) {
244 printk(KERN_INFO "crashkernel reservation failed - "
245 "you have to specify a base address\n");
246 return;
247 }
248
249 if (reserve_bootmem_generic(crash_base, crash_size,
250 BOOTMEM_EXCLUSIVE) < 0) {
251 printk(KERN_INFO "crashkernel reservation failed - "
252 "memory is in use\n");
253 return;
254 }
255
256 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
257 "for crashkernel (System RAM: %ldMB)\n",
258 (unsigned long)(crash_size >> 20),
259 (unsigned long)(crash_base >> 20),
260 (unsigned long)(total_mem >> 20));
261 crashk_res.start = crash_base;
262 crashk_res.end = crash_base + crash_size - 1;
263 insert_resource(&iomem_resource, &crashk_res);
264 }
265}
266#else
267static inline void __init reserve_crashkernel(void)
268{}
269#endif
270
271/* 231/*
272 * setup_arch - architecture-specific boot-time initializations 232 * setup_arch - architecture-specific boot-time initializations
273 * 233 *