[PATCH v2 6/8] x86: kdump: use generic interface to simplify crashkernel reservation code

Baoquan He bhe at redhat.com
Wed Aug 30 04:39:05 PDT 2023


On 08/30/23 at 09:49am, kernel test robot wrote:
> Hi Baoquan,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on arm64/for-next/core]
> [also build test ERROR on tip/x86/core powerpc/next powerpc/fixes v6.5]
> [cannot apply to linus/master next-20230829]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/crash_core-c-remove-unnecessary-parameter-of-function/20230829-201942
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
> patch link:    https://lore.kernel.org/r/20230829121610.138107-7-bhe%40redhat.com
> patch subject: [PATCH v2 6/8] x86: kdump: use generic interface to simplify crashkernel reservation code
> config: x86_64-randconfig-r022-20230830 (https://download.01.org/0day-ci/archive/20230830/202308300910.e0i4piJT-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230830/202308300910.e0i4piJT-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp at intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202308300910.e0i4piJT-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    ld: vmlinux.o: in function `reserve_crashkernel_low':
>    kernel/crash_core.c:369: undefined reference to `crashk_low_res'
>    ld: kernel/crash_core.c:369: undefined reference to `crashk_low_res'
>    ld: kernel/crash_core.c:370: undefined reference to `crashk_low_res'
>    ld: kernel/crash_core.c:369: undefined reference to `crashk_low_res'
>    ld: kernel/crash_core.c:370: undefined reference to `crashk_low_res'
>    ld: vmlinux.o:kernel/crash_core.c:371: more undefined references to `crashk_low_res' follow
>    ld: vmlinux.o: in function `reserve_crashkernel_generic':
> >> kernel/crash_core.c:453: undefined reference to `crashk_res'
> >> ld: kernel/crash_core.c:453: undefined reference to `crashk_res'
>    ld: kernel/crash_core.c:454: undefined reference to `crashk_res'
> >> ld: kernel/crash_core.c:453: undefined reference to `crashk_res'
>    ld: kernel/crash_core.c:454: undefined reference to `crashk_res'
>    ld: vmlinux.o:kernel/crash_core.c:454: more undefined references to `crashk_res' follow

Thanks for reporting. This one has the same root cause as the i386-randconfig
building. It's because crashk_res|crashk_low_res are defined in
kernel/kexec_core.c, but referenced in generic reservation code in
crash_core.c, while in this lkp's randconfig, CONFIG_KEXEC_CORE is
unset, CONFIG_CRASH_CORE=on. Then undefined reference to `crashk_res'
and `crashk_low_res' are reported.

Below patch can fix it. I will post v3 to contain this.

>From 5a5bda3b5b1e370b789489d87516c8f1fb966c46 Mon Sep 17 00:00:00 2001
From: Baoquan He <bhe at redhat.com>
Date: Tue, 29 Aug 2023 22:38:15 -0400
Subject: [PATCH] crash_core: move crashk_res and crashk_low_res definition
 into crash_core.c
Content-type: text/plain

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 at redhat.com>
---
 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




More information about the linux-arm-kernel mailing list