[PATCH] crash_core: move crashk_res and crashk_low_res definition into crash_core.c

From: Baoquan He
Date: Tue Aug 29 2023 - 22:38:15 EST


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 which references them will be added into
crash_core.c. So move crashk_res and crashk_low_res definition into
crash_core.c to avoid compiling error when CONFIG_CRASH_CORE=on while
CONFIG_KEXEC_CORE is unset.

Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
---
include/linux/crash_core.h | 5 +++++
include/linux/kexec.h | 4 ----
kernel/crash_core.c | 16 ++++++++++++++++
kernel/kexec_core.c | 17 -----------------
4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index d64006c4bd43..daa87b8730d3 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -9,6 +9,11 @@
#include <asm/crash_core.h>
#endif

+/* Location of a reserved region to hold the crash kernel.
+ */
+extern struct resource crashk_res;
+extern struct resource crashk_low_res;
+
#define CRASH_CORE_NOTE_NAME "CORE"
#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 22b5cd24f581..e762b0435c39 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -22,10 +22,6 @@
#include <uapi/linux/kexec.h>
#include <linux/verification.h>

-/* Location of a reserved region to hold the crash kernel.
- */
-extern struct resource crashk_res;
-extern struct resource crashk_low_res;
extern note_buf_t __percpu *crash_notes;

#ifdef CONFIG_KEXEC_CORE
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 61a8ea3b23a2..d76e7280c651 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -28,6 +28,22 @@ u32 *vmcoreinfo_note;
/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */
static unsigned char *vmcoreinfo_data_safecopy;

+/* Location of the reserved area for the crash kernel */
+struct resource crashk_res = {
+ .name = "Crash kernel",
+ .start = 0,
+ .end = 0,
+ .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
+ .desc = IORES_DESC_CRASH_KERNEL
+};
+struct resource crashk_low_res = {
+ .name = "Crash kernel",
+ .start = 0,
+ .end = 0,
+ .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
+ .desc = IORES_DESC_CRASH_KERNEL
+};
+
/*
* parsing the "crashkernel" commandline
*
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index e2f2574d8b74..03ee65546df6 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -55,23 +55,6 @@ note_buf_t __percpu *crash_notes;
/* Flag to indicate we are going to kexec a new kernel */
bool kexec_in_progress = false;

-
-/* Location of the reserved area for the crash kernel */
-struct resource crashk_res = {
- .name = "Crash kernel",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
- .desc = IORES_DESC_CRASH_KERNEL
-};
-struct resource crashk_low_res = {
- .name = "Crash kernel",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
- .desc = IORES_DESC_CRASH_KERNEL
-};
-
int kexec_should_crash(struct task_struct *p)
{
/*
--
2.41.0