x86, crash: don't nest CONFIG_CRASH_DUMP ifdef inside CONFIG_KEXEC_CODE ifdef scope
Subsystems (11)
PATCH 1/3 x86, crash: don't nest CONFIG_CRASH_DUMP ifdef inside CONFIG_KEXEC_CODE ifdef scope
Michael pointed out that the #ifdef CONFIG_CRASH_DUMP is nested inside arch/x86/xen/enlighten_hvm.c.
Although the nesting works well too since CONFIG_CRASH_DUMP has dependency on CONFIG_KEXEC_CORE, it may cause confuse because there are places where it's not nested, and people may think it need be nested even though it doesn't have to.
Fix that by moving CONFIG_CRASH_DUMP ifdeffery of codes out of CONFIG_KEXEC_CODE ifdeffery scope.
And also fix a building error Nathan reported as below by replacing CONFIG_KEXEC_CORE ifdef with CONFIG_VMCORE_INFO ifdef.
====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.x86_64 $ make -skj"$(nproc)" ARCH=x86_64 CROSS_COMPILE=x86_64-linux- olddefconfig all ... x86_64-linux-ld: arch/x86/xen/mmu_pv.o: in function `paddr_vmcoreinfo_note': mmu_pv.c:(.text+0x3af3): undefined reference to `vmcoreinfo_note' ====
--- arch/x86/kernel/cpu/mshyperv.c | 10 ++++++---- arch/x86/kernel/reboot.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/mmu_pv.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +6 -4
@@ -209,6 +209,7 @@ static void hv_machine_shutdown(void)if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs)
@@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)/* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup (); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static uint32_t __init ms_hyperv_platform (void )
@@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif -#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) +#if IS_ENABLED (CONFIG_HYPERV ) +#if defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP ) machine_ops.crash_shutdown = hv_machine_crash_shutdown;#endif #endif
arch/x86/kernel/reboot.c +1 -1
@@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt (); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown (struct pt_regs *regs) { machine_ops.crash_shutdown (regs);
arch/x86/xen/enlighten_hvm.c +2 -2
@@ -148,6 +148,7 @@ static void xen_hvm_shutdown(void)if (kexec_in_progress) xen_reboot(SHUTDOWN_soft_reset); } +#endif #ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs)
@@ -156,7 +157,6 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) xen_reboot(SHUTDOWN_soft_reset); }#endif -#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu) {
@@ -238,10 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#endif #ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif -#endif }static __init int xen_parse_nopv (char *arg)
arch/x86/xen/mmu_pv.c +1 -1
@@ -2520,7 +2520,7 @@ int xen_remap_pfn(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL_GPL (xen_remap_pfn); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_VMCORE_INFO phys_addr_t paddr_vmcoreinfo_note (void ) {if (xen_pv_domain ())
Signature · 1 line
2.41.0
PATCH 2/3 crash: fix building error in generic codes
Nathan reported some building errors on arm64 as below:
==========
$ curl -LSso .config https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/linux-aarch64/config $ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux- olddefconfig all ... aarch64-linux-ld: kernel/kexec_file.o: in function `kexec_walk_memblock.constprop.0': kexec_file.c:(.text+0x314): undefined reference to `crashk_res' ... aarch64-linux-ld: drivers/of/kexec.o: in function `of_kexec_alloc_and_setup_fdt': kexec.c:(.text+0x580): undefined reference to `crashk_res' ... aarch64-linux-ld: kexec.c:(.text+0x5c0): undefined reference to `crashk_low_res' ==========
On the provided config, it has:
===CONFIG_VMCORE_INFO=yCONFIG_KEXEC_CORE=yCONFIG_KEXEC=yCONFIG_KEXEC_FILE=y
===
For these crash related code blocks, they need put inside CONFIG_CRASH_DUMP ifdeffery scope to avoid building erorr when CONFIG_CRASH_DUMP is not set.
--- drivers/of/kexec.c | 2 ++ kernel/kexec_file.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/of/kexec.c +2 -0
@@ -395,6 +395,7 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,if (ret) goto out; +#ifdef CONFIG_CRASH_DUMP /* add linux,usable-memory-range */ ret = fdt_appendprop_addrrange(fdt, 0, chosen_node, "linux,usable-memory-range", crashk_res.start,
@@ -410,6 +411,7 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,if (ret) goto out; } +#endif }/* add bootargs */
kernel/kexec_file.c +2 -0
@@ -540,8 +540,10 @@ static int kexec_walk_memblock(struct kexec_buf *kbuf,phys_addr_t mstart, mend;struct resource res = { }; +#ifdef CONFIG_CRASH_DUMP if (kbuf->image->type ==KEXEC_TYPE_CRASH )return func (&crashk_res, kbuf); +#endif /* * Using MEMBLOCK_NONE will properly skip MEMBLOCK_DRIVER_MANAGED. See
Signature · 1 line
2.41.0
PATCH 3/3 arch, crash: move arch_crash_save_vmcoreinfo() out to file vmcore_info.c
In reply to Baoquan HeNathan reported below building error:
=====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.armv7 $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- olddefconfig all ... arm-linux-gnueabi-ld: arch/arm/kernel/machine_kexec.o: in function `arch_crash_save_vmcoreinfo': machine_kexec.c:(.text+0x488): undefined reference to `vmcoreinfo_append_str' ====
On architecutres, like arm, s390, ppc, sh, function arch_crash_save_vmcoreinfo() is located in machine_kexec.c and it can only be compiled in when CONFIG_KEXEC_CORE=y.
That's not right because arch_crash_save_vmcoreinfo() is used to export arch specific vmcoreinfo. CONFIG_VMCORE_INFO is supposed to control its compiling in. However, CONFIG_VMVCORE_INFO could be independent of CONFIG_KEXEC_CORE, e.g CONFIG_PROC_KCORE=y will select CONFIG_VMVCORE_INFO. Or CONFIG_KEXEC/CONFIG_KEXEC_FILE is set while CONFIG_CRASH_DUMP is not set, it will report linking error.
So, on arm, s390, ppc and sh, move arch_crash_save_vmcoreinfo out to a new file vmcore_info.c. Let CONFIG_VMCORE_INFO decide if compiling in arch_crash_save_vmcoreinfo().
--- arch/arm/kernel/Makefile | 1 + arch/arm/kernel/machine_kexec.c | 7 ------- arch/arm/kernel/vmcore_info.c | 10 ++++++++++ arch/powerpc/kexec/Makefile | 1 + arch/powerpc/kexec/core.c | 28 -------------------------- arch/powerpc/kexec/vmcore_info.c | 34 ++++++++++++++++++++++++++++++++ arch/s390/kernel/Makefile | 1 + arch/s390/kernel/machine_kexec.c | 15 -------------- arch/s390/kernel/vmcore_info.c | 23 +++++++++++++++++++++ arch/sh/kernel/Makefile | 1 + arch/sh/kernel/machine_kexec.c | 11 ----------- arch/sh/kernel/vmcore_info.c | 17 ++++++++++++++++ 12 files changed, 88 insertions(+), 61 deletions(-) create mode 100644 arch/arm/kernel/vmcore_info.c create mode 100644 arch/powerpc/kexec/vmcore_info.c create mode 100644 arch/s390/kernel/vmcore_info.c create mode 100644 arch/sh/kernel/vmcore_info.c
arch/arm/kernel/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o patch.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o patch.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o # Main staffs in KPROBES are in arch/arm/probes/ . obj-$(CONFIG_KPROBES) += patch.o insn.o obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
arch/arm/kernel/machine_kexec.c +0 -7
@@ -198,10 +198,3 @@ void machine_kexec(struct kimage *image)soft_restart (reboot_entry_phys); } - -void arch_crash_save_vmcoreinfo (void ) -{ -#ifdef CONFIG_ARM_LPAE -VMCOREINFO_CONFIG (ARM_LPAE ); -#endif -}
arch/arm/kernel/vmcore_info.c new file +10 -0
@@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/vmcore_info.h> + +void arch_crash_save_vmcoreinfo (void ) +{ +#ifdef CONFIG_ARM_LPAE +VMCOREINFO_CONFIG (ARM_LPAE ); +#endif +}
arch/powerpc/kexec/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-y += core.o crash.o core_$(BITS).o obj-$(CONFIG_PPC32) += relocate_32.o obj-$(CONFIG_KEXEC_FILE) += file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o # Disable GCOV, KCOV & sanitizers in odd or sensitive code GCOV_PROFILE_core_$(BITS).o := n
arch/powerpc/kexec/core.c +0 -28
@@ -53,34 +53,6 @@ void machine_kexec_cleanup(struct kimage *image) { } -void arch_crash_save_vmcoreinfo (void ) -{ - -#ifdef CONFIG_NUMA -VMCOREINFO_SYMBOL (node_data); -VMCOREINFO_LENGTH (node_data,MAX_NUMNODES ); -#endif -#ifndef CONFIG_NUMA -VMCOREINFO_SYMBOL (contig_page_data); -#endif -#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP ) -VMCOREINFO_SYMBOL (vmemmap_list); -VMCOREINFO_SYMBOL (mmu_vmemmap_psize); -VMCOREINFO_SYMBOL (mmu_psize_defs); -VMCOREINFO_STRUCT_SIZE (vmemmap_backing); -VMCOREINFO_OFFSET (vmemmap_backing, list); -VMCOREINFO_OFFSET (vmemmap_backing, phys); -VMCOREINFO_OFFSET (vmemmap_backing, virt_addr); -VMCOREINFO_STRUCT_SIZE (mmu_psize_def); -VMCOREINFO_OFFSET (mmu_psize_def, shift); -#endif -VMCOREINFO_SYMBOL (cur_cpu_spec); -VMCOREINFO_OFFSET (cpu_spec, cpu_features); -VMCOREINFO_OFFSET (cpu_spec, mmu_features); -vmcoreinfo_append_str ("NUMBER(RADIX_MMU)=%d\n" ,early_radix_enabled ()); -vmcoreinfo_append_str ("KERNELOFFSET=%lx\n" ,kaslr_offset ()); -} -/* * Do not allocate memory (or fail in any way) in machine_kexec(). * We are past the point of no return, committed to rebooting now.
arch/powerpc/kexec/vmcore_info.c new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/vmcore_info.h> +#include <asm/pgalloc.h> + +void arch_crash_save_vmcoreinfo (void ) +{ + +#ifdef CONFIG_NUMA +VMCOREINFO_SYMBOL (node_data); +VMCOREINFO_LENGTH (node_data,MAX_NUMNODES ); +#endif +#ifndef CONFIG_NUMA +VMCOREINFO_SYMBOL (contig_page_data); +#endif +#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP ) +VMCOREINFO_SYMBOL (vmemmap_list); +VMCOREINFO_SYMBOL (mmu_vmemmap_psize); +VMCOREINFO_SYMBOL (mmu_psize_defs); +VMCOREINFO_STRUCT_SIZE (vmemmap_backing); +VMCOREINFO_OFFSET (vmemmap_backing, list); +VMCOREINFO_OFFSET (vmemmap_backing, phys); +VMCOREINFO_OFFSET (vmemmap_backing, virt_addr); +VMCOREINFO_STRUCT_SIZE (mmu_psize_def); +VMCOREINFO_OFFSET (mmu_psize_def, shift); +#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, cpu_features); +VMCOREINFO_OFFSET (cpu_spec, mmu_features); +vmcoreinfo_append_str ("NUMBER(RADIX_MMU)=%d\n" ,early_radix_enabled ()); +vmcoreinfo_append_str ("KERNELOFFSET=%lx\n" ,kaslr_offset ()); +} + +
arch/s390/kernel/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o obj-$(CONFIG_FUNCTION_TRACER) += mcount.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_UPROBES) += uprobes.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o
arch/s390/kernel/machine_kexec.c +0 -15
@@ -209,21 +209,6 @@ void machine_kexec_cleanup(struct kimage *image) { } -void arch_crash_save_vmcoreinfo (void ) -{ -struct lowcore *abs_lc; - -VMCOREINFO_SYMBOL (lowcore_ptr); -VMCOREINFO_SYMBOL (high_memory); -VMCOREINFO_LENGTH (lowcore_ptr,NR_CPUS ); -vmcoreinfo_append_str ("SAMODE31=%lx\n" , (unsigned long )__samode31); -vmcoreinfo_append_str ("EAMODE31=%lx\n" , (unsigned long )__eamode31); -vmcoreinfo_append_str ("KERNELOFFSET=%lx\n" ,kaslr_offset ()); - abs_lc =get_abs_lowcore (); - abs_lc->vmcore_info =paddr_vmcoreinfo_note (); -put_abs_lowcore (abs_lc); -} -void machine_shutdown (void ) { }
arch/s390/kernel/vmcore_info.c new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/vmcore_info.h> +#include <asm/abs_lowcore.h> +#include <linux/mm.h> +#include <asm/setup.h> + +void arch_crash_save_vmcoreinfo (void ) +{ +struct lowcore *abs_lc; + +VMCOREINFO_SYMBOL (lowcore_ptr); +VMCOREINFO_SYMBOL (high_memory); +VMCOREINFO_LENGTH (lowcore_ptr,NR_CPUS ); +vmcoreinfo_append_str ("SAMODE31=%lx\n" , (unsigned long )__samode31); +vmcoreinfo_append_str ("EAMODE31=%lx\n" , (unsigned long )__eamode31); +vmcoreinfo_append_str ("KERNELOFFSET=%lx\n" ,kaslr_offset ()); + abs_lc =get_abs_lowcore (); + abs_lc->vmcore_info =paddr_vmcoreinfo_note (); +put_abs_lowcore (abs_lc); +} + +
arch/sh/kernel/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_MODULES) += sh_ksyms_32.o module.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
arch/sh/kernel/machine_kexec.c +0 -11
@@ -137,17 +137,6 @@ void machine_kexec(struct kimage *image)__ftrace_enabled_restore (save_ftrace_enabled); } -void arch_crash_save_vmcoreinfo (void ) -{ -#ifdef CONFIG_NUMA -VMCOREINFO_SYMBOL (node_data); -VMCOREINFO_LENGTH (node_data,MAX_NUMNODES ); -#endif -#ifdef CONFIG_X2TLB -VMCOREINFO_CONFIG (X2TLB ); -#endif -} -void __init reserve_crashkernel (void ) {unsigned long long crash_size, crash_base;
arch/sh/kernel/vmcore_info.c new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/vmcore_info.h> +#include <linux/mm.h> + +void arch_crash_save_vmcoreinfo (void ) +{ +#ifdef CONFIG_NUMA +VMCOREINFO_SYMBOL (node_data); +VMCOREINFO_LENGTH (node_data,MAX_NUMNODES ); +#endif +#ifdef CONFIG_X2TLB +VMCOREINFO_CONFIG (X2TLB ); +#endif +} + +
Signature · 1 line
2.41.0
From: Baoquan He <[email protected]> Sent: Monday, January 29, 2024 5:51 AM
Quoted 3 lines
Michael pointed out that the #ifdef
CONFIG_CRASH_DUMPis nested insidearch/x86/xen/enlighten_hvm.c.
Did some words get left out in the above sentence? It mentions the Xen case, but not the Hyper-V case. I'm not sure what you intended.
Quoted 3 lines
Although the nesting works well too since
CONFIG_CRASH_DUMPhas dependency onCONFIG_KEXEC_CORE, it may cause confuse because there
s/confusion/confuse/
Quoted 1 line
are places where it's not nested, and people may think it need be nested
s/need be/needs to be/
Quoted 18 lines
even though it doesn't have to.
Fix that by moving
CONFIG_CRASH_DUMPifdeffery of codes out ofCONFIG_KEXEC_CODEifdeffery scope.And also fix a building error Nathan reported as below by replacing
CONFIG_KEXEC_COREifdef withCONFIG_VMCORE_INFOifdef.====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.x86_64 $ make -skj"$(nproc)" ARCH=x86_64 CROSS_COMPILE=x86_64-linux- olddefconfig all ... x86_64-linux-ld: arch/x86/xen/mmu_pv.o: in function `paddr_vmcoreinfo_note': mmu_pv.c:(.text+0x3af3): undefined reference to `vmcoreinfo_note' ====
Quoted 3 lines
Modulo the commit message nits, LGTM.
Quoted 107 lines
--- arch/x86/kernel/cpu/mshyperv.c | 10 ++++++---- arch/x86/kernel/reboot.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/mmu_pv.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)arch/x86/kernel/cpu/mshyperv.c +2
-2@@ -209,6 +209,7 @@ static void hv_machine_shutdown(void)if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs)@@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)/* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup (); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static
uint32_t__initms_hyperv_platform(void)arch/x86/kernel/cpu/mshyperv.c +4
-2@@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif -#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) +#if IS_ENABLED (CONFIG_HYPERV ) +#if defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP ) machine_ops.crash_shutdown = hv_machine_crash_shutdown;#endif #endif arch/x86/kernel/reboot.c +1
-1@@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt (); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown (struct pt_regs *regs) { machine_ops.crash_shutdown (regs);arch/x86/xen/enlighten_hvm.c +1
-1@@ -148,6 +148,7 @@ static void xen_hvm_shutdown(void)if (kexec_in_progress) xen_reboot(SHUTDOWN_soft_reset); } +#endif #ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs)@@ -156,7 +157,6 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) xen_reboot(SHUTDOWN_soft_reset); }#endif -#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu){
arch/x86/xen/enlighten_hvm.c +1
-1@@ -238,10 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#endif #ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif -#endif }static __init int xen_parse_nopv (char *arg)arch/x86/xen/mmu_pv.c +1
-1@@ -2520,7 +2520,7 @@ int xen_remap_pfn(struct vm_area_struct *vma,unsigned long addr, }EXPORT_SYMBOL_GPL (xen_remap_pfn ); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_VMCORE_INFO phys_addr_t paddr_vmcoreinfo_note (void ) {if (
xen_pv_domain())
--
2.41.0
Quoted 7 lines · Michael Kelley
From: Baoquan He <[email protected]> Sent: Monday, January 29, 2024 5:51 AM
Quoted 3 lines
Michael pointed out that the #ifdef
CONFIG_CRASH_DUMPis nested insidearch/x86/xen/enlighten_hvm.c.Did some words get left out in the above sentence? It mentions the Xen case, but not the Hyper-V case. I'm not sure what you intended.
Thanks a lot for your careful reviewing.
Yeah, I tried to list all affected file names, seems my vim editor threw away some words. And I forgot mentioning the change in reboot.c.
I adjusted log as below according to your comments, do you think it's OK now?
===
Michael pointed out that the #ifdef CONFIG_CRASH_DUMP is nested inside CONFIG_KEXEC_CODE ifdef scope in some XEN, HyperV codes.
Although the nesting works well too since CONFIG_CRASH_DUMP has dependency on CONFIG_KEXEC_CORE, it may cause confusion because there are places where it's not nested, and people may think it needs be nested even though it doesn't have to.
Fix that by moving CONFIG_CRASH_DUMP ifdeffery of codes out of CONFIG_KEXEC_CODE ifdeffery scope.
And also put function machine_crash_shutdown() definition inside CONFIG_CRASH_DUMP ifdef scope instead of CONFIG_KEXEC_CORE ifdef.
And also fix a building error Nathan reported as below by replacing CONFIG_KEXEC_CORE ifdef with CONFIG_VMCORE_INFO ifdef.
......
===
Thanks
Baoquan
From: Baoquan He <[email protected]>
Quoted 11 lines · Michael Kelley
Quoted 1 line
From: Baoquan He <[email protected]> Sent: Monday, January 29, 2024
5:51 AM
Quoted 6 lines
Quoted 3 lines
Michael pointed out that the #ifdef
CONFIG_CRASH_DUMPis nested insidearch/x86/xen/enlighten_hvm.c.Did some words get left out in the above sentence? It mentions the Xen case, but not the Hyper-V case. I'm not sure what you intended.
Quoted 7 lines
Thanks a lot for your careful reviewing.
Yeah, I tried to list all affected file names, seems my vim editor threw away some words. And I forgot mentioning the change in
reboot.c.I adjusted log as below according to your comments, do you think it's OK now?
Yes -- looks like everything is included and clear up my confusion. But I still have two small nits per below. :-)
Michael
Quoted 4 lines
===
Michael pointed out that the #ifdefCONFIG_CRASH_DUMPis nested insideCONFIG_KEXEC_CODEifdef scope in some XEN, HyperV codes.
s/Hyper-V/HyperV/
Quoted 4 lines
Although the nesting works well too since
CONFIG_CRASH_DUMPhas dependency onCONFIG_KEXEC_CORE, it may cause confusion because there are places where it's not nested, and people may think it needs be nested
s/needs to be/needs be/
Quoted 15 lines
even though it doesn't have to.
Fix that by moving
CONFIG_CRASH_DUMPifdeffery of codes out ofCONFIG_KEXEC_CODEifdeffery scope.And also put function
machine_crash_shutdown()definition insideCONFIG_CRASH_DUMPifdef scope instead ofCONFIG_KEXEC_COREifdef.And also fix a building error Nathan reported as below by replacing
CONFIG_KEXEC_COREifdef withCONFIG_VMCORE_INFOifdef.
......
===Thanks
Baoquan
Quoted 14 lines · Michael Kelley
From: Baoquan He <[email protected]>
Quoted 13 lines · Michael Kelley
Quoted 1 line
From: Baoquan He <[email protected]> Sent: Monday, January 29, 2024
5:51 AM
Quoted 6 lines
Quoted 3 lines
Michael pointed out that the #ifdef
CONFIG_CRASH_DUMPis nested insidearch/x86/xen/enlighten_hvm.c.Did some words get left out in the above sentence? It mentions the Xen case, but not the Hyper-V case. I'm not sure what you intended.
Thanks a lot for your careful reviewing.
Quoted 8 lines
Quoted 5 lines
Yeah, I tried to list all affected file names, seems my vim editor threw away some words. And I forgot mentioning the change in
reboot.c.I adjusted log as below according to your comments, do you think it's OK now?
Yes -- looks like everything is included and clear up my confusion. But I still have two small nits per below. :-)
Right, I will grabbed them into v2. Thanks again.
Quoted 31 lines
Quoted 5 lines
===
Michael pointed out that the #ifdefCONFIG_CRASH_DUMPis nested insideCONFIG_KEXEC_CODEifdef scope in some XEN, HyperV codes.s/Hyper-V/HyperV/
Quoted 4 lines
Although the nesting works well too since
CONFIG_CRASH_DUMPhas dependency onCONFIG_KEXEC_CORE, it may cause confusion because there are places where it's not nested, and people may think it needs be nesteds/needs to be/needs be/
Quoted 15 lines
even though it doesn't have to.
Fix that by moving
CONFIG_CRASH_DUMPifdeffery of codes out ofCONFIG_KEXEC_CODEifdeffery scope.And also put function
machine_crash_shutdown()definition insideCONFIG_CRASH_DUMPifdef scope instead ofCONFIG_KEXEC_COREifdef.And also fix a building error Nathan reported as below by replacing
CONFIG_KEXEC_COREifdef withCONFIG_VMCORE_INFOifdef.
......
===Thanks
Baoquan
Michael pointed out that the CONFIG_CRASH_DUMP ifdef is nested inside CONFIG_KEXEC_CODE ifdef scope in some XEN, Hyper-V codes.
Although the nesting works well too since CONFIG_CRASH_DUMP has dependency on CONFIG_KEXEC_CORE, it may cause confusion because there are places where it's not nested, and people may think it needs to be nested even though it doesn't have to.
Fix that by moving CONFIG_CRASH_DUMP ifdeffery of codes out of CONFIG_KEXEC_CODE ifdeffery scope.
And also put function machine_crash_shutdown() definition inside CONFIG_CRASH_DUMP ifdef scope instead of CONFIG_KEXEC_CORE ifdef.
And also fix a building error Nathan reported as below by replacing CONFIG_KEXEC_CORE ifdef with CONFIG_VMCORE_INFO ifdef.
====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.x86_64 $ make -skj"$(nproc)" ARCH=x86_64 CROSS_COMPILE=x86_64-linux- olddefconfig all ... x86_64-linux-ld: arch/x86/xen/mmu_pv.o: in function `paddr_vmcoreinfo_note': mmu_pv.c:(.text+0x3af3): undefined reference to `vmcoreinfo_note' ====
---v1->v2:
- Add missing words and fix typos in patch log pointed out by Michael.
arch/x86/kernel/cpu/mshyperv.c | 10 ++++++---- arch/x86/kernel/reboot.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/mmu_pv.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +6 -4
@@ -209,6 +209,7 @@ static void hv_machine_shutdown(void)if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs)
@@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)/* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup (); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static uint32_t __init ms_hyperv_platform (void )
@@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif -#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) +#if IS_ENABLED (CONFIG_HYPERV ) +#if defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP ) machine_ops.crash_shutdown = hv_machine_crash_shutdown;#endif #endif
arch/x86/kernel/reboot.c +1 -1
@@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt (); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown (struct pt_regs *regs) { machine_ops.crash_shutdown (regs);
arch/x86/xen/enlighten_hvm.c +2 -2
@@ -148,6 +148,7 @@ static void xen_hvm_shutdown(void)if (kexec_in_progress) xen_reboot(SHUTDOWN_soft_reset); } +#endif #ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs)
@@ -156,7 +157,6 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) xen_reboot(SHUTDOWN_soft_reset); }#endif -#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu) {
@@ -238,10 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#endif #ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif -#endif }static __init int xen_parse_nopv (char *arg)
arch/x86/xen/mmu_pv.c +1 -1
@@ -2520,7 +2520,7 @@ int xen_remap_pfn(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL_GPL (xen_remap_pfn); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_VMCORE_INFO phys_addr_t paddr_vmcoreinfo_note (void ) {if (xen_pv_domain ())
Signature · 1 line
2.41.0
Michael Kelley
Reviewed-byFrom: Baoquan He <[email protected]> Sent: Monday, January 29, 2024 7:00 PM
Quoted 138 lines
Michael pointed out that the
CONFIG_CRASH_DUMPifdef is nested insideCONFIG_KEXEC_CODEifdef scope in some XEN, Hyper-V codes.Although the nesting works well too since
CONFIG_CRASH_DUMPhas dependency onCONFIG_KEXEC_CORE, it may cause confusion because there are places where it's not nested, and people may think it needs to be nested even though it doesn't have to.Fix that by moving
CONFIG_CRASH_DUMPifdeffery of codes out ofCONFIG_KEXEC_CODEifdeffery scope.And also put function
machine_crash_shutdown()definition insideCONFIG_CRASH_DUMPifdef scope instead ofCONFIG_KEXEC_COREifdef.And also fix a building error Nathan reported as below by replacing
CONFIG_KEXEC_COREifdef withCONFIG_VMCORE_INFOifdef.====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.x86_64 $ make -skj"$(nproc)" ARCH=x86_64 CROSS_COMPILE=x86_64-linux- olddefconfig all ... x86_64-linux-ld: arch/x86/xen/mmu_pv.o: in function `paddr_vmcoreinfo_note': mmu_pv.c:(.text+0x3af3): undefined reference to `vmcoreinfo_note' ====Link https://lore.kernel.org/all/SN6PR02MB4157931105FA68D72E3D3DB8D47B2@SN6PR02MB4157.namprd02.prod.outlook.com/T/#u open hereSigned-off-by Baoquan He <[email protected]>---
v1->v2:
- Add missing words and fix typos in patch log pointed out by Michael.arch/x86/kernel/cpu/mshyperv.c | 10 ++++++---- arch/x86/kernel/reboot.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/mmu_pv.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)arch/x86/kernel/cpu/mshyperv.c +2
-2@@ -209,6 +209,7 @@ static void hv_machine_shutdown(void)if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs)@@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)/* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup (); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static
uint32_t__initms_hyperv_platform(void)arch/x86/kernel/cpu/mshyperv.c +4
-2@@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif -#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) +#if IS_ENABLED (CONFIG_HYPERV ) +#if defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP ) machine_ops.crash_shutdown = hv_machine_crash_shutdown;#endif #endif arch/x86/kernel/reboot.c +1
-1@@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt (); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown (struct pt_regs *regs) { machine_ops.crash_shutdown (regs);arch/x86/xen/enlighten_hvm.c +1
-1@@ -148,6 +148,7 @@ static void xen_hvm_shutdown(void)if (kexec_in_progress) xen_reboot(SHUTDOWN_soft_reset); } +#endif #ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs)@@ -156,7 +157,6 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) xen_reboot(SHUTDOWN_soft_reset); }#endif -#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu){
arch/x86/xen/enlighten_hvm.c +1
-1@@ -238,10 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#endif #ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif -#endif }static __init int xen_parse_nopv (char *arg)arch/x86/xen/mmu_pv.c +1
-1@@ -2520,7 +2520,7 @@ int xen_remap_pfn(struct vm_area_struct *vma,unsigned long addr, }EXPORT_SYMBOL_GPL (xen_remap_pfn ); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_VMCORE_INFO phys_addr_t paddr_vmcoreinfo_note (void ) {
Quoted 3 lines
if (
xen_pv_domain())
--
2.41.0
This series resolves the build issues I was seeing. Please feel free to carry
forward if there are any more revisions without drastic changes.
Quoted 129 lines · Baoquan He
Michael pointed out that the #ifdef
CONFIG_CRASH_DUMPis nested insidearch/x86/xen/enlighten_hvm.c.Although the nesting works well too since
CONFIG_CRASH_DUMPhas dependency onCONFIG_KEXEC_CORE, it may cause confuse because there are places where it's not nested, and people may think it need be nested even though it doesn't have to.Fix that by moving
CONFIG_CRASH_DUMPifdeffery of codes out ofCONFIG_KEXEC_CODEifdeffery scope.And also fix a building error Nathan reported as below by replacing
CONFIG_KEXEC_COREifdef withCONFIG_VMCORE_INFOifdef.====
$ curl -LSso .config https://git.alpinelinux.org/aports/plain/community/linux-edge/config-edge.x86_64 $ make -skj"$(nproc)" ARCH=x86_64 CROSS_COMPILE=x86_64-linux- olddefconfig all ... x86_64-linux-ld: arch/x86/xen/mmu_pv.o: in function `paddr_vmcoreinfo_note': mmu_pv.c:(.text+0x3af3): undefined reference to `vmcoreinfo_note' ====Link https://lore.kernel.org/all/SN6PR02MB4157931105FA68D72E3D3DB8D47B2@SN6PR02MB4157.namprd02.prod.outlook.com/T/#u open hereSigned-off-by Baoquan He <[email protected]>--- arch/x86/kernel/cpu/mshyperv.c | 10 ++++++---- arch/x86/kernel/reboot.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/mmu_pv.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)arch/x86/kernel/cpu/mshyperv.c +6
-4@@ -209,6 +209,7 @@ static void hv_machine_shutdown(void)if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs)@@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)/* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup (); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static uint32_t __init ms_hyperv_platform (void )@@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif -#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) +#if IS_ENABLED (CONFIG_HYPERV ) +#if defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP ) machine_ops.crash_shutdown = hv_machine_crash_shutdown;#endif #endif arch/x86/kernel/reboot.c +1
-1@@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt (); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown (struct pt_regs *regs) { machine_ops.crash_shutdown (regs);arch/x86/xen/enlighten_hvm.c +2
-2@@ -148,6 +148,7 @@ static void xen_hvm_shutdown(void)if (kexec_in_progress) xen_reboot(SHUTDOWN_soft_reset); } +#endif #ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs)@@ -156,7 +157,6 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) xen_reboot(SHUTDOWN_soft_reset); }#endif -#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu) {@@ -238,10 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#endif #ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif -#endif }static __init int xen_parse_nopv (char *arg)arch/x86/xen/mmu_pv.c +1
-1@@ -2520,7 +2520,7 @@ int xen_remap_pfn(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL_GPL (xen_remap_pfn); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_VMCORE_INFO phys_addr_t paddr_vmcoreinfo_note (void ) {if (xen_pv_domain ())Signature · 1 line
2.41.0