Skip to content

Commit b631b95

Browse files
Baoquan Heakpm00
authored andcommitted
crash_core: move crashk_*res definition into crash_core.c
Both crashk_res and crashk_low_res are used to mark the reserved crashkernel regions in iomem_resource tree. And later the generic crashkernel resrvation will be added into crash_core.c. So move crashk_res and crashk_low_res definition into crash_core.c to avoid compiling error if CONFIG_CRASH_CORE=on while CONFIG_KEXEC_CORE is unset. Meanwhile include <asm/crash_core.h> in <linux/crash_core.h> if generic reservation is needed. In that case, <asm/crash_core.h> need be added by ARCH. In asm/crash_core.h, ARCH can provide its own macro definitions to override macros in <linux/crash_core.h> if needed. Wrap the including into CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope to avoid compiling error in other ARCH-es which don't take the generic reservation way yet. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Zhen Lei <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Chen Jiahao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0ab9716 commit b631b95

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

include/linux/crash_core.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
#include <linux/linkage.h>
66
#include <linux/elfcore.h>
77
#include <linux/elf.h>
8+
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
9+
#include <asm/crash_core.h>
10+
#endif
11+
12+
/* Location of a reserved region to hold the crash kernel.
13+
*/
14+
extern struct resource crashk_res;
15+
extern struct resource crashk_low_res;
816

917
#define CRASH_CORE_NOTE_NAME "CORE"
1018
#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)

include/linux/kexec.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#include <uapi/linux/kexec.h>
2323
#include <linux/verification.h>
2424

25-
/* Location of a reserved region to hold the crash kernel.
26-
*/
27-
extern struct resource crashk_res;
28-
extern struct resource crashk_low_res;
2925
extern note_buf_t __percpu *crash_notes;
3026

3127
#ifdef CONFIG_KEXEC_CORE

kernel/crash_core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ u32 *vmcoreinfo_note;
3535
/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */
3636
static unsigned char *vmcoreinfo_data_safecopy;
3737

38+
/* Location of the reserved area for the crash kernel */
39+
struct resource crashk_res = {
40+
.name = "Crash kernel",
41+
.start = 0,
42+
.end = 0,
43+
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
44+
.desc = IORES_DESC_CRASH_KERNEL
45+
};
46+
struct resource crashk_low_res = {
47+
.name = "Crash kernel",
48+
.start = 0,
49+
.end = 0,
50+
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
51+
.desc = IORES_DESC_CRASH_KERNEL
52+
};
53+
3854
/*
3955
* parsing the "crashkernel" commandline
4056
*

kernel/kexec_core.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,6 @@ atomic_t __kexec_lock = ATOMIC_INIT(0);
5252
/* Flag to indicate we are going to kexec a new kernel */
5353
bool kexec_in_progress = false;
5454

55-
56-
/* Location of the reserved area for the crash kernel */
57-
struct resource crashk_res = {
58-
.name = "Crash kernel",
59-
.start = 0,
60-
.end = 0,
61-
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
62-
.desc = IORES_DESC_CRASH_KERNEL
63-
};
64-
struct resource crashk_low_res = {
65-
.name = "Crash kernel",
66-
.start = 0,
67-
.end = 0,
68-
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
69-
.desc = IORES_DESC_CRASH_KERNEL
70-
};
71-
7255
int kexec_should_crash(struct task_struct *p)
7356
{
7457
/*

0 commit comments

Comments
 (0)