Re: [PATCH] riscv: crash: Add crash hotplug support

From: kernel test robot

Date: Wed Sep 09 2026 - 17:45:51 EST


Hi Rui,

kernel test robot noticed the following build errors:

[auto build test ERROR on kees/for-next/kspp]
[also build test ERROR on linus/master kees/for-next/pstore v7.3-rc2 next-20260909]
[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/Rui-Qi/riscv-crash-Add-crash-hotplug-support/20260908-205143
base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/kspp
patch link: https://lore.kernel.org/r/20260908125155.1777895-1-qirui.001%40bytedance.com
patch subject: [PATCH] riscv: crash: Add crash hotplug support
config: riscv-randconfig-r071-20260910 (https://download.01.org/0day-ci/archive/20260910/202609100553.E6HUYviI-lkp@xxxxxxxxx/config)
compiler: clang version 21.1.8 (https://github.com/llvm/llvm-project 2078da43e25a4623cab2d0d60decddf709aaea28)
smatch: v0.5.0-9187-g5189e3fb
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260910/202609100553.E6HUYviI-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609100553.E6HUYviI-lkp@xxxxxxxxx/

All error/warnings (new ones prefixed by >>):

In file included from kernel/crash_reserve.c:12:
In file included from include/linux/kexec.h:38:
>> arch/riscv/include/asm/kexec.h:79:45: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
arch/riscv/include/asm/kexec.h:82:39: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
2 warnings generated.
--
In file included from kernel/kexec.c:13:
In file included from include/linux/kexec.h:38:
>> arch/riscv/include/asm/kexec.h:79:45: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
arch/riscv/include/asm/kexec.h:82:39: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
>> kernel/kexec.c:138:61: error: incompatible pointer types passing 'struct kimage *' to parameter of type 'struct kimage *' [-Werror,-Wincompatible-pointer-types]
138 | if ((flags & KEXEC_ON_CRASH) && arch_crash_hotplug_support(image, flags))
| ^~~~~
arch/riscv/include/asm/kexec.h:82:47: note: passing argument to parameter 'image' here
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
2 warnings and 1 error generated.
--
In file included from kernel/crash_core.c:14:
In file included from include/linux/kexec.h:38:
>> arch/riscv/include/asm/kexec.h:79:45: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
arch/riscv/include/asm/kexec.h:82:39: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
>> kernel/crash_core.c:718:34: error: incompatible pointer types passing 'struct kimage *' to parameter of type 'struct kimage *' [-Werror,-Wincompatible-pointer-types]
718 | arch_crash_handle_hotplug_event(image, arg);
| ^~~~~
arch/riscv/include/asm/kexec.h:79:53: note: passing argument to parameter 'image' here
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
2 warnings and 1 error generated.
--
In file included from arch/riscv/kernel/crash.c:8:
In file included from include/linux/kexec.h:38:
>> arch/riscv/include/asm/kexec.h:79:45: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
arch/riscv/include/asm/kexec.h:82:39: warning: declaration of 'struct kimage' will not be visible outside of this function [-Wvisibility]
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
>> arch/riscv/kernel/crash.c:18:5: error: conflicting types for 'arch_crash_hotplug_support'
18 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
| ^
arch/riscv/include/asm/kexec.h:83:36: note: expanded from macro 'arch_crash_hotplug_support'
83 | #define arch_crash_hotplug_support arch_crash_hotplug_support
| ^
arch/riscv/include/asm/kexec.h:82:5: note: previous declaration is here
82 | int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags);
| ^
>> arch/riscv/kernel/crash.c:53:6: error: conflicting types for 'arch_crash_handle_hotplug_event'
53 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
| ^
arch/riscv/include/asm/kexec.h:80:41: note: expanded from macro 'arch_crash_handle_hotplug_event'
80 | #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
| ^
arch/riscv/include/asm/kexec.h:79:6: note: previous declaration is here
79 | void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
| ^
2 warnings and 2 errors generated.


vim +/arch_crash_hotplug_support +18 arch/riscv/kernel/crash.c

17
> 18 int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
19 {
20 #ifdef CONFIG_KEXEC_FILE
21 if (image->file_mode)
22 return 1;
23 #endif
24 /*
25 * For the kexec_load() syscall path, the user space kexec tool
26 * needs to indicate that the elfcorehdr segment is excluded from
27 * SHA verification by setting the appropriate flags.
28 */
29 return (kexec_flags & KEXEC_UPDATE_ELFCOREHDR ||
30 kexec_flags & KEXEC_CRASH_HOTPLUG_SUPPORT);
31 }
32
33 unsigned int arch_crash_get_elfcorehdr_size(void)
34 {
35 unsigned int sz;
36
37 /* kernel_map, VMCOREINFO and maximum CPUs */
38 sz = 2 + CONFIG_NR_CPUS;
39 if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
40 sz += CONFIG_CRASH_MAX_MEMORY_RANGES;
41 sz *= sizeof(Elf64_Phdr);
42 return sz;
43 }
44
45 /**
46 * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
47 * @image: a pointer to kexec_crash_image
48 * @arg: struct memory_notify handler for memory hotplug case and
49 * NULL for CPU hotplug case.
50 *
51 * Prepare the new elfcorehdr and replace the existing elfcorehdr.
52 */
> 53 void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
54 {
55 void *elfbuf = NULL, *old_elfcorehdr;
56 unsigned long mem, memsz;
57 unsigned long elfsz = 0;
58
59 /*
60 * As crash_prepare_elf64_headers() has already described all
61 * possible CPUs, there is no need to update the elfcorehdr
62 * for additional CPU changes.
63 */
64 if ((image->file_mode || image->elfcorehdr_updated) &&
65 ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) ||
66 (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU)))
67 return;
68
69 /*
70 * Create the new elfcorehdr reflecting the changes to CPU and/or
71 * memory resources.
72 */
73 if (crash_prepare_headers(true, &elfbuf, &elfsz, NULL)) {
74 pr_err("unable to create new elfcorehdr");
75 goto out;
76 }
77
78 /*
79 * Obtain address and size of the elfcorehdr segment, and
80 * check it against the new elfcorehdr buffer.
81 */
82 mem = image->segment[image->elfcorehdr_index].mem;
83 memsz = image->segment[image->elfcorehdr_index].memsz;
84 if (elfsz > memsz) {
85 pr_err("update elfcorehdr elfsz %lu > memsz %lu",
86 elfsz, memsz);
87 goto out;
88 }
89
90 /*
91 * Copy new elfcorehdr over the old elfcorehdr at destination.
92 */
93 old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT));
94 if (!old_elfcorehdr) {
95 pr_err("mapping elfcorehdr segment failed\n");
96 goto out;
97 }
98
99 /*
100 * Temporarily invalidate the crash image while the
101 * elfcorehdr is updated.
102 */
103 xchg(&kexec_crash_image, NULL);
104 memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz);
105 xchg(&kexec_crash_image, image);
106 kunmap_local(old_elfcorehdr);
107 pr_debug("updated elfcorehdr\n");
108
109 out:
110 vfree(elfbuf);
111 }
112

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki