Commit 93a72052be81823fa1584b9be037d51924f9efa4

Authored by Olaf Hering
Committed by Linus Torvalds
1 parent 8547727756

crash_dump: export is_kdump_kernel to modules, consolidate elfcorehdr_addr, setu…

…p_elfcorehdr and saved_max_pfn

The Xen PV drivers in a crashed HVM guest can not connect to the dom0
backend drivers because both frontend and backend drivers are still in
connected state.  To run the connection reset function only in case of a
crashdump, the is_kdump_kernel() function needs to be available for the PV
driver modules.

Consolidate elfcorehdr_addr, setup_elfcorehdr and saved_max_pfn into
kernel/crash_dump.c Also export elfcorehdr_addr to make is_kdump_kernel()
usable for modules.

Leave 'elfcorehdr' as early_param().  This changes powerpc from __setup()
to early_param().  It adds an address range check from x86 also on ia64
and powerpc.

[akpm@linux-foundation.org: additional #includes]
[akpm@linux-foundation.org: remove elfcorehdr_addr export]
[akpm@linux-foundation.org: fix for Tejun's mm/nobootmem.c changes]
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 16 changed files with 37 additions and 135 deletions Side-by-side Diff

arch/arm/kernel/crash_dump.c
... ... @@ -18,9 +18,6 @@
18 18 #include <linux/uaccess.h>
19 19 #include <linux/io.h>
20 20  
21   -/* stores the physical address of elf header of crash image */
22   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
23   -
24 21 /**
25 22 * copy_oldmem_page() - copy one page from old kernel memory
26 23 * @pfn: page frame number to be copied
arch/arm/kernel/setup.c
... ... @@ -788,30 +788,6 @@
788 788 static inline void reserve_crashkernel(void) {}
789 789 #endif /* CONFIG_KEXEC */
790 790  
791   -/*
792   - * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
793   - * is_kdump_kernel() to determine if we are booting after a panic. Hence
794   - * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
795   - */
796   -
797   -#ifdef CONFIG_CRASH_DUMP
798   -/*
799   - * elfcorehdr= specifies the location of elf core header stored by the crashed
800   - * kernel. This option will be passed by kexec loader to the capture kernel.
801   - */
802   -static int __init setup_elfcorehdr(char *arg)
803   -{
804   - char *end;
805   -
806   - if (!arg)
807   - return -EINVAL;
808   -
809   - elfcorehdr_addr = memparse(arg, &end);
810   - return end > arg ? 0 : -EINVAL;
811   -}
812   -early_param("elfcorehdr", setup_elfcorehdr);
813   -#endif /* CONFIG_CRASH_DUMP */
814   -
815 791 static void __init squash_mem_tags(struct tag *tag)
816 792 {
817 793 for (; tag->hdr.size; tag = tag_next(tag))
arch/ia64/kernel/crash_dump.c
... ... @@ -13,9 +13,6 @@
13 13 #include <asm/page.h>
14 14 #include <asm/uaccess.h>
15 15  
16   -/* Stores the physical address of elf header of crash image. */
17   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
18   -
19 16 /**
20 17 * copy_oldmem_page - copy one page from "oldmem"
21 18 * @pfn: page frame number to be copied
arch/ia64/kernel/efi.c
... ... @@ -23,6 +23,7 @@
23 23 */
24 24 #include <linux/module.h>
25 25 #include <linux/bootmem.h>
  26 +#include <linux/crash_dump.h>
26 27 #include <linux/kernel.h>
27 28 #include <linux/init.h>
28 29 #include <linux/types.h>
arch/ia64/kernel/setup.c
... ... @@ -479,25 +479,7 @@
479 479 }
480 480 early_param("nomca", setup_nomca);
481 481  
482   -/*
483   - * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
484   - * is_kdump_kernel() to determine if we are booting after a panic. Hence
485   - * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
486   - */
487 482 #ifdef CONFIG_CRASH_DUMP
488   -/* elfcorehdr= specifies the location of elf core header
489   - * stored by the crashed kernel.
490   - */
491   -static int __init parse_elfcorehdr(char *arg)
492   -{
493   - if (!arg)
494   - return -EINVAL;
495   -
496   - elfcorehdr_addr = memparse(arg, &arg);
497   - return 0;
498   -}
499   -early_param("elfcorehdr", parse_elfcorehdr);
500   -
501 483 int __init reserve_elfcorehdr(u64 *start, u64 *end)
502 484 {
503 485 u64 length;
arch/powerpc/kernel/crash_dump.c
... ... @@ -28,9 +28,6 @@
28 28 #define DBG(fmt...)
29 29 #endif
30 30  
31   -/* Stores the physical address of elf header of crash image. */
32   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
33   -
34 31 #ifndef CONFIG_RELOCATABLE
35 32 void __init reserve_kdump_trampoline(void)
36 33 {
... ... @@ -71,20 +68,6 @@
71 68 DBG(" <- setup_kdump_trampoline()\n");
72 69 }
73 70 #endif /* CONFIG_RELOCATABLE */
74   -
75   -/*
76   - * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
77   - * is_kdump_kernel() to determine if we are booting after a panic. Hence
78   - * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
79   - */
80   -static int __init parse_elfcorehdr(char *p)
81   -{
82   - if (p)
83   - elfcorehdr_addr = memparse(p, &p);
84   -
85   - return 1;
86   -}
87   -__setup("elfcorehdr=", parse_elfcorehdr);
88 71  
89 72 static int __init parse_savemaxmem(char *p)
90 73 {
arch/sh/kernel/crash_dump.c
... ... @@ -9,28 +9,6 @@
9 9 #include <linux/io.h>
10 10 #include <asm/uaccess.h>
11 11  
12   -/* Stores the physical address of elf header of crash image. */
13   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
14   -
15   -/*
16   - * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
17   - * is_kdump_kernel() to determine if we are booting after a panic. Hence
18   - * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
19   - *
20   - * elfcorehdr= specifies the location of elf core header
21   - * stored by the crashed kernel.
22   - */
23   -static int __init parse_elfcorehdr(char *arg)
24   -{
25   - if (!arg)
26   - return -EINVAL;
27   -
28   - elfcorehdr_addr = memparse(arg, &arg);
29   -
30   - return 0;
31   -}
32   -early_param("elfcorehdr", parse_elfcorehdr);
33   -
34 12 /**
35 13 * copy_oldmem_page - copy one page from "oldmem"
36 14 * @pfn: page frame number to be copied
arch/x86/kernel/crash_dump_32.c
... ... @@ -14,9 +14,6 @@
14 14  
15 15 static void *kdump_buf_page;
16 16  
17   -/* Stores the physical address of elf header of crash image. */
18   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
19   -
20 17 static inline bool is_crashed_pfn_valid(unsigned long pfn)
21 18 {
22 19 #ifndef CONFIG_X86_PAE
arch/x86/kernel/crash_dump_64.c
... ... @@ -10,9 +10,6 @@
10 10 #include <linux/uaccess.h>
11 11 #include <linux/io.h>
12 12  
13   -/* Stores the physical address of elf header of crash image. */
14   -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
15   -
16 13 /**
17 14 * copy_oldmem_page - copy one page from "oldmem"
18 15 * @pfn: page frame number to be copied
arch/x86/kernel/e820.c
... ... @@ -11,6 +11,7 @@
11 11 #include <linux/kernel.h>
12 12 #include <linux/types.h>
13 13 #include <linux/init.h>
  14 +#include <linux/crash_dump.h>
14 15 #include <linux/bootmem.h>
15 16 #include <linux/pfn.h>
16 17 #include <linux/suspend.h>
arch/x86/kernel/setup.c
... ... @@ -619,28 +619,6 @@
619 619  
620 620 }
621 621  
622   -/*
623   - * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
624   - * is_kdump_kernel() to determine if we are booting after a panic. Hence
625   - * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
626   - */
627   -
628   -#ifdef CONFIG_CRASH_DUMP
629   -/* elfcorehdr= specifies the location of elf core header
630   - * stored by the crashed kernel. This option will be passed
631   - * by kexec loader to the capture kernel.
632   - */
633   -static int __init setup_elfcorehdr(char *arg)
634   -{
635   - char *end;
636   - if (!arg)
637   - return -EINVAL;
638   - elfcorehdr_addr = memparse(arg, &end);
639   - return end > arg ? 0 : -EINVAL;
640   -}
641   -early_param("elfcorehdr", setup_elfcorehdr);
642   -#endif
643   -
644 622 static __init void reserve_ibft_region(void)
645 623 {
646 624 unsigned long addr, size = 0;
include/linux/bootmem.h
... ... @@ -19,10 +19,6 @@
19 19 */
20 20 extern unsigned long max_pfn;
21 21  
22   -#ifdef CONFIG_CRASH_DUMP
23   -extern unsigned long saved_max_pfn;
24   -#endif
25   -
26 22 #ifndef CONFIG_NO_BOOTMEM
27 23 /*
28 24 * node_bootmem_map is a map pointer - the bits represent all physical
... ... @@ -107,6 +107,7 @@
107 107 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
108 108 obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
109 109 obj-$(CONFIG_PADATA) += padata.o
  110 +obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
110 111  
111 112 ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
112 113 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
  1 +#include <linux/kernel.h>
  2 +#include <linux/crash_dump.h>
  3 +#include <linux/init.h>
  4 +#include <linux/errno.h>
  5 +#include <linux/module.h>
  6 +
  7 +/*
  8 + * If we have booted due to a crash, max_pfn will be a very low value. We need
  9 + * to know the amount of memory that the previous kernel used.
  10 + */
  11 +unsigned long saved_max_pfn;
  12 +
  13 +/*
  14 + * stores the physical address of elf header of crash image
  15 + *
  16 + * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
  17 + * is_kdump_kernel() to determine if we are booting after a panic. Hence put
  18 + * it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
  19 + */
  20 +unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
  21 +
  22 +/*
  23 + * elfcorehdr= specifies the location of elf core header stored by the crashed
  24 + * kernel. This option will be passed by kexec loader to the capture kernel.
  25 + */
  26 +static int __init setup_elfcorehdr(char *arg)
  27 +{
  28 + char *end;
  29 + if (!arg)
  30 + return -EINVAL;
  31 + elfcorehdr_addr = memparse(arg, &end);
  32 + return end > arg ? 0 : -EINVAL;
  33 +}
  34 +early_param("elfcorehdr", setup_elfcorehdr);
... ... @@ -34,14 +34,6 @@
34 34 unsigned long min_low_pfn;
35 35 unsigned long max_pfn;
36 36  
37   -#ifdef CONFIG_CRASH_DUMP
38   -/*
39   - * If we have booted due to a crash, max_pfn will be a very low value. We need
40   - * to know the amount of memory that the previous kernel used.
41   - */
42   -unsigned long saved_max_pfn;
43   -#endif
44   -
45 37 bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
46 38  
47 39 static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list);
... ... @@ -32,14 +32,6 @@
32 32 unsigned long min_low_pfn;
33 33 unsigned long max_pfn;
34 34  
35   -#ifdef CONFIG_CRASH_DUMP
36   -/*
37   - * If we have booted due to a crash, max_pfn will be a very low value. We need
38   - * to know the amount of memory that the previous kernel used.
39   - */
40   -unsigned long saved_max_pfn;
41   -#endif
42   -
43 35 static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
44 36 u64 goal, u64 limit)
45 37 {