Split crash out from kexec and clean up related config items
Subsystems (25)
v2 cover Split crash out from kexec and clean up related config items
Motivation:
=============
Previously, LKP reported a building error. When investigating, it can't be resolved reasonablly with the present messy kdump config items.
https://lore.kernel.org/oe-kbuild-all/[email protected]/
The kdump (crash dumping) related config items could causes confusions:
Firstly,
---CRASH_CORE enables codes including
- crashkernel reservation;
- elfcorehdr updating;
- vmcoreinfo exporting;
- crash hotplug handling;
Now fadump of powerpc, kcore dynamic debugging and kdump all selects CRASH_CORE, while fadump
- fadump needs crashkernel parsing, vmcoreinfo exporting, and accessing global variable 'elfcorehdr_addr';
- kcore only needs vmcoreinfo exporting;
- kdump needs all of the current kernel/crash_core.c.
So only enabling PROC_CORE or FA_DUMP will enable CRASH_CORE, this mislead people that we enable crash dumping, actual it's not.
Secondly,
---
It's not reasonable to allow KEXEC_CORE select CRASH_CORE.
Because KEXEC_CORE enables codes which allocate control pages, copy kexec/kdump segments, and prepare for switching. These codes are shared by both kexec reboot and kdump. We could want kexec reboot, but disable kdump. In that case, CRASH_CORE should not be selected.
--------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y
---------------------
Thirdly,
---
It's not reasonable to allow CRASH_DUMP select KEXEC_CORE.
That could make KEXEC_CORE, CRASH_DUMP are enabled independently from KEXEC or KEXEC_FILE. However, w/o KEXEC or KEXEC_FILE, the KEXEC_CORE code built in doesn't make any sense because no kernel loading or switching will happen to utilize the KEXEC_CORE code.
---------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
---------------------
In this case, what is worse, on arch sh and arm, KEXEC relies on MMU, while CRASH_DUMP can still be enabled when !MMU, then compiling error is seen as the lkp test robot reported in above link.
------arch/sh/Kconfig------
config ARCH_SUPPORTS_KEXEC
def_bool MMU
config ARCH_SUPPORTS_CRASH_DUMP
def_bool BROKEN_ON_SMP
---------------------------
Changes:
===========
1, split out crash_reserve.c from crash_core.c;
2, split out vmcore_infoc. from crash_core.c;
3, move crash related codes in kexec_core.c into crash_core.c; 4, remove dependency of FA_DUMP on CRASH_DUMP;
5, clean up kdump related config items;
6, wrap up crash codes in crash related ifdefs on all 9 arch-es
which support crash dumping;
Achievement:
===========
With above changes, I can rearrange the config item logic as below (the right item depends on or is selected by the left item):
PROC_KCORE -----------> VMCORE_INFO
|----------> VMCORE_INFO
FA_DUMP----|
|----------> CRASH_RESERVE
---->VMCORE_INFO
/
|---->CRASH_RESERVE
KEXEC --| /|
|--> KEXEC_CORE--> CRASH_DUMP-->/-|---->PROC_VMCORE
KEXEC_FILE --| \ |
\---->CRASH_HOTPLUG
KEXEC --|
|--> KEXEC_CORE (for kexec reboot only)
KEXEC_FILE --|Test
========
On all 8 architectures, including x86_64, arm64, s390x, sh, arm, mips, riscv, loongarch, I did below three cases of config item setting and building all passed. Let me take configs on x86_64 as exampmle here:
(1) Both CONFIG_KEXEC and KEXEC_FILE is unset, then all kexec/kdump items are unset automatically:
# Kexec and crash features
# CONFIG_KEXEC is not set
# CONFIG_KEXEC_FILE is not set
# end of Kexec and crash features
(2) set CONFIG_KEXEC_FILE and 'make olddefconfig':
---------------
# Kexec and crash features CONFIG_CRASH_RESERVE=y CONFIG_VMCORE_INFO=yCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=yCONFIG_CRASH_DUMP=yCONFIG_CRASH_HOTPLUG=y CONFIG_CRASH_MAX_MEMORY_RANGES=8192
# end of Kexec and crash features ---------------
(3) unset CONFIG_CRASH_DUMP in case 2 and execute 'make olddefconfig':
------------------------
# Kexec and crash featuresCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=y
# end of Kexec and crash features ------------------------
Note:
For ppc, it needs investigation to make clear how to split out crash code in arch folder. Hope Hari and Pingfan can help have a look, see if it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.
Baoquan He (14):
kexec: split crashkernel reservation code out from crash_core.c
crash: split vmcoreinfo exporting code out from crash_core.c
crash: remove dependency of FA_DUMP on CRASH_DUMP
crash: split crash dumping code out from kexec_core.c
crash: clean up kdump related config items
x86, crash: wrap crash dumping code into crash related ifdefs arm64, crash: wrap crash dumping code into crash related ifdefs ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP s390, crash: wrap crash dumping code into crash related ifdefs sh, crash: wrap crash dumping code into crash related ifdefs arm, crash: wrap crash dumping code into crash related ifdefs mips, crash: wrap crash dumping code into crash related ifdefs riscv, crash: wrap crash dumping code into crash related ifdefs loongarch, crash: wrap crash dumping code into crash related ifdefs
arch/arm/kernel/setup.c | 7 +-
arch/arm64/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 4 +-
arch/arm64/include/asm/kexec.h | 2 +-
arch/arm64/kernel/Makefile | 2 +-
arch/arm64/kernel/machine_kexec.c | 2 +-
arch/arm64/kernel/machine_kexec_file.c | 10 +-
.../kernel/{crash_core.c => vmcore_info.c} | 2 +-
arch/loongarch/kernel/setup.c | 7 +-
arch/mips/kernel/setup.c | 17 +-
arch/powerpc/Kconfig | 9 +-
arch/powerpc/kernel/setup-common.c | 2 +-
arch/powerpc/mm/nohash/kaslr_booke.c | 4 +-
arch/powerpc/platforms/powernv/opal-core.c | 2 +-
arch/riscv/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 4 +-
arch/riscv/kernel/Makefile | 2 +-
arch/riscv/kernel/elf_kexec.c | 9 +-
.../kernel/{crash_core.c => vmcore_info.c} | 2 +-
arch/riscv/mm/init.c | 2 +-
arch/s390/kernel/kexec_elf.c | 2 +
arch/s390/kernel/kexec_image.c | 2 +
arch/s390/kernel/machine_kexec_file.c | 10 +
arch/sh/kernel/machine_kexec.c | 3 +
arch/sh/kernel/setup.c | 2 +-
arch/x86/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 6 +-
arch/x86/kernel/Makefile | 6 +-
arch/x86/kernel/cpu/mshyperv.c | 4 +
arch/x86/kernel/kexec-bzimage64.c | 4 +
arch/x86/kernel/kvm.c | 4 +-
arch/x86/kernel/machine_kexec_64.c | 3 +
arch/x86/kernel/reboot.c | 2 +-
arch/x86/kernel/setup.c | 2 +-
arch/x86/kernel/smp.c | 2 +-
.../{crash_core_32.c => vmcore_info_32.c} | 2 +-
.../{crash_core_64.c => vmcore_info_64.c} | 2 +-
arch/x86/xen/enlighten_hvm.c | 4 +
drivers/base/cpu.c | 6 +-
drivers/firmware/qemu_fw_cfg.c | 14 +-
fs/proc/Kconfig | 2 +-
fs/proc/kcore.c | 2 +-
include/linux/buildid.h | 2 +-
include/linux/crash_core.h | 152 ++--
include/linux/crash_reserve.h | 48 ++
include/linux/kexec.h | 47 +-
include/linux/vmcore_info.h | 81 ++
init/initramfs.c | 2 +-
kernel/Kconfig.kexec | 12 +-
kernel/Makefile | 5 +-
kernel/crash_core.c | 764 +++++-------------
kernel/crash_reserve.c | 464 +++++++++++
kernel/{crash_dump.c => elfcorehdr.c} | 0
kernel/kexec.c | 11 +-
kernel/kexec_core.c | 250 +-----
kernel/kexec_file.c | 13 +-
kernel/kexec_internal.h | 2 +
kernel/ksysfs.c | 10 +-
kernel/printk/printk.c | 4 +-
kernel/vmcore_info.c | 233 ++++++
lib/buildid.c | 2 +-
61 files changed, 1233 insertions(+), 1048 deletions(-)
rename arch/arm64/include/asm/{crash_core.h => crash_reserve.h} (81%)
rename arch/arm64/kernel/{crash_core.c => vmcore_info.c} (97%)
rename arch/riscv/include/asm/{crash_core.h => crash_reserve.h} (78%)
rename arch/riscv/kernel/{crash_core.c => vmcore_info.c} (96%)
rename arch/x86/include/asm/{crash_core.h => crash_reserve.h} (92%)
rename arch/x86/kernel/{crash_core_32.c => vmcore_info_32.c} (90%)
rename arch/x86/kernel/{crash_core_64.c => vmcore_info_64.c} (94%)
create mode 100644 include/linux/crash_reserve.h
create mode 100644 include/linux/vmcore_info.h
create mode 100644 kernel/crash_reserve.c
rename kernel/{crash_dump.c => elfcorehdr.c} (100%)
create mode 100644 kernel/vmcore_info.cSignature · 1 line
2.41.0
PATCH v2 1/14 kexec: split crashkernel reservation code out from crash_core.c
Both kdump and fa_dump of ppc rely on crashkernel reservation. Move the relevant codes into separate files:crash_reserve.c, include/linux/crash_reserve.h.
And also add config item CRASH_RESERVE to control its enabling of the codes. And update config items which has relationship with crashkernel reservation.
And also change ifdeffery from CONFIG_CRASH_CORE to CONFIG_CRASH_RESERVE when those scopes are only crashkernel reservation related.
And also rename arch/XXX/include/asm/{crash_core.h => crash_reserve.h} on arm64, x86 and risc-v because those architectures' crash_core.h is only related to crashkernel reservation.
---
arch/arm64/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 4 +-
arch/powerpc/Kconfig | 1 +
arch/powerpc/mm/nohash/kaslr_booke.c | 4 +-
arch/riscv/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 4 +-
arch/x86/Kconfig | 2 +-
.../asm/{crash_core.h => crash_reserve.h} | 6 +-
include/linux/crash_core.h | 40 --
include/linux/crash_reserve.h | 48 ++
include/linux/kexec.h | 1 +
kernel/Kconfig.kexec | 5 +-
kernel/Makefile | 1 +
kernel/crash_core.c | 438 -----------------
kernel/crash_reserve.c | 464 ++++++++++++++++++
15 files changed, 531 insertions(+), 491 deletions(-)
rename arch/arm64/include/asm/{crash_core.h => crash_reserve.h} (81%)
rename arch/riscv/include/asm/{crash_core.h => crash_reserve.h} (78%)
rename arch/x86/include/asm/{crash_core.h => crash_reserve.h} (92%)
create mode 100644 include/linux/crash_reserve.h
create mode 100644 kernel/crash_reserve.carch/arm64/Kconfig +1 -1
@@ -1501,7 +1501,7 @@ config ARCH_SUPPORTS_CRASH_DUMP def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESERVE config TRANS_TABLE def_bool y
arch/arm64/include/asm/crash_reserve.h renamed from arch/arm64/include/asm/crash_core.h +2 -2
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _ARM64_CRASH_CORE_H -#define _ARM64_CRASH_CORE_H +#ifndef _ARM64_CRASH_RESERVE_H +#define _ARM64_CRASH_RESERVE_H/* Current arm64 boot protocol requires 2MB alignment */ #define CRASH_ALIGN SZ_2M
arch/powerpc/Kconfig +1 -0
@@ -691,6 +691,7 @@ config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) select CRASH_CORE + select CRASH_RESERVE select CRASH_DUMP help A robust mechanism to get reliable kernel crash dump with
arch/powerpc/mm/nohash/kaslr_booke.c +2 -2
@@ -13,7 +13,7 @@#include <linux/delay.h> #include <linux/memblock.h> #include <linux/libfdt.h> -#include <linux/crash_core.h> +#include <linux/crash_reserve.h> #include <linux/of.h> #include <linux/of_fdt.h> #include <asm/cacheflush.h>
@@ -173,7 +173,7 @@ static __init bool overlaps_region(const void *fdt, u32 start,static void __init get_crash_kernel (void *fdt,unsigned long size) { -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_CRASH_RESERVE unsigned long long crash_size, crash_base;int ret;
arch/riscv/Kconfig +1 -1
@@ -712,7 +712,7 @@ config ARCH_SUPPORTS_CRASH_DUMP def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESERVE config COMPAT bool "Kernel support for 32-bit U-mode"
arch/riscv/include/asm/crash_reserve.h renamed from arch/riscv/include/asm/crash_core.h +2 -2
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _RISCV_CRASH_CORE_H -#define _RISCV_CRASH_CORE_H +#ifndef _RISCV_CRASH_RESERVE_H +#define _RISCV_CRASH_RESERVE_H#define CRASH_ALIGN PMD_SIZE
arch/x86/Kconfig +1 -1
@@ -2106,7 +2106,7 @@ config ARCH_SUPPORTS_CRASH_HOTPLUG def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESEERVE config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
arch/x86/include/asm/crash_reserve.h renamed from arch/x86/include/asm/crash_core.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _X86_CRASH_CORE_H -#define _X86_CRASH_CORE_H +#ifndef _X86_CRASH_RESERVE_H +#define _X86_CRASH_RESERVE_H/* 16M alignment for crash kernel regions */ #define CRASH_ALIGN SZ_16M
@@ -39,4 +39,4 @@ static inline unsigned long crash_low_size_default(void) #endif } -#endif /* _X86_CRASH_CORE_H */ +#endif /* _X86_CRASH_RESERVE_H */
include/linux/crash_core.h +0 -40
@@ -5,14 +5,6 @@#include <linux/linkage.h> #include <linux/elfcore.h> #include <linux/elf.h> -#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION -#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)
@@ -87,38 +79,6 @@ Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len);void final_note (Elf_Word *buf); -int __init parse_crashkernel (char *cmdline,unsigned long long system_ram, -unsigned long long *crash_size,unsigned long long *crash_base, -unsigned long long *low_size,bool *high); - -#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION -#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE -#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) -#endif -#ifndef CRASH_ALIGN -#define CRASH_ALIGN SZ_2M -#endif -#ifndef CRASH_ADDR_LOW_MAX -#define CRASH_ADDR_LOW_MAX SZ_4G -#endif -#ifndef CRASH_ADDR_HIGH_MAX -#define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM() -#endif - -void __init reserve_crashkernel_generic (char *cmdline, -unsigned long long crash_size, -unsigned long long crash_base, -unsigned long long crash_low_size, -bool high); -#else -static inline void __init reserve_crashkernel_generic (char *cmdline, -unsigned long long crash_size, -unsigned long long crash_base, -unsigned long long crash_low_size, -bool high) -{} -#endif -/* Alignment required for elf header segment */ #define ELF_CORE_HEADER_ALIGN 4096
include/linux/crash_reserve.h new file +48 -0
48 lines not on this page · raw message
include/linux/kexec.h +1 -0
@@ -16,6 +16,7 @@#if !defined(__ASSEMBLY__)#include <linux/crash_core.h> +#include <linux/crash_reserve.h> #include <asm/io.h> #include <linux/range.h>
kernel/Kconfig.kexec +4 -1
@@ -2,11 +2,15 @@ menu "Kexec and crash features" +config CRASH_RESERVE + bool + config CRASH_CORE bool config KEXEC_CORE select CRASH_CORE + select CRASH_RESERVE bool config KEXEC_ELF
@@ -96,7 +100,6 @@ config KEXEC_JUMP config CRASH_DUMP bool "kernel crash dumps" depends on ARCH_SUPPORTS_CRASH_DUMP - select CRASH_CORE select KEXEC_CORE help Generate crash dump after being started by kexec.
kernel/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o obj-$(CONFIG_KEXEC_CORE) += kexec_core.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
kernel/crash_core.c +0 -438
444 lines not on this page · raw message
kernel/crash_reserve.c new file +464 -0
464 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v2 01/14] kexec: split crashkernel reservation code out from crash_core.c
Hello Baoquan,
Thank you for reorganizing the kexec and kdump code with a well-defined configuration structure.
While reviewing the patch series, I noticed a few typos.
Quoted 136 lines · Baoquan He
Both kdump and
fa_dumpof ppc rely on crashkernel reservation. Move the relevant codes into separate files:crash_reserve.c,include/linux/crash_reserve.h.And also add config item
CRASH_RESERVEto control its enabling of the codes. And update config items which has relationship with crashkernel reservation.And also change ifdeffery from
CONFIG_CRASH_COREtoCONFIG_CRASH_RESERVEwhen those scopes are only crashkernel reservation related.And also rename
arch/XXX/include/asm/{crash_core.h=>crash_reserve.h} on arm64, x86 and risc-v because those architectures'crash_core.his only related to crashkernel reservation.Signed-off-by Baoquan He <[email protected]>--- arch/arm64/Kconfig | 2 +- .../asm/{crash_core.h => crash_reserve.h} | 4 +- arch/powerpc/Kconfig | 1 + arch/powerpc/mm/nohash/kaslr_booke.c | 4 +- arch/riscv/Kconfig | 2 +- .../asm/{crash_core.h => crash_reserve.h} | 4 +- arch/x86/Kconfig | 2 +- .../asm/{crash_core.h => crash_reserve.h} | 6 +- include/linux/crash_core.h | 40 -- include/linux/crash_reserve.h | 48 ++ include/linux/kexec.h | 1 + kernel/Kconfig.kexec | 5 +- kernel/Makefile | 1 + kernel/crash_core.c | 438 ----------------- kernel/crash_reserve.c | 464 ++++++++++++++++++ 15 files changed, 531 insertions(+), 491 deletions(-)rename
arch/arm64/include/asm/{crash_core.h=>crash_reserve.h} (81%) renamearch/riscv/include/asm/{crash_core.h=>crash_reserve.h} (78%) renamearch/x86/include/asm/{crash_core.h=>crash_reserve.h} (92%) create mode 100644include/linux/crash_reserve.h
create mode 100644kernel/crash_reserve.carch/arm64/Kconfig +1
-1@@ -1501,7 +1501,7 @@ config ARCH_SUPPORTS_CRASH_DUMP def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESERVE config TRANS_TABLE def_bool yarch/arm64/include/asm/crash_reserve.h renamed from arch/arm64/include/asm/crash_core.h +2
-2@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _ARM64_CRASH_CORE_H -#define _ARM64_CRASH_CORE_H +#ifndef _ARM64_CRASH_RESERVE_H +#define _ARM64_CRASH_RESERVE_H/* Current arm64 boot protocol requires 2MB alignment */ #define CRASH_ALIGN SZ_2March/powerpc/Kconfig +1
-0@@ -691,6 +691,7 @@ config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) select CRASH_CORE + select CRASH_RESERVE select CRASH_DUMP help A robust mechanism to get reliable kernel crash dump witharch/powerpc/mm/nohash/kaslr_booke.c +2
-2@@ -13,7 +13,7 @@#include <linux/delay.h> #include <linux/memblock.h> #include <linux/libfdt.h> -#include <linux/crash_core.h> +#include <linux/crash_reserve.h> #include <linux/of.h> #include <linux/of_fdt.h> #include <asm/cacheflush.h> @@ -173,7 +173,7 @@ static __init bool overlaps_region(const void *fdt, u32 start,static void __init get_crash_kernel (void *fdt,unsigned long size) { -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_CRASH_RESERVE unsigned long long crash_size, crash_base;int ret;arch/riscv/Kconfig +1
-1@@ -712,7 +712,7 @@ config ARCH_SUPPORTS_CRASH_DUMP def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESERVE config COMPAT bool "Kernel support for 32-bit U-mode"arch/riscv/include/asm/crash_reserve.h renamed from arch/riscv/include/asm/crash_core.h +2
-2@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _RISCV_CRASH_CORE_H -#define _RISCV_CRASH_CORE_H +#ifndef _RISCV_CRASH_RESERVE_H +#define _RISCV_CRASH_RESERVE_H#define CRASH_ALIGN PMD_SIZEarch/x86/Kconfig +0
-0
arch/x86/Kconfig config ARCH_SUPPORTS_CRASH_HOTPLUG · line 2109
Quoted 5 lines
arch/x86/Kconfig +1
-1@@ -2106,7 +2106,7 @@ config ARCH_SUPPORTS_CRASH_HOTPLUG def_bool y config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION - def_bool CRASH_CORE + def_bool CRASH_RESEERVE
%s/CRASH_RESEERVE/CRASH_RESERVE? - Sourabh
Andrew Morton
maintainerRe: [PATCH v2 01/14] kexec: split crashkernel reservation code out from crash_core.c
Quoted 5 lines · On Wed, 21 Feb 2024 22:59:47 +0530 Sourabh Jain <[email protected]>…
arch/x86/Kconfig config ARCH_SUPPORTS_CRASH_HOTPLUG · line 2109
Quoted 3 lines
config
ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATIONarch/x86/Kconfig +1
-1- def_bool CRASH_CORE + def_bool CRASH_RESEERVE%s/CRASH_RESEERVE/CRASH_RESERVE?
Yes, thanks, this has been addressed in a followon fixup patch in the mm.git tree.
PATCH v2 2/14 crash: split vmcoreinfo exporting code out from crash_core.c
In reply to Baoquan HeNow move the relevant codes into separate files:kernel/crash_reserve.c, include/linux/crash_reserve.h.
And add config item CRASH_RESERVE to control its enabling.
And also update the old ifdeffery of CONFIG_CRASH_CORE, including of <linux/crash_core.h> and config item dependency on CRASH_CORE accordingly.
And also do renaming as follows:
- arch/xxx/kernel/{crash_core.c => vmcore_info.c}
because they are only related to vmcoreinfo exporting on x86, arm64, riscv.
And also Remove config item CRASH_CORE, and rely on CONFIG_KEXEC_CORE to decide if build in crash_core.c.
---
arch/arm64/kernel/Makefile | 2 +-
.../kernel/{crash_core.c => vmcore_info.c} | 2 +-
arch/powerpc/Kconfig | 2 +-
arch/powerpc/kernel/setup-common.c | 2 +-
arch/powerpc/platforms/powernv/opal-core.c | 2 +-
arch/riscv/kernel/Makefile | 2 +-
.../kernel/{crash_core.c => vmcore_info.c} | 2 +-
arch/x86/kernel/Makefile | 2 +-
.../{crash_core_32.c => vmcore_info_32.c} | 2 +-
.../{crash_core_64.c => vmcore_info_64.c} | 2 +-
drivers/firmware/qemu_fw_cfg.c | 14 +-
fs/proc/Kconfig | 2 +-
fs/proc/kcore.c | 2 +-
include/linux/buildid.h | 2 +-
include/linux/crash_core.h | 73 ------
include/linux/kexec.h | 1 +
include/linux/vmcore_info.h | 81 ++++++
kernel/Kconfig.kexec | 4 +-
kernel/Makefile | 4 +-
kernel/crash_core.c | 208 ----------------
kernel/ksysfs.c | 6 +-
kernel/printk/printk.c | 4 +-
kernel/vmcore_info.c | 233 ++++++++++++++++++
lib/buildid.c | 2 +-
24 files changed, 345 insertions(+), 311 deletions(-)
rename arch/arm64/kernel/{crash_core.c => vmcore_info.c} (97%)
rename arch/riscv/kernel/{crash_core.c => vmcore_info.c} (96%)
rename arch/x86/kernel/{crash_core_32.c => vmcore_info_32.c} (90%)
rename arch/x86/kernel/{crash_core_64.c => vmcore_info_64.c} (94%)
create mode 100644 include/linux/vmcore_info.h
create mode 100644 kernel/vmcore_info.carch/arm64/kernel/Makefile +1 -1
@@ -66,7 +66,7 @@ obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o obj-$(CONFIG_ARM64_PTR_AUTH) += pointer_auth.o obj-$(CONFIG_ARM64_MTE) += mte.o
arch/arm64/kernel/vmcore_info.c renamed from arch/arm64/kernel/crash_core.c +1 -1
@@ -4,7 +4,7 @@* Copyright (C) Huawei Futurewei Technologies. */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <asm/cpufeature.h> #include <asm/memory.h> #include <asm/pgtable-hwdef.h>
arch/powerpc/Kconfig +1 -1
@@ -690,7 +690,7 @@ config ARCH_SELECTS_CRASH_DUMP config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE select CRASH_DUMP help
arch/powerpc/kernel/setup-common.c +1 -1
@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;EXPORT_SYMBOL (ppc_do_canonicalize_irqs);#endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* This keeps a track of which one is the crashing cpu. */ int crashing_cpu =-1 ;#endif
arch/powerpc/platforms/powernv/opal-core.c +1 -1
@@ -16,7 +16,7 @@#include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/slab.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/of.h> #include <asm/page.h>
arch/riscv/kernel/Makefile +1 -1
@@ -91,7 +91,7 @@ obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o
arch/riscv/kernel/vmcore_info.c renamed from arch/riscv/kernel/crash_core.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pagemap.h> void arch_crash_save_vmcoreinfo (void )
arch/x86/kernel/Makefile +1 -1
@@ -98,7 +98,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o obj-$(CONFIG_X86_TSC) += trace_clock.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_RETHOOK) += rethook.o -obj-$(CONFIG_CRASH_CORE) += crash_core_$(BITS).o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += machine_kexec_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o crash.o obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.o
arch/x86/kernel/vmcore_info_32.c renamed from arch/x86/kernel/crash_core_32.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h>
arch/x86/kernel/vmcore_info_64.c renamed from arch/x86/kernel/crash_core_64.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h>
drivers/firmware/qemu_fw_cfg.c +7 -7
@@ -37,7 +37,7 @@#include <uapi/linux/qemu_fw_cfg.h> #include <linux/delay.h> #include <linux/crash_dump.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> MODULE_AUTHOR ("Gabriel L. Somlo <[email protected]>" );MODULE_DESCRIPTION ("QEMU fw_cfg sysfs support" );
@@ -67,7 +67,7 @@ static void fw_cfg_sel_endianness(u16 key)iowrite16 (key, fw_cfg_reg_ctrl); } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static inline bool fw_cfg_dma_enabled (void ) {return (fw_cfg_rev &FW_CFG_VERSION_DMA ) && fw_cfg_reg_dma;
@@ -156,7 +156,7 @@ static ssize_t fw_cfg_read_blob(u16 key,return count; } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */ static ssize_t fw_cfg_write_blob (u16 key,void *buf,loff_t pos,size_t count)
@@ -195,7 +195,7 @@ static ssize_t fw_cfg_write_blob(u16 key, return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* clean up fw_cfg device i/o */ static void fw_cfg_io_cleanup (void )
@@ -319,7 +319,7 @@ struct fw_cfg_sysfs_entry {struct list_head list; }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t fw_cfg_write_vmcoreinfo (const struct fw_cfg_file *f) {static struct fw_cfg_vmcoreinfo *data;
@@ -343,7 +343,7 @@ static ssize_t fw_cfg_write_vmcoreinfo(const struct fw_cfg_file *f)kfree (data); return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* get fw_cfg_sysfs_entry from kobject member */ static inline struct fw_cfg_sysfs_entry *to_entry (struct kobject *kobj)
@@ -583,7 +583,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)int err;struct fw_cfg_sysfs_entry *entry; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO if (fw_cfg_dma_enabled () &&strcmp (f->name,FW_CFG_VMCOREINFO_FILENAME ) ==0 && !is_kdump_kernel ()) {
fs/proc/Kconfig +1 -1
@@ -32,7 +32,7 @@ config PROC_FS config PROC_KCORE bool "/proc/kcore support" if !ARM depends on PROC_FS && MMU - select CRASH_CORE + select VMCORE_INFO help Provides a virtual ELF core file of the live kernel. This can be read with gdb and other ELF tools. No modifications can be
fs/proc/kcore.c +1 -1
@@ -10,7 +10,7 @@* Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <[email protected]> */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/mm.h> #include <linux/proc_fs.h> #include <linux/kcore.h>
include/linux/buildid.h +1 -1
@@ -11,7 +11,7 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id, __u32 *size);int build_id_parse_buf (const void *buf,unsigned char *build_id,u32 buf_size); -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ];void init_vmlinux_build_id (void );#else
include/linux/crash_core.h +0 -73
79 lines not on this page · raw message
include/linux/kexec.h +1 -0
@@ -16,6 +16,7 @@#if !defined(__ASSEMBLY__)#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/crash_reserve.h> #include <asm/io.h> #include <linux/range.h>
include/linux/vmcore_info.h new file +81 -0
81 lines not on this page · raw message
kernel/Kconfig.kexec +2 -2
@@ -5,11 +5,11 @@ menu "Kexec and crash features" config CRASH_RESERVE bool -config CRASH_CORE +config VMCORE_INFO bool config KEXEC_CORE - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE bool
kernel/Makefile +2 -2
@@ -68,9 +68,9 @@ obj-$(CONFIG_MODULE_SIG_FORMAT) += module_signature.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o -obj-$(CONFIG_KEXEC_CORE) += kexec_core.o +obj-$(CONFIG_KEXEC_CORE) += kexec_core.o crash_core.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC_FILE) += kexec_file.o obj-$(CONFIG_KEXEC_ELF) += kexec_elf.o
kernel/crash_core.c +0 -208
220 lines not on this page · raw message
kernel/ksysfs.c +3 -3
@@ -154,7 +154,7 @@ KERNEL_ATTR_RW(kexec_crash_size);#endif /* CONFIG_KEXEC_CORE */ -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t vmcoreinfo_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf)
@@ -177,7 +177,7 @@ KERNEL_ATTR_RO(crash_elfcorehdr_size);#endif -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* whether file capabilities are enabled */ static ssize_t fscaps_show(struct kobject *kobj,
@@ -265,7 +265,7 @@ static struct attribute * kernel_attrs[] = { &kexec_crash_loaded_attr.attr, &kexec_crash_size_attr.attr, #endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO &vmcoreinfo_attr.attr, #ifdef CONFIG_CRASH_HOTPLUG &crash_elfcorehdr_size_attr.attr,
kernel/printk/printk.c +2 -2
@@ -34,7 +34,7 @@#include <linux/security.h> #include <linux/memblock.h> #include <linux/syscalls.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/ratelimit.h> #include <linux/kmsg_dump.h> #include <linux/syslog.h>
@@ -951,7 +951,7 @@ const struct file_operations kmsg_fops = { .release = devkmsg_release, }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* * This appends the listed symbols to /proc/vmcore *
kernel/vmcore_info.c new file +233 -0
233 lines not on this page · raw message
lib/buildid.c +1 -1
@@ -174,7 +174,7 @@ int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size)return parse_build_id_buf (build_id,NULL , buf, buf_size); } -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ]__ro_after_init ;/**
Signature · 1 line
2.41.0
Re: [PATCH v2 02/14] crash: split vmcoreinfo exporting code out from crash_core.c
Hello Baoquan,
Quoted 4 lines · Baoquan He
Now move the relevant codes into separate files:
kernel/crash_reserve.c,include/linux/crash_reserve.h.And add config item
CRASH_RESERVEto control its enabling.
Feels like this patch is more about vmcore_info.[c|h] and CONFIG_VMCORE_INFO then the above mentioned files and config.
- Sourabh
Quoted 1,040 lines
And also update the old ifdeffery of
CONFIG_CRASH_CORE, including of <linux/crash_core.h> and config item dependency onCRASH_COREaccordingly.And also do renaming as follows:
-arch/xxx/kernel/{crash_core.c=>vmcore_info.c}
because they are only related to vmcoreinfo exporting on x86, arm64, riscv.And also Remove config item
CRASH_CORE, and rely onCONFIG_KEXEC_COREto decide if build incrash_core.c.Signed-off-by Baoquan He <[email protected]>--- arch/arm64/kernel/Makefile | 2 +- .../kernel/{crash_core.c => vmcore_info.c} | 2 +- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/setup-common.c | 2 +- arch/powerpc/platforms/powernv/opal-core.c | 2 +- arch/riscv/kernel/Makefile | 2 +- .../kernel/{crash_core.c => vmcore_info.c} | 2 +- arch/x86/kernel/Makefile | 2 +- .../{crash_core_32.c => vmcore_info_32.c} | 2 +- .../{crash_core_64.c => vmcore_info_64.c} | 2 +- drivers/firmware/qemu_fw_cfg.c | 14 +- fs/proc/Kconfig | 2 +- fs/proc/kcore.c | 2 +- include/linux/buildid.h | 2 +- include/linux/crash_core.h | 73 ------ include/linux/kexec.h | 1 + include/linux/vmcore_info.h | 81 ++++++ kernel/Kconfig.kexec | 4 +- kernel/Makefile | 4 +- kernel/crash_core.c | 208 ---------------- kernel/ksysfs.c | 6 +- kernel/printk/printk.c | 4 +- kernel/vmcore_info.c | 233 ++++++++++++++++++ lib/buildid.c | 2 +- 24 files changed, 345 insertions(+), 311 deletions(-)rename
arch/arm64/kernel/{crash_core.c=>vmcore_info.c} (97%) renamearch/riscv/kernel/{crash_core.c=>vmcore_info.c} (96%) renamearch/x86/kernel/{crash_core_32.c=>vmcore_info_32.c} (90%) renamearch/x86/kernel/{crash_core_64.c=>vmcore_info_64.c} (94%) create mode 100644include/linux/vmcore_info.h
create mode 100644kernel/vmcore_info.carch/arm64/kernel/Makefile +1
-1@@ -66,7 +66,7 @@ obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o obj-$(CONFIG_ARM64_PTR_AUTH) += pointer_auth.o obj-$(CONFIG_ARM64_MTE) += mte.oarch/arm64/kernel/vmcore_info.c renamed from arch/arm64/kernel/crash_core.c +1
-1@@ -4,7 +4,7 @@* Copyright (C) Huawei Futurewei Technologies. */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <asm/cpufeature.h> #include <asm/memory.h> #include <asm/pgtable-hwdef.h> arch/powerpc/Kconfig +1
-1@@ -690,7 +690,7 @@ config ARCH_SELECTS_CRASH_DUMP config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE select CRASH_DUMP helparch/powerpc/kernel/setup-common.c +1
-1@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;EXPORT_SYMBOL (ppc_do_canonicalize_irqs);#endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* This keeps a track of which one is the crashing cpu. */ int crashing_cpu =-1 ;#endif arch/powerpc/platforms/powernv/opal-core.c +1
-1@@ -16,7 +16,7 @@#include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/slab.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/of.h> #include <asm/page.h> arch/riscv/kernel/Makefile +1
-1@@ -91,7 +91,7 @@ obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_JUMP_LABEL) += jump_label.oarch/riscv/kernel/vmcore_info.c renamed from arch/riscv/kernel/crash_core.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pagemap.h> void arch_crash_save_vmcoreinfo (void )arch/x86/kernel/Makefile +1
-1@@ -98,7 +98,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o obj-$(CONFIG_X86_TSC) += trace_clock.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_RETHOOK) += rethook.o -obj-$(CONFIG_CRASH_CORE) += crash_core_$(BITS).o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += machine_kexec_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o crash.o obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.oarch/x86/kernel/vmcore_info_32.c renamed from arch/x86/kernel/crash_core_32.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h> arch/x86/kernel/vmcore_info_64.c renamed from arch/x86/kernel/crash_core_64.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h> drivers/firmware/qemu_fw_cfg.c +7
-7@@ -37,7 +37,7 @@#include <uapi/linux/qemu_fw_cfg.h> #include <linux/delay.h> #include <linux/crash_dump.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> MODULE_AUTHOR ("Gabriel L. Somlo <[email protected]>" );MODULE_DESCRIPTION ("QEMU fw_cfg sysfs support" );@@ -67,7 +67,7 @@ static void fw_cfg_sel_endianness(u16 key)iowrite16 (key, fw_cfg_reg_ctrl); } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static inline bool fw_cfg_dma_enabled (void ) {return (fw_cfg_rev &FW_CFG_VERSION_DMA ) && fw_cfg_reg_dma;@@ -156,7 +156,7 @@ static ssize_t fw_cfg_read_blob(u16 key,return count; } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */ static ssize_t fw_cfg_write_blob (u16 key,void *buf,loff_t pos,size_t count)@@ -195,7 +195,7 @@ static ssize_t fw_cfg_write_blob(u16 key, return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* clean up fw_cfg device i/o */ static void fw_cfg_io_cleanup (void )@@ -319,7 +319,7 @@ struct fw_cfg_sysfs_entry {struct list_head list; }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t fw_cfg_write_vmcoreinfo (const struct fw_cfg_file *f) {static struct fw_cfg_vmcoreinfo *data;@@ -343,7 +343,7 @@ static ssize_t fw_cfg_write_vmcoreinfo(const struct fw_cfg_file *f)kfree (data); return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* get fw_cfg_sysfs_entry from kobject member */ static inline struct fw_cfg_sysfs_entry *to_entry (struct kobject *kobj)@@ -583,7 +583,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)int err;struct fw_cfg_sysfs_entry *entry; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO if (fw_cfg_dma_enabled () &&strcmp (f->name,FW_CFG_VMCOREINFO_FILENAME ) ==0 && !is_kdump_kernel ()) {fs/proc/Kconfig +1
-1@@ -32,7 +32,7 @@ config PROC_FS config PROC_KCORE bool "/proc/kcore support" if !ARM depends on PROC_FS && MMU - select CRASH_CORE + select VMCORE_INFO help Provides a virtual ELF core file of the live kernel. This can be read with gdb and other ELF tools. No modifications can befs/proc/kcore.c +1
-1@@ -10,7 +10,7 @@* Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <[email protected]> */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/mm.h> #include <linux/proc_fs.h> #include <linux/kcore.h> include/linux/buildid.h +1
-1@@ -11,7 +11,7 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id, __u32 *size);int build_id_parse_buf (const void *buf,unsigned char *build_id,u32 buf_size); -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ];void init_vmlinux_build_id (void );#else include/linux/crash_core.h +0
-73@@ -6,79 +6,6 @@#include <linux/elfcore.h> #include <linux/elf.h> -#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) -#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) - -/* -* The per-cpu notes area is a list of notes terminated by a "NULL" -* note header. For kdump, the code in vmcore.c runs in the context -* of the second kernel to combine them into one note. -*/ -#define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ - CRASH_CORE_NOTE_NAME_BYTES + \ - CRASH_CORE_NOTE_DESC_BYTES) - -#define VMCOREINFO_BYTES PAGE_SIZE -#define VMCOREINFO_NOTE_NAME "VMCOREINFO" -#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) -#define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ - VMCOREINFO_NOTE_NAME_BYTES + \ - VMCOREINFO_BYTES) - -typedef u32 note_buf_t [CRASH_CORE_NOTE_BYTES /4 ]; -/* Per cpu memory for storing cpu states in case of system crash. */ -extern note_buf_t __percpu *crash_notes; - -void crash_update_vmcoreinfo_safecopy (void *ptr); -void crash_save_vmcoreinfo (void ); -void arch_crash_save_vmcoreinfo (void ); -__printf(1, 2) -void vmcoreinfo_append_str (const char *fmt, ...); -phys_addr_t paddr_vmcoreinfo_note (void ); - -#define VMCOREINFO_OSRELEASE (value) \ - vmcoreinfo_append_str("OSRELEASE=%s\n", value) -#define VMCOREINFO_BUILD_ID () \ - ({ \ - static_assert(sizeof(vmlinux_build_id) == 20); \ - vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \ - }) - -#define VMCOREINFO_PAGESIZE (value) \ - vmcoreinfo_append_str("PAGESIZE=%ld\n", value) -#define VMCOREINFO_SYMBOL (name) \ - vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) -#define VMCOREINFO_SYMBOL_ARRAY (name) \ - vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name) -#define VMCOREINFO_SIZE (name) \ - vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ - (unsigned long)sizeof(name)) -#define VMCOREINFO_STRUCT_SIZE (name) \ - vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ - (unsigned long)sizeof(struct name)) -#define VMCOREINFO_OFFSET (name, field) \ - vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ - (unsigned long)offsetof(struct name, field)) -#define VMCOREINFO_TYPE_OFFSET (name, field) \ - vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ - (unsigned long)offsetof(name, field)) -#define VMCOREINFO_LENGTH (name, value) \ - vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value) -#define VMCOREINFO_NUMBER (name) \ - vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name) -#define VMCOREINFO_CONFIG (name) \ - vmcoreinfo_append_str("CONFIG_%s=y\n", #name) - -extern unsigned char *vmcoreinfo_data; -extern size_t vmcoreinfo_size; -extern u32 *vmcoreinfo_note; - -Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, -void *data,size_t data_len); -void final_note (Elf_Word *buf); -/* Alignment required for elf header segment */ #define ELF_CORE_HEADER_ALIGN 4096include/linux/kexec.h +1
-0@@ -16,6 +16,7 @@#if !defined(__ASSEMBLY__)#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/crash_reserve.h> #include <asm/io.h> #include <linux/range.h> include/linux/vmcore_info.h new file +81
-0@@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LINUX_VMCORE_INFO_H +#define LINUX_VMCORE_INFO_H + +#include <linux/linkage.h> +#include <linux/elfcore.h> +#include <linux/elf.h> + +#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) +#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) + +/* +* The per-cpu notes area is a list of notes terminated by a "NULL" +* note header. For kdump, the code in vmcore.c runs in the context +* of the second kernel to combine them into one note. +*/ +#define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ + CRASH_CORE_NOTE_NAME_BYTES + \ + CRASH_CORE_NOTE_DESC_BYTES) + +#define VMCOREINFO_BYTES PAGE_SIZE +#define VMCOREINFO_NOTE_NAME "VMCOREINFO" +#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) +#define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ + VMCOREINFO_NOTE_NAME_BYTES + \ + VMCOREINFO_BYTES) + +typedef u32 note_buf_t [CRASH_CORE_NOTE_BYTES /4 ]; +/* Per cpu memory for storing cpu states in case of system crash. */ +extern note_buf_t __percpu *crash_notes; + +void crash_update_vmcoreinfo_safecopy (void *ptr); +void crash_save_vmcoreinfo (void ); +void arch_crash_save_vmcoreinfo (void ); +__printf(1, 2) +void vmcoreinfo_append_str (const char *fmt, ...); +phys_addr_t paddr_vmcoreinfo_note (void ); + +#define VMCOREINFO_OSRELEASE (value) \ + vmcoreinfo_append_str("OSRELEASE=%s\n", value) +#define VMCOREINFO_BUILD_ID () \ + ({ \ + static_assert(sizeof(vmlinux_build_id) == 20); \ + vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \ + }) + +#define VMCOREINFO_PAGESIZE (value) \ + vmcoreinfo_append_str("PAGESIZE=%ld\n", value) +#define VMCOREINFO_SYMBOL (name) \ + vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) +#define VMCOREINFO_SYMBOL_ARRAY (name) \ + vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name) +#define VMCOREINFO_SIZE (name) \ + vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ + (unsigned long)sizeof(name)) +#define VMCOREINFO_STRUCT_SIZE (name) \ + vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ + (unsigned long)sizeof(struct name)) +#define VMCOREINFO_OFFSET (name, field) \ + vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ + (unsigned long)offsetof(struct name, field)) +#define VMCOREINFO_TYPE_OFFSET (name, field) \ + vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ + (unsigned long)offsetof(name, field)) +#define VMCOREINFO_LENGTH (name, value) \ + vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value) +#define VMCOREINFO_NUMBER (name) \ + vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name) +#define VMCOREINFO_CONFIG (name) \ + vmcoreinfo_append_str("CONFIG_%s=y\n", #name) + +extern unsigned char *vmcoreinfo_data; +extern size_t vmcoreinfo_size; +extern u32 *vmcoreinfo_note; + +Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, +void *data,size_t data_len); +void final_note (Elf_Word *buf); +#endif /* LINUX_VMCORE_INFO_H */ kernel/Kconfig.kexec +2
-2@@ -5,11 +5,11 @@ menu "Kexec and crash features" config CRASH_RESERVE bool -config CRASH_CORE +config VMCORE_INFO bool config KEXEC_CORE - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE boolkernel/Makefile +2
-2@@ -68,9 +68,9 @@ obj-$(CONFIG_MODULE_SIG_FORMAT) += module_signature.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o -obj-$(CONFIG_KEXEC_CORE) += kexec_core.o +obj-$(CONFIG_KEXEC_CORE) += kexec_core.o crash_core.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC_FILE) += kexec_file.o obj-$(CONFIG_KEXEC_ELF) += kexec_elf.okernel/crash_core.c +0
-208@@ -26,14 +26,6 @@/* Per cpu memory for storing cpu states in case of system crash. */ note_buf_t __percpu *crash_notes; -/* vmcoreinfo stuff */ -unsigned char *vmcoreinfo_data; -size_t vmcoreinfo_size; -u32 *vmcoreinfo_note; - -/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ -static unsigned char *vmcoreinfo_data_safecopy; -int crash_prepare_elf64_headers (struct crash_mem *mem,int need_kernel_map,void **addr,unsigned long *sz) {@@ -195,206 +187,6 @@ int crash_exclude_mem_range(struct crash_mem *mem,return 0 ; } -Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, -void *data,size_t data_len) -{ -struct elf_note *note = (struct elf_note *)buf; - - note->n_namesz =strlen (name) +1 ; - note->n_descsz = data_len; - note->n_type = type; - buf +=DIV_ROUND_UP (sizeof (*note),sizeof (Elf_Word)); -memcpy (buf, name, note->n_namesz); - buf +=DIV_ROUND_UP (note->n_namesz,sizeof (Elf_Word)); -memcpy (buf, data, data_len); - buf +=DIV_ROUND_UP (data_len,sizeof (Elf_Word)); - -return buf; -} - -void final_note (Elf_Word *buf) -{ -memset (buf,0 ,sizeof (struct elf_note )); -} - -static void update_vmcoreinfo_note (void ) -{ -u32 *buf = vmcoreinfo_note; - -if (!vmcoreinfo_size) -return ; - buf =append_elf_note (buf,VMCOREINFO_NOTE_NAME ,0 , vmcoreinfo_data, - vmcoreinfo_size); -final_note (buf); -} - -void crash_update_vmcoreinfo_safecopy (void *ptr) -{ -if (ptr) -memcpy (ptr, vmcoreinfo_data, vmcoreinfo_size); - - vmcoreinfo_data_safecopy = ptr; -} - -void crash_save_vmcoreinfo (void ) -{ -if (!vmcoreinfo_note) -return ; - -/* Use the safe copy to generate vmcoreinfo note if have */ -if (vmcoreinfo_data_safecopy) - vmcoreinfo_data = vmcoreinfo_data_safecopy; - -vmcoreinfo_append_str ("CRASHTIME=%lld\n" ,ktime_get_real_seconds ()); -update_vmcoreinfo_note (); -} - -void vmcoreinfo_append_str (const char *fmt, ...) -{ -va_list args; -char buf[0x50 ]; -size_t r; - -va_start (args, fmt); - r =vscnprintf (buf,sizeof (buf), fmt, args); -va_end (args); - - r =min (r, (size_t )VMCOREINFO_BYTES - vmcoreinfo_size); - -memcpy (&vmcoreinfo_data[vmcoreinfo_size], buf, r); - - vmcoreinfo_size += r; - -WARN_ONCE (vmcoreinfo_size ==VMCOREINFO_BYTES , -"vmcoreinfo data exceeds allocated size, truncating" ); -} - -/* -* provide an empty default implementation here -- architecture -* code may override this -*/ -void __weak arch_crash_save_vmcoreinfo (void ) -{} - -phys_addr_t __weak paddr_vmcoreinfo_note (void ) -{ -return __pa (vmcoreinfo_note); -} -EXPORT_SYMBOL (paddr_vmcoreinfo_note); - -static int __init crash_save_vmcoreinfo_init (void ) -{ - vmcoreinfo_data = (unsigned char *)get_zeroed_page (GFP_KERNEL ); -if (!vmcoreinfo_data) { -pr_warn ("Memory allocation for vmcoreinfo_data failed\n" ); -return -ENOMEM ; - } - - vmcoreinfo_note =alloc_pages_exact (VMCOREINFO_NOTE_SIZE , -GFP_KERNEL | __GFP_ZERO); -if (!vmcoreinfo_note) { -free_page ((unsigned long )vmcoreinfo_data); - vmcoreinfo_data =NULL ; -pr_warn ("Memory allocation for vmcoreinfo_note failed\n" ); -return -ENOMEM ; - } - -VMCOREINFO_OSRELEASE (init_uts_ns.name.release); -VMCOREINFO_BUILD_ID (); -VMCOREINFO_PAGESIZE (PAGE_SIZE ); - -VMCOREINFO_SYMBOL (init_uts_ns); -VMCOREINFO_OFFSET (uts_namespace, name); -VMCOREINFO_SYMBOL (node_online_map); -#ifdef CONFIG_MMU -VMCOREINFO_SYMBOL_ARRAY (swapper_pg_dir); -#endif -VMCOREINFO_SYMBOL (_stext); -VMCOREINFO_SYMBOL (vmap_area_list); - -#ifndef CONFIG_NUMA -VMCOREINFO_SYMBOL (mem_map); -VMCOREINFO_SYMBOL (contig_page_data); -#endif -#ifdef CONFIG_SPARSEMEM -VMCOREINFO_SYMBOL_ARRAY (mem_section); -VMCOREINFO_LENGTH (mem_section,NR_SECTION_ROOTS ); -VMCOREINFO_STRUCT_SIZE (mem_section); -VMCOREINFO_OFFSET (mem_section, section_mem_map); -VMCOREINFO_NUMBER (SECTION_SIZE_BITS ); -VMCOREINFO_NUMBER (MAX_PHYSMEM_BITS ); -#endif -VMCOREINFO_STRUCT_SIZE (page); -VMCOREINFO_STRUCT_SIZE (pglist_data); -VMCOREINFO_STRUCT_SIZE (zone); -VMCOREINFO_STRUCT_SIZE (free_area); -VMCOREINFO_STRUCT_SIZE (list_head); -VMCOREINFO_SIZE (nodemask_t); -VMCOREINFO_OFFSET (page, flags); -VMCOREINFO_OFFSET (page, _refcount); -VMCOREINFO_OFFSET (page, mapping); -VMCOREINFO_OFFSET (page, lru); -VMCOREINFO_OFFSET (page, _mapcount); -VMCOREINFO_OFFSET (page, private); -VMCOREINFO_OFFSET (page, compound_head); -VMCOREINFO_OFFSET (pglist_data, node_zones); -VMCOREINFO_OFFSET (pglist_data, nr_zones); -#ifdef CONFIG_FLATMEM -VMCOREINFO_OFFSET (pglist_data, node_mem_map); -#endif -VMCOREINFO_OFFSET (pglist_data, node_start_pfn); -VMCOREINFO_OFFSET (pglist_data, node_spanned_pages); -VMCOREINFO_OFFSET (pglist_data, node_id); -VMCOREINFO_OFFSET (zone, free_area); -VMCOREINFO_OFFSET (zone, vm_stat); -VMCOREINFO_OFFSET (zone, spanned_pages); -VMCOREINFO_OFFSET (free_area, free_list); -VMCOREINFO_OFFSET (list_head, next); -VMCOREINFO_OFFSET (list_head, prev); -VMCOREINFO_OFFSET (vmap_area, va_start); -VMCOREINFO_OFFSET (vmap_area, list); -VMCOREINFO_LENGTH (zone.free_area,NR_PAGE_ORDERS ); -log_buf_vmcoreinfo_setup (); -VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES ); -VMCOREINFO_NUMBER (NR_FREE_PAGES ); -VMCOREINFO_NUMBER (PG_lru); -VMCOREINFO_NUMBER (PG_private); -VMCOREINFO_NUMBER (PG_swapcache); -VMCOREINFO_NUMBER (PG_swapbacked); -VMCOREINFO_NUMBER (PG_slab); -#ifdef CONFIG_MEMORY_FAILURE -VMCOREINFO_NUMBER (PG_hwpoison); -#endif -VMCOREINFO_NUMBER (PG_head_mask); -#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) -VMCOREINFO_NUMBER (PAGE_BUDDY_MAPCOUNT_VALUE ); -#ifdef CONFIG_HUGETLB_PAGE -VMCOREINFO_NUMBER (PG_hugetlb); -#define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) -VMCOREINFO_NUMBER (PAGE_OFFLINE_MAPCOUNT_VALUE ); -#endif - -#ifdef CONFIG_KALLSYMS -VMCOREINFO_SYMBOL (kallsyms_names); -VMCOREINFO_SYMBOL (kallsyms_num_syms); -VMCOREINFO_SYMBOL (kallsyms_token_table); -VMCOREINFO_SYMBOL (kallsyms_token_index); -#ifdef CONFIG_KALLSYMS_BASE_RELATIVE -VMCOREINFO_SYMBOL (kallsyms_offsets); -VMCOREINFO_SYMBOL (kallsyms_relative_base); -#else -VMCOREINFO_SYMBOL (kallsyms_addresses); -#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */ -#endif /* CONFIG_KALLSYMS */ - -arch_crash_save_vmcoreinfo (); -update_vmcoreinfo_note (); - -return 0 ; -} - -subsys_initcall (crash_save_vmcoreinfo_init); -static int __init crash_notes_memory_init (void ) {/* Allocate memory for saving cpu registers. */ kernel/ksysfs.c +3
-3@@ -154,7 +154,7 @@ KERNEL_ATTR_RW(kexec_crash_size);#endif /* CONFIG_KEXEC_CORE */ -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t vmcoreinfo_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf)@@ -177,7 +177,7 @@ KERNEL_ATTR_RO(crash_elfcorehdr_size);#endif -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* whether file capabilities are enabled */ static ssize_t fscaps_show(struct kobject *kobj,@@ -265,7 +265,7 @@ static struct attribute * kernel_attrs[] = { &kexec_crash_loaded_attr.attr, &kexec_crash_size_attr.attr, #endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO &vmcoreinfo_attr.attr, #ifdef CONFIG_CRASH_HOTPLUG &crash_elfcorehdr_size_attr.attr,kernel/printk/printk.c +2
-2@@ -34,7 +34,7 @@#include <linux/security.h> #include <linux/memblock.h> #include <linux/syscalls.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/ratelimit.h> #include <linux/kmsg_dump.h> #include <linux/syslog.h> @@ -951,7 +951,7 @@ const struct file_operations kmsg_fops = { .release = devkmsg_release, }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* * This appends the listed symbols to /proc/vmcore * kernel/vmcore_info.c new file +233
-0@@ -0,0 +1,233 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* crash.c - kernel crash support code. +* Copyright (C) 2002-2004 Eric Biederman <[email protected]> +*/ + +#include <linux/buildid.h> +#include <linux/init.h> +#include <linux/utsname.h> +#include <linux/vmalloc.h> +#include <linux/sizes.h> +#include <linux/kexec.h> +#include <linux/memory.h> +#include <linux/cpuhotplug.h> +#include <linux/memblock.h> +#include <linux/kexec.h> +#include <linux/kmemleak.h> + +#include <asm/page.h> +#include <asm/sections.h> + +#include <crypto/sha1.h> + +#include "kallsyms_internal.h" +#include "kexec_internal.h" + +/* vmcoreinfo stuff */ +unsigned char *vmcoreinfo_data; +size_t vmcoreinfo_size; +u32 *vmcoreinfo_note; + +/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ +static unsigned char *vmcoreinfo_data_safecopy; + +Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, +void *data,size_t data_len) +{ +struct elf_note *note = (struct elf_note *)buf; + + note->n_namesz =strlen (name) +1 ; + note->n_descsz = data_len; + note->n_type = type; + buf +=DIV_ROUND_UP (sizeof (*note),sizeof (Elf_Word)); +memcpy (buf, name, note->n_namesz); + buf +=DIV_ROUND_UP (note->n_namesz,sizeof (Elf_Word)); +memcpy (buf, data, data_len); + buf +=DIV_ROUND_UP (data_len,sizeof (Elf_Word)); + +return buf; +} + +void final_note (Elf_Word *buf) +{ +memset (buf,0 ,sizeof (struct elf_note )); +} + +static void update_vmcoreinfo_note (void ) +{ +u32 *buf = vmcoreinfo_note; + +if (!vmcoreinfo_size) +return ; + buf =append_elf_note (buf,VMCOREINFO_NOTE_NAME ,0 , vmcoreinfo_data, + vmcoreinfo_size); +final_note (buf); +} + +void crash_update_vmcoreinfo_safecopy (void *ptr) +{ +if (ptr) +memcpy (ptr, vmcoreinfo_data, vmcoreinfo_size); + + vmcoreinfo_data_safecopy = ptr; +} + +void crash_save_vmcoreinfo (void ) +{ +if (!vmcoreinfo_note) +return ; + +/* Use the safe copy to generate vmcoreinfo note if have */ +if (vmcoreinfo_data_safecopy) + vmcoreinfo_data = vmcoreinfo_data_safecopy; + +vmcoreinfo_append_str ("CRASHTIME=%lld\n" ,ktime_get_real_seconds ()); +update_vmcoreinfo_note (); +} + +void vmcoreinfo_append_str (const char *fmt, ...) +{ +va_list args; +char buf[0x50 ]; +size_t r; + +va_start (args, fmt); + r =vscnprintf (buf,sizeof (buf), fmt, args); +va_end (args); + + r =min (r, (size_t )VMCOREINFO_BYTES - vmcoreinfo_size); + +memcpy (&vmcoreinfo_data[vmcoreinfo_size], buf, r); + + vmcoreinfo_size += r; + +WARN_ONCE (vmcoreinfo_size ==VMCOREINFO_BYTES , +"vmcoreinfo data exceeds allocated size, truncating" ); +} + +/* +* provide an empty default implementation here -- architecture +* code may override this +*/ +void __weak arch_crash_save_vmcoreinfo (void ) +{} + +phys_addr_t __weak paddr_vmcoreinfo_note (void ) +{ +return __pa (vmcoreinfo_note); +} +EXPORT_SYMBOL (paddr_vmcoreinfo_note); + +static int __init crash_save_vmcoreinfo_init (void ) +{ + vmcoreinfo_data = (unsigned char *)get_zeroed_page (GFP_KERNEL ); +if (!vmcoreinfo_data) { +pr_warn ("Memory allocation for vmcoreinfo_data failed\n" ); +return -ENOMEM ; + } + + vmcoreinfo_note =alloc_pages_exact (VMCOREINFO_NOTE_SIZE , +GFP_KERNEL | __GFP_ZERO); +if (!vmcoreinfo_note) { +free_page ((unsigned long )vmcoreinfo_data); + vmcoreinfo_data =NULL ; +pr_warn ("Memory allocation for vmcoreinfo_note failed\n" ); +return -ENOMEM ; + } + +VMCOREINFO_OSRELEASE (init_uts_ns.name.release); +VMCOREINFO_BUILD_ID (); +VMCOREINFO_PAGESIZE (PAGE_SIZE ); + +VMCOREINFO_SYMBOL (init_uts_ns); +VMCOREINFO_OFFSET (uts_namespace, name); +VMCOREINFO_SYMBOL (node_online_map); +#ifdef CONFIG_MMU +VMCOREINFO_SYMBOL_ARRAY (swapper_pg_dir); +#endif +VMCOREINFO_SYMBOL (_stext); +VMCOREINFO_SYMBOL (vmap_area_list); + +#ifndef CONFIG_NUMA +VMCOREINFO_SYMBOL (mem_map); +VMCOREINFO_SYMBOL (contig_page_data); +#endif +#ifdef CONFIG_SPARSEMEM +VMCOREINFO_SYMBOL_ARRAY (mem_section); +VMCOREINFO_LENGTH (mem_section,NR_SECTION_ROOTS ); +VMCOREINFO_STRUCT_SIZE (mem_section); +VMCOREINFO_OFFSET (mem_section, section_mem_map); +VMCOREINFO_NUMBER (SECTION_SIZE_BITS ); +VMCOREINFO_NUMBER (MAX_PHYSMEM_BITS ); +#endif +VMCOREINFO_STRUCT_SIZE (page); +VMCOREINFO_STRUCT_SIZE (pglist_data); +VMCOREINFO_STRUCT_SIZE (zone); +VMCOREINFO_STRUCT_SIZE (free_area); +VMCOREINFO_STRUCT_SIZE (list_head); +VMCOREINFO_SIZE (nodemask_t); +VMCOREINFO_OFFSET (page, flags); +VMCOREINFO_OFFSET (page, _refcount); +VMCOREINFO_OFFSET (page, mapping); +VMCOREINFO_OFFSET (page, lru); +VMCOREINFO_OFFSET (page, _mapcount); +VMCOREINFO_OFFSET (page, private); +VMCOREINFO_OFFSET (page, compound_head); +VMCOREINFO_OFFSET (pglist_data, node_zones); +VMCOREINFO_OFFSET (pglist_data, nr_zones); +#ifdef CONFIG_FLATMEM +VMCOREINFO_OFFSET (pglist_data, node_mem_map); +#endif +VMCOREINFO_OFFSET (pglist_data, node_start_pfn); +VMCOREINFO_OFFSET (pglist_data, node_spanned_pages); +VMCOREINFO_OFFSET (pglist_data, node_id); +VMCOREINFO_OFFSET (zone, free_area); +VMCOREINFO_OFFSET (zone, vm_stat); +VMCOREINFO_OFFSET (zone, spanned_pages); +VMCOREINFO_OFFSET (free_area, free_list); +VMCOREINFO_OFFSET (list_head, next); +VMCOREINFO_OFFSET (list_head, prev); +VMCOREINFO_OFFSET (vmap_area, va_start); +VMCOREINFO_OFFSET (vmap_area, list); +VMCOREINFO_LENGTH (zone.free_area,NR_PAGE_ORDERS ); +log_buf_vmcoreinfo_setup (); +VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES ); +VMCOREINFO_NUMBER (NR_FREE_PAGES ); +VMCOREINFO_NUMBER (PG_lru); +VMCOREINFO_NUMBER (PG_private); +VMCOREINFO_NUMBER (PG_swapcache); +VMCOREINFO_NUMBER (PG_swapbacked); +VMCOREINFO_NUMBER (PG_slab); +#ifdef CONFIG_MEMORY_FAILURE +VMCOREINFO_NUMBER (PG_hwpoison); +#endif +VMCOREINFO_NUMBER (PG_head_mask); +#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) +VMCOREINFO_NUMBER (PAGE_BUDDY_MAPCOUNT_VALUE ); +#ifdef CONFIG_HUGETLB_PAGE +VMCOREINFO_NUMBER (PG_hugetlb); +#define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) +VMCOREINFO_NUMBER (PAGE_OFFLINE_MAPCOUNT_VALUE ); +#endif + +#ifdef CONFIG_KALLSYMS +VMCOREINFO_SYMBOL (kallsyms_names); +VMCOREINFO_SYMBOL (kallsyms_num_syms); +VMCOREINFO_SYMBOL (kallsyms_token_table); +VMCOREINFO_SYMBOL (kallsyms_token_index); +#ifdef CONFIG_KALLSYMS_BASE_RELATIVE +VMCOREINFO_SYMBOL (kallsyms_offsets); +VMCOREINFO_SYMBOL (kallsyms_relative_base); +#else +VMCOREINFO_SYMBOL (kallsyms_addresses); +#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */ +#endif /* CONFIG_KALLSYMS */ + +arch_crash_save_vmcoreinfo (); +update_vmcoreinfo_note (); + +return 0 ; +} + +subsys_initcall (crash_save_vmcoreinfo_init);lib/buildid.c +1
-1@@ -174,7 +174,7 @@ int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size)return parse_build_id_buf (build_id,NULL , buf, buf_size); } -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ]__ro_after_init ;/**
Re: [PATCH v2 02/14] crash: split vmcoreinfo exporting code out from crash_core.c
Quoted 10 lines · Sourabh Jain
Hello Baoquan,
Quoted 4 lines · Baoquan He
Now move the relevant codes into separate files:
kernel/crash_reserve.c,include/linux/crash_reserve.h.And add config item
CRASH_RESERVEto control its enabling.Feels like this patch is more about vmcore_info.[c|h] and
CONFIG_VMCORE_INFOthen the above mentioned files and config.
You are right. Above lines about crash_reserve should be removed. It's from v1, and done in patch 1 of v2 and v3. I forgot removing them.
Quoted 1,004 lines
Quoted 1,003 lines
And also update the old ifdeffery of
CONFIG_CRASH_CORE, including of <linux/crash_core.h> and config item dependency onCRASH_COREaccordingly.And also do renaming as follows:
-arch/xxx/kernel/{crash_core.c=>vmcore_info.c}
because they are only related to vmcoreinfo exporting on x86, arm64, riscv.And also Remove config item
CRASH_CORE, and rely onCONFIG_KEXEC_COREto decide if build incrash_core.c.Signed-off-by Baoquan He <[email protected]>--- arch/arm64/kernel/Makefile | 2 +- .../kernel/{crash_core.c => vmcore_info.c} | 2 +- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/setup-common.c | 2 +- arch/powerpc/platforms/powernv/opal-core.c | 2 +- arch/riscv/kernel/Makefile | 2 +- .../kernel/{crash_core.c => vmcore_info.c} | 2 +- arch/x86/kernel/Makefile | 2 +- .../{crash_core_32.c => vmcore_info_32.c} | 2 +- .../{crash_core_64.c => vmcore_info_64.c} | 2 +- drivers/firmware/qemu_fw_cfg.c | 14 +- fs/proc/Kconfig | 2 +- fs/proc/kcore.c | 2 +- include/linux/buildid.h | 2 +- include/linux/crash_core.h | 73 ------ include/linux/kexec.h | 1 + include/linux/vmcore_info.h | 81 ++++++ kernel/Kconfig.kexec | 4 +- kernel/Makefile | 4 +- kernel/crash_core.c | 208 ---------------- kernel/ksysfs.c | 6 +- kernel/printk/printk.c | 4 +- kernel/vmcore_info.c | 233 ++++++++++++++++++ lib/buildid.c | 2 +- 24 files changed, 345 insertions(+), 311 deletions(-)rename
arch/arm64/kernel/{crash_core.c=>vmcore_info.c} (97%) renamearch/riscv/kernel/{crash_core.c=>vmcore_info.c} (96%) renamearch/x86/kernel/{crash_core_32.c=>vmcore_info_32.c} (90%) renamearch/x86/kernel/{crash_core_64.c=>vmcore_info_64.c} (94%) create mode 100644include/linux/vmcore_info.h
create mode 100644kernel/vmcore_info.carch/arm64/kernel/Makefile +1
-1@@ -66,7 +66,7 @@ obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o obj-$(CONFIG_ARM64_PTR_AUTH) += pointer_auth.o obj-$(CONFIG_ARM64_MTE) += mte.oarch/arm64/kernel/vmcore_info.c renamed from arch/arm64/kernel/crash_core.c +1
-1@@ -4,7 +4,7 @@* Copyright (C) Huawei Futurewei Technologies. */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <asm/cpufeature.h> #include <asm/memory.h> #include <asm/pgtable-hwdef.h> arch/powerpc/Kconfig +1
-1@@ -690,7 +690,7 @@ config ARCH_SELECTS_CRASH_DUMP config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE select CRASH_DUMP helparch/powerpc/kernel/setup-common.c +1
-1@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;EXPORT_SYMBOL (ppc_do_canonicalize_irqs);#endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* This keeps a track of which one is the crashing cpu. */ int crashing_cpu =-1 ;#endif arch/powerpc/platforms/powernv/opal-core.c +1
-1@@ -16,7 +16,7 @@#include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/slab.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/of.h> #include <asm/page.h> arch/riscv/kernel/Makefile +1
-1@@ -91,7 +91,7 @@ obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_JUMP_LABEL) += jump_label.oarch/riscv/kernel/vmcore_info.c renamed from arch/riscv/kernel/crash_core.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pagemap.h> void arch_crash_save_vmcoreinfo (void )arch/x86/kernel/Makefile +1
-1@@ -98,7 +98,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o obj-$(CONFIG_X86_TSC) += trace_clock.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_RETHOOK) += rethook.o -obj-$(CONFIG_CRASH_CORE) += crash_core_$(BITS).o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += machine_kexec_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o crash.o obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.oarch/x86/kernel/vmcore_info_32.c renamed from arch/x86/kernel/crash_core_32.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h> arch/x86/kernel/vmcore_info_64.c renamed from arch/x86/kernel/crash_core_64.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/pgtable.h> #include <asm/setup.h> drivers/firmware/qemu_fw_cfg.c +7
-7@@ -37,7 +37,7 @@#include <uapi/linux/qemu_fw_cfg.h> #include <linux/delay.h> #include <linux/crash_dump.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> MODULE_AUTHOR ("Gabriel L. Somlo <[email protected]>" );MODULE_DESCRIPTION ("QEMU fw_cfg sysfs support" );@@ -67,7 +67,7 @@ static void fw_cfg_sel_endianness(u16 key)iowrite16 (key, fw_cfg_reg_ctrl); } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static inline bool fw_cfg_dma_enabled (void ) {return (fw_cfg_rev &FW_CFG_VERSION_DMA ) && fw_cfg_reg_dma;@@ -156,7 +156,7 @@ static ssize_t fw_cfg_read_blob(u16 key,return count; } -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */ static ssize_t fw_cfg_write_blob (u16 key,void *buf,loff_t pos,size_t count)@@ -195,7 +195,7 @@ static ssize_t fw_cfg_write_blob(u16 key, return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* clean up fw_cfg device i/o */ static void fw_cfg_io_cleanup (void )@@ -319,7 +319,7 @@ struct fw_cfg_sysfs_entry {struct list_head list; }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t fw_cfg_write_vmcoreinfo (const struct fw_cfg_file *f) {static struct fw_cfg_vmcoreinfo *data;@@ -343,7 +343,7 @@ static ssize_t fw_cfg_write_vmcoreinfo(const struct fw_cfg_file *f)kfree (data); return ret; } -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* get fw_cfg_sysfs_entry from kobject member */ static inline struct fw_cfg_sysfs_entry *to_entry (struct kobject *kobj)@@ -583,7 +583,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)int err;struct fw_cfg_sysfs_entry *entry; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO if (fw_cfg_dma_enabled () &&strcmp (f->name,FW_CFG_VMCOREINFO_FILENAME ) ==0 && !is_kdump_kernel ()) {fs/proc/Kconfig +1
-1@@ -32,7 +32,7 @@ config PROC_FS config PROC_KCORE bool "/proc/kcore support" if !ARM depends on PROC_FS && MMU - select CRASH_CORE + select VMCORE_INFO help Provides a virtual ELF core file of the live kernel. This can be read with gdb and other ELF tools. No modifications can befs/proc/kcore.c +1
-1@@ -10,7 +10,7 @@* Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <[email protected]> */ -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/mm.h> #include <linux/proc_fs.h> #include <linux/kcore.h> include/linux/buildid.h +1
-1@@ -11,7 +11,7 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id, __u32 *size);int build_id_parse_buf (const void *buf,unsigned char *build_id,u32 buf_size); -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ];void init_vmlinux_build_id (void );#else include/linux/crash_core.h +0
-73@@ -6,79 +6,6 @@#include <linux/elfcore.h> #include <linux/elf.h> -#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) -#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) - -/* -* The per-cpu notes area is a list of notes terminated by a "NULL" -* note header. For kdump, the code in vmcore.c runs in the context -* of the second kernel to combine them into one note. -*/ -#define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ - CRASH_CORE_NOTE_NAME_BYTES + \ - CRASH_CORE_NOTE_DESC_BYTES) - -#define VMCOREINFO_BYTES PAGE_SIZE -#define VMCOREINFO_NOTE_NAME "VMCOREINFO" -#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) -#define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ - VMCOREINFO_NOTE_NAME_BYTES + \ - VMCOREINFO_BYTES) - -typedef u32 note_buf_t [CRASH_CORE_NOTE_BYTES /4 ]; -/* Per cpu memory for storing cpu states in case of system crash. */ -extern note_buf_t __percpu *crash_notes; - -void crash_update_vmcoreinfo_safecopy (void *ptr); -void crash_save_vmcoreinfo (void ); -void arch_crash_save_vmcoreinfo (void ); -__printf(1, 2) -void vmcoreinfo_append_str (const char *fmt, ...); -phys_addr_t paddr_vmcoreinfo_note (void ); - -#define VMCOREINFO_OSRELEASE (value) \ - vmcoreinfo_append_str("OSRELEASE=%s\n", value) -#define VMCOREINFO_BUILD_ID () \ - ({ \ - static_assert(sizeof(vmlinux_build_id) == 20); \ - vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \ - }) - -#define VMCOREINFO_PAGESIZE (value) \ - vmcoreinfo_append_str("PAGESIZE=%ld\n", value) -#define VMCOREINFO_SYMBOL (name) \ - vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) -#define VMCOREINFO_SYMBOL_ARRAY (name) \ - vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name) -#define VMCOREINFO_SIZE (name) \ - vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ - (unsigned long)sizeof(name)) -#define VMCOREINFO_STRUCT_SIZE (name) \ - vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ - (unsigned long)sizeof(struct name)) -#define VMCOREINFO_OFFSET (name, field) \ - vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ - (unsigned long)offsetof(struct name, field)) -#define VMCOREINFO_TYPE_OFFSET (name, field) \ - vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ - (unsigned long)offsetof(name, field)) -#define VMCOREINFO_LENGTH (name, value) \ - vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value) -#define VMCOREINFO_NUMBER (name) \ - vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name) -#define VMCOREINFO_CONFIG (name) \ - vmcoreinfo_append_str("CONFIG_%s=y\n", #name) - -extern unsigned char *vmcoreinfo_data; -extern size_t vmcoreinfo_size; -extern u32 *vmcoreinfo_note; - -Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, -void *data,size_t data_len); -void final_note (Elf_Word *buf); -/* Alignment required for elf header segment */ #define ELF_CORE_HEADER_ALIGN 4096include/linux/kexec.h +1
-0@@ -16,6 +16,7 @@#if !defined(__ASSEMBLY__)#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/crash_reserve.h> #include <asm/io.h> #include <linux/range.h> include/linux/vmcore_info.h new file +81
-0@@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LINUX_VMCORE_INFO_H +#define LINUX_VMCORE_INFO_H + +#include <linux/linkage.h> +#include <linux/elfcore.h> +#include <linux/elf.h> + +#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) +#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) + +/* +* The per-cpu notes area is a list of notes terminated by a "NULL" +* note header. For kdump, the code in vmcore.c runs in the context +* of the second kernel to combine them into one note. +*/ +#define CRASH_CORE_NOTE_BYTES ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ + CRASH_CORE_NOTE_NAME_BYTES + \ + CRASH_CORE_NOTE_DESC_BYTES) + +#define VMCOREINFO_BYTES PAGE_SIZE +#define VMCOREINFO_NOTE_NAME "VMCOREINFO" +#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) +#define VMCOREINFO_NOTE_SIZE ((CRASH_CORE_NOTE_HEAD_BYTES * 2) + \ + VMCOREINFO_NOTE_NAME_BYTES + \ + VMCOREINFO_BYTES) + +typedef u32 note_buf_t [CRASH_CORE_NOTE_BYTES /4 ]; +/* Per cpu memory for storing cpu states in case of system crash. */ +extern note_buf_t __percpu *crash_notes; + +void crash_update_vmcoreinfo_safecopy (void *ptr); +void crash_save_vmcoreinfo (void ); +void arch_crash_save_vmcoreinfo (void ); +__printf(1, 2) +void vmcoreinfo_append_str (const char *fmt, ...); +phys_addr_t paddr_vmcoreinfo_note (void ); + +#define VMCOREINFO_OSRELEASE (value) \ + vmcoreinfo_append_str("OSRELEASE=%s\n", value) +#define VMCOREINFO_BUILD_ID () \ + ({ \ + static_assert(sizeof(vmlinux_build_id) == 20); \ + vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \ + }) + +#define VMCOREINFO_PAGESIZE (value) \ + vmcoreinfo_append_str("PAGESIZE=%ld\n", value) +#define VMCOREINFO_SYMBOL (name) \ + vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) +#define VMCOREINFO_SYMBOL_ARRAY (name) \ + vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name) +#define VMCOREINFO_SIZE (name) \ + vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ + (unsigned long)sizeof(name)) +#define VMCOREINFO_STRUCT_SIZE (name) \ + vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ + (unsigned long)sizeof(struct name)) +#define VMCOREINFO_OFFSET (name, field) \ + vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ + (unsigned long)offsetof(struct name, field)) +#define VMCOREINFO_TYPE_OFFSET (name, field) \ + vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ + (unsigned long)offsetof(name, field)) +#define VMCOREINFO_LENGTH (name, value) \ + vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value) +#define VMCOREINFO_NUMBER (name) \ + vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name) +#define VMCOREINFO_CONFIG (name) \ + vmcoreinfo_append_str("CONFIG_%s=y\n", #name) + +extern unsigned char *vmcoreinfo_data; +extern size_t vmcoreinfo_size; +extern u32 *vmcoreinfo_note; + +Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, +void *data,size_t data_len); +void final_note (Elf_Word *buf); +#endif /* LINUX_VMCORE_INFO_H */ kernel/Kconfig.kexec +2
-2@@ -5,11 +5,11 @@ menu "Kexec and crash features" config CRASH_RESERVE bool -config CRASH_CORE +config VMCORE_INFO bool config KEXEC_CORE - select CRASH_CORE + select VMCORE_INFO select CRASH_RESERVE boolkernel/Makefile +2
-2@@ -68,9 +68,9 @@ obj-$(CONFIG_MODULE_SIG_FORMAT) += module_signature.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o -obj-$(CONFIG_CRASH_CORE) += crash_core.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o -obj-$(CONFIG_KEXEC_CORE) += kexec_core.o +obj-$(CONFIG_KEXEC_CORE) += kexec_core.o crash_core.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC_FILE) += kexec_file.o obj-$(CONFIG_KEXEC_ELF) += kexec_elf.okernel/crash_core.c +0
-208@@ -26,14 +26,6 @@/* Per cpu memory for storing cpu states in case of system crash. */ note_buf_t __percpu *crash_notes; -/* vmcoreinfo stuff */ -unsigned char *vmcoreinfo_data; -size_t vmcoreinfo_size; -u32 *vmcoreinfo_note; - -/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ -static unsigned char *vmcoreinfo_data_safecopy; -int crash_prepare_elf64_headers (struct crash_mem *mem,int need_kernel_map,void **addr,unsigned long *sz) {@@ -195,206 +187,6 @@ int crash_exclude_mem_range(struct crash_mem *mem,return 0 ; } -Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, -void *data,size_t data_len) -{ -struct elf_note *note = (struct elf_note *)buf; - - note->n_namesz =strlen (name) +1 ; - note->n_descsz = data_len; - note->n_type = type; - buf +=DIV_ROUND_UP (sizeof (*note),sizeof (Elf_Word)); -memcpy (buf, name, note->n_namesz); - buf +=DIV_ROUND_UP (note->n_namesz,sizeof (Elf_Word)); -memcpy (buf, data, data_len); - buf +=DIV_ROUND_UP (data_len,sizeof (Elf_Word)); - -return buf; -} - -void final_note (Elf_Word *buf) -{ -memset (buf,0 ,sizeof (struct elf_note )); -} - -static void update_vmcoreinfo_note (void ) -{ -u32 *buf = vmcoreinfo_note; - -if (!vmcoreinfo_size) -return ; - buf =append_elf_note (buf,VMCOREINFO_NOTE_NAME ,0 , vmcoreinfo_data, - vmcoreinfo_size); -final_note (buf); -} - -void crash_update_vmcoreinfo_safecopy (void *ptr) -{ -if (ptr) -memcpy (ptr, vmcoreinfo_data, vmcoreinfo_size); - - vmcoreinfo_data_safecopy = ptr; -} - -void crash_save_vmcoreinfo (void ) -{ -if (!vmcoreinfo_note) -return ; - -/* Use the safe copy to generate vmcoreinfo note if have */ -if (vmcoreinfo_data_safecopy) - vmcoreinfo_data = vmcoreinfo_data_safecopy; - -vmcoreinfo_append_str ("CRASHTIME=%lld\n" ,ktime_get_real_seconds ()); -update_vmcoreinfo_note (); -} - -void vmcoreinfo_append_str (const char *fmt, ...) -{ -va_list args; -char buf[0x50 ]; -size_t r; - -va_start (args, fmt); - r =vscnprintf (buf,sizeof (buf), fmt, args); -va_end (args); - - r =min (r, (size_t )VMCOREINFO_BYTES - vmcoreinfo_size); - -memcpy (&vmcoreinfo_data[vmcoreinfo_size], buf, r); - - vmcoreinfo_size += r; - -WARN_ONCE (vmcoreinfo_size ==VMCOREINFO_BYTES , -"vmcoreinfo data exceeds allocated size, truncating" ); -} - -/* -* provide an empty default implementation here -- architecture -* code may override this -*/ -void __weak arch_crash_save_vmcoreinfo (void ) -{} - -phys_addr_t __weak paddr_vmcoreinfo_note (void ) -{ -return __pa (vmcoreinfo_note); -} -EXPORT_SYMBOL (paddr_vmcoreinfo_note); - -static int __init crash_save_vmcoreinfo_init (void ) -{ - vmcoreinfo_data = (unsigned char *)get_zeroed_page (GFP_KERNEL ); -if (!vmcoreinfo_data) { -pr_warn ("Memory allocation for vmcoreinfo_data failed\n" ); -return -ENOMEM ; - } - - vmcoreinfo_note =alloc_pages_exact (VMCOREINFO_NOTE_SIZE , -GFP_KERNEL | __GFP_ZERO); -if (!vmcoreinfo_note) { -free_page ((unsigned long )vmcoreinfo_data); - vmcoreinfo_data =NULL ; -pr_warn ("Memory allocation for vmcoreinfo_note failed\n" ); -return -ENOMEM ; - } - -VMCOREINFO_OSRELEASE (init_uts_ns.name.release); -VMCOREINFO_BUILD_ID (); -VMCOREINFO_PAGESIZE (PAGE_SIZE ); - -VMCOREINFO_SYMBOL (init_uts_ns); -VMCOREINFO_OFFSET (uts_namespace, name); -VMCOREINFO_SYMBOL (node_online_map); -#ifdef CONFIG_MMU -VMCOREINFO_SYMBOL_ARRAY (swapper_pg_dir); -#endif -VMCOREINFO_SYMBOL (_stext); -VMCOREINFO_SYMBOL (vmap_area_list); - -#ifndef CONFIG_NUMA -VMCOREINFO_SYMBOL (mem_map); -VMCOREINFO_SYMBOL (contig_page_data); -#endif -#ifdef CONFIG_SPARSEMEM -VMCOREINFO_SYMBOL_ARRAY (mem_section); -VMCOREINFO_LENGTH (mem_section,NR_SECTION_ROOTS ); -VMCOREINFO_STRUCT_SIZE (mem_section); -VMCOREINFO_OFFSET (mem_section, section_mem_map); -VMCOREINFO_NUMBER (SECTION_SIZE_BITS ); -VMCOREINFO_NUMBER (MAX_PHYSMEM_BITS ); -#endif -VMCOREINFO_STRUCT_SIZE (page); -VMCOREINFO_STRUCT_SIZE (pglist_data); -VMCOREINFO_STRUCT_SIZE (zone); -VMCOREINFO_STRUCT_SIZE (free_area); -VMCOREINFO_STRUCT_SIZE (list_head); -VMCOREINFO_SIZE (nodemask_t); -VMCOREINFO_OFFSET (page, flags); -VMCOREINFO_OFFSET (page, _refcount); -VMCOREINFO_OFFSET (page, mapping); -VMCOREINFO_OFFSET (page, lru); -VMCOREINFO_OFFSET (page, _mapcount); -VMCOREINFO_OFFSET (page, private); -VMCOREINFO_OFFSET (page, compound_head); -VMCOREINFO_OFFSET (pglist_data, node_zones); -VMCOREINFO_OFFSET (pglist_data, nr_zones); -#ifdef CONFIG_FLATMEM -VMCOREINFO_OFFSET (pglist_data, node_mem_map); -#endif -VMCOREINFO_OFFSET (pglist_data, node_start_pfn); -VMCOREINFO_OFFSET (pglist_data, node_spanned_pages); -VMCOREINFO_OFFSET (pglist_data, node_id); -VMCOREINFO_OFFSET (zone, free_area); -VMCOREINFO_OFFSET (zone, vm_stat); -VMCOREINFO_OFFSET (zone, spanned_pages); -VMCOREINFO_OFFSET (free_area, free_list); -VMCOREINFO_OFFSET (list_head, next); -VMCOREINFO_OFFSET (list_head, prev); -VMCOREINFO_OFFSET (vmap_area, va_start); -VMCOREINFO_OFFSET (vmap_area, list); -VMCOREINFO_LENGTH (zone.free_area,NR_PAGE_ORDERS ); -log_buf_vmcoreinfo_setup (); -VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES ); -VMCOREINFO_NUMBER (NR_FREE_PAGES ); -VMCOREINFO_NUMBER (PG_lru); -VMCOREINFO_NUMBER (PG_private); -VMCOREINFO_NUMBER (PG_swapcache); -VMCOREINFO_NUMBER (PG_swapbacked); -VMCOREINFO_NUMBER (PG_slab); -#ifdef CONFIG_MEMORY_FAILURE -VMCOREINFO_NUMBER (PG_hwpoison); -#endif -VMCOREINFO_NUMBER (PG_head_mask); -#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) -VMCOREINFO_NUMBER (PAGE_BUDDY_MAPCOUNT_VALUE ); -#ifdef CONFIG_HUGETLB_PAGE -VMCOREINFO_NUMBER (PG_hugetlb); -#define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) -VMCOREINFO_NUMBER (PAGE_OFFLINE_MAPCOUNT_VALUE ); -#endif - -#ifdef CONFIG_KALLSYMS -VMCOREINFO_SYMBOL (kallsyms_names); -VMCOREINFO_SYMBOL (kallsyms_num_syms); -VMCOREINFO_SYMBOL (kallsyms_token_table); -VMCOREINFO_SYMBOL (kallsyms_token_index); -#ifdef CONFIG_KALLSYMS_BASE_RELATIVE -VMCOREINFO_SYMBOL (kallsyms_offsets); -VMCOREINFO_SYMBOL (kallsyms_relative_base); -#else -VMCOREINFO_SYMBOL (kallsyms_addresses); -#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */ -#endif /* CONFIG_KALLSYMS */ - -arch_crash_save_vmcoreinfo (); -update_vmcoreinfo_note (); - -return 0 ; -} - -subsys_initcall (crash_save_vmcoreinfo_init); -static int __init crash_notes_memory_init (void ) {/* Allocate memory for saving cpu registers. */ kernel/ksysfs.c +3
-3@@ -154,7 +154,7 @@ KERNEL_ATTR_RW(kexec_crash_size);#endif /* CONFIG_KEXEC_CORE */ -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO static ssize_t vmcoreinfo_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf)@@ -177,7 +177,7 @@ KERNEL_ATTR_RO(crash_elfcorehdr_size);#endif -#endif /* CONFIG_CRASH_CORE */ +#endif /* CONFIG_VMCORE_INFO */ /* whether file capabilities are enabled */ static ssize_t fscaps_show(struct kobject *kobj,@@ -265,7 +265,7 @@ static struct attribute * kernel_attrs[] = { &kexec_crash_loaded_attr.attr, &kexec_crash_size_attr.attr, #endif -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO &vmcoreinfo_attr.attr, #ifdef CONFIG_CRASH_HOTPLUG &crash_elfcorehdr_size_attr.attr,kernel/printk/printk.c +2
-2@@ -34,7 +34,7 @@#include <linux/security.h> #include <linux/memblock.h> #include <linux/syscalls.h> -#include <linux/crash_core.h> +#include <linux/vmcore_info.h> #include <linux/ratelimit.h> #include <linux/kmsg_dump.h> #include <linux/syslog.h> @@ -951,7 +951,7 @@ const struct file_operations kmsg_fops = { .release = devkmsg_release, }; -#ifdef CONFIG_CRASH_CORE +#ifdef CONFIG_VMCORE_INFO /* * This appends the listed symbols to /proc/vmcore * kernel/vmcore_info.c new file +233
-0@@ -0,0 +1,233 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* crash.c - kernel crash support code. +* Copyright (C) 2002-2004 Eric Biederman <[email protected]> +*/ + +#include <linux/buildid.h> +#include <linux/init.h> +#include <linux/utsname.h> +#include <linux/vmalloc.h> +#include <linux/sizes.h> +#include <linux/kexec.h> +#include <linux/memory.h> +#include <linux/cpuhotplug.h> +#include <linux/memblock.h> +#include <linux/kexec.h> +#include <linux/kmemleak.h> + +#include <asm/page.h> +#include <asm/sections.h> + +#include <crypto/sha1.h> + +#include "kallsyms_internal.h" +#include "kexec_internal.h" + +/* vmcoreinfo stuff */ +unsigned char *vmcoreinfo_data; +size_t vmcoreinfo_size; +u32 *vmcoreinfo_note; + +/* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ +static unsigned char *vmcoreinfo_data_safecopy; + +Elf_Word *append_elf_note (Elf_Word *buf,char *name,unsigned int type, +void *data,size_t data_len) +{ +struct elf_note *note = (struct elf_note *)buf; + + note->n_namesz =strlen (name) +1 ; + note->n_descsz = data_len; + note->n_type = type; + buf +=DIV_ROUND_UP (sizeof (*note),sizeof (Elf_Word)); +memcpy (buf, name, note->n_namesz); + buf +=DIV_ROUND_UP (note->n_namesz,sizeof (Elf_Word)); +memcpy (buf, data, data_len); + buf +=DIV_ROUND_UP (data_len,sizeof (Elf_Word)); + +return buf; +} + +void final_note (Elf_Word *buf) +{ +memset (buf,0 ,sizeof (struct elf_note )); +} + +static void update_vmcoreinfo_note (void ) +{ +u32 *buf = vmcoreinfo_note; + +if (!vmcoreinfo_size) +return ; + buf =append_elf_note (buf,VMCOREINFO_NOTE_NAME ,0 , vmcoreinfo_data, + vmcoreinfo_size); +final_note (buf); +} + +void crash_update_vmcoreinfo_safecopy (void *ptr) +{ +if (ptr) +memcpy (ptr, vmcoreinfo_data, vmcoreinfo_size); + + vmcoreinfo_data_safecopy = ptr; +} + +void crash_save_vmcoreinfo (void ) +{ +if (!vmcoreinfo_note) +return ; + +/* Use the safe copy to generate vmcoreinfo note if have */ +if (vmcoreinfo_data_safecopy) + vmcoreinfo_data = vmcoreinfo_data_safecopy; + +vmcoreinfo_append_str ("CRASHTIME=%lld\n" ,ktime_get_real_seconds ()); +update_vmcoreinfo_note (); +} + +void vmcoreinfo_append_str (const char *fmt, ...) +{ +va_list args; +char buf[0x50 ]; +size_t r; + +va_start (args, fmt); + r =vscnprintf (buf,sizeof (buf), fmt, args); +va_end (args); + + r =min (r, (size_t )VMCOREINFO_BYTES - vmcoreinfo_size); + +memcpy (&vmcoreinfo_data[vmcoreinfo_size], buf, r); + + vmcoreinfo_size += r; + +WARN_ONCE (vmcoreinfo_size ==VMCOREINFO_BYTES , +"vmcoreinfo data exceeds allocated size, truncating" ); +} + +/* +* provide an empty default implementation here -- architecture +* code may override this +*/ +void __weak arch_crash_save_vmcoreinfo (void ) +{} + +phys_addr_t __weak paddr_vmcoreinfo_note (void ) +{ +return __pa (vmcoreinfo_note); +} +EXPORT_SYMBOL (paddr_vmcoreinfo_note); + +static int __init crash_save_vmcoreinfo_init (void ) +{ + vmcoreinfo_data = (unsigned char *)get_zeroed_page (GFP_KERNEL ); +if (!vmcoreinfo_data) { +pr_warn ("Memory allocation for vmcoreinfo_data failed\n" ); +return -ENOMEM ; + } + + vmcoreinfo_note =alloc_pages_exact (VMCOREINFO_NOTE_SIZE , +GFP_KERNEL | __GFP_ZERO); +if (!vmcoreinfo_note) { +free_page ((unsigned long )vmcoreinfo_data); + vmcoreinfo_data =NULL ; +pr_warn ("Memory allocation for vmcoreinfo_note failed\n" ); +return -ENOMEM ; + } + +VMCOREINFO_OSRELEASE (init_uts_ns.name.release); +VMCOREINFO_BUILD_ID (); +VMCOREINFO_PAGESIZE (PAGE_SIZE ); + +VMCOREINFO_SYMBOL (init_uts_ns); +VMCOREINFO_OFFSET (uts_namespace, name); +VMCOREINFO_SYMBOL (node_online_map); +#ifdef CONFIG_MMU +VMCOREINFO_SYMBOL_ARRAY (swapper_pg_dir); +#endif +VMCOREINFO_SYMBOL (_stext); +VMCOREINFO_SYMBOL (vmap_area_list); + +#ifndef CONFIG_NUMA +VMCOREINFO_SYMBOL (mem_map); +VMCOREINFO_SYMBOL (contig_page_data); +#endif +#ifdef CONFIG_SPARSEMEM +VMCOREINFO_SYMBOL_ARRAY (mem_section); +VMCOREINFO_LENGTH (mem_section,NR_SECTION_ROOTS ); +VMCOREINFO_STRUCT_SIZE (mem_section); +VMCOREINFO_OFFSET (mem_section, section_mem_map); +VMCOREINFO_NUMBER (SECTION_SIZE_BITS ); +VMCOREINFO_NUMBER (MAX_PHYSMEM_BITS ); +#endif +VMCOREINFO_STRUCT_SIZE (page); +VMCOREINFO_STRUCT_SIZE (pglist_data); +VMCOREINFO_STRUCT_SIZE (zone); +VMCOREINFO_STRUCT_SIZE (free_area); +VMCOREINFO_STRUCT_SIZE (list_head); +VMCOREINFO_SIZE (nodemask_t); +VMCOREINFO_OFFSET (page, flags); +VMCOREINFO_OFFSET (page, _refcount); +VMCOREINFO_OFFSET (page, mapping); +VMCOREINFO_OFFSET (page, lru); +VMCOREINFO_OFFSET (page, _mapcount); +VMCOREINFO_OFFSET (page, private); +VMCOREINFO_OFFSET (page, compound_head); +VMCOREINFO_OFFSET (pglist_data, node_zones); +VMCOREINFO_OFFSET (pglist_data, nr_zones); +#ifdef CONFIG_FLATMEM +VMCOREINFO_OFFSET (pglist_data, node_mem_map); +#endif +VMCOREINFO_OFFSET (pglist_data, node_start_pfn); +VMCOREINFO_OFFSET (pglist_data, node_spanned_pages); +VMCOREINFO_OFFSET (pglist_data, node_id); +VMCOREINFO_OFFSET (zone, free_area); +VMCOREINFO_OFFSET (zone, vm_stat); +VMCOREINFO_OFFSET (zone, spanned_pages); +VMCOREINFO_OFFSET (free_area, free_list); +VMCOREINFO_OFFSET (list_head, next); +VMCOREINFO_OFFSET (list_head, prev); +VMCOREINFO_OFFSET (vmap_area, va_start); +VMCOREINFO_OFFSET (vmap_area, list); +VMCOREINFO_LENGTH (zone.free_area,NR_PAGE_ORDERS ); +log_buf_vmcoreinfo_setup (); +VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES ); +VMCOREINFO_NUMBER (NR_FREE_PAGES ); +VMCOREINFO_NUMBER (PG_lru); +VMCOREINFO_NUMBER (PG_private); +VMCOREINFO_NUMBER (PG_swapcache); +VMCOREINFO_NUMBER (PG_swapbacked); +VMCOREINFO_NUMBER (PG_slab); +#ifdef CONFIG_MEMORY_FAILURE +VMCOREINFO_NUMBER (PG_hwpoison); +#endif +VMCOREINFO_NUMBER (PG_head_mask); +#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) +VMCOREINFO_NUMBER (PAGE_BUDDY_MAPCOUNT_VALUE ); +#ifdef CONFIG_HUGETLB_PAGE +VMCOREINFO_NUMBER (PG_hugetlb); +#define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) +VMCOREINFO_NUMBER (PAGE_OFFLINE_MAPCOUNT_VALUE ); +#endif + +#ifdef CONFIG_KALLSYMS +VMCOREINFO_SYMBOL (kallsyms_names); +VMCOREINFO_SYMBOL (kallsyms_num_syms); +VMCOREINFO_SYMBOL (kallsyms_token_table); +VMCOREINFO_SYMBOL (kallsyms_token_index); +#ifdef CONFIG_KALLSYMS_BASE_RELATIVE +VMCOREINFO_SYMBOL (kallsyms_offsets); +VMCOREINFO_SYMBOL (kallsyms_relative_base); +#else +VMCOREINFO_SYMBOL (kallsyms_addresses); +#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */ +#endif /* CONFIG_KALLSYMS */ + +arch_crash_save_vmcoreinfo (); +update_vmcoreinfo_note (); + +return 0 ; +} + +subsys_initcall (crash_save_vmcoreinfo_init);lib/buildid.c +1
-1@@ -174,7 +174,7 @@ int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size)return parse_build_id_buf (build_id,NULL , buf, buf_size); } -#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_CRASH_CORE ) +#if IS_ENABLED (CONFIG_STACKTRACE_BUILD_ID ) ||IS_ENABLED (CONFIG_VMCORE_INFO )unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX ]__ro_after_init ;/**
PATCH v2 3/14 crash: remove dependency of FA_DUMP on CRASH_DUMP
In reply to Baoquan HeIn kdump kernel, /proc/vmcore is an elf file mapping the crashed kernel's old memory content. Its elf header is constructed in 1st kernel and passed to kdump kernel via elfcorehdr_addr. Config CRASH_DUMP enables the code of 1st kernel's old memory accessing in different architectures.
Currently, config FA_DUMP has dependency on CRASH_DUMP because fadump needs access global variable 'elfcorehdr_addr' to judge if it's in kdump kernel within function is_kdump_kernel(). In the current kernel/crash_dump.c, variable 'elfcorehdr_addr' is defined, and function setup_elfcorehdr() used to parse kernel parameter to fetch the passed value of elfcorehdr_addr. Only for accessing elfcorehdr_addr, FA_DUMP really doesn't have to depends on CRASH_DUMP.
To remove the dependency of FA_DUMP on CRASH_DUMP to avoid confusion, rename kernel/crash_dump.c to kernel/elfcorehdr.c, and build it when CONFIG_VMCORE_INFO is ebabled. With this, FA_DUMP doesn't need to depend on CRASH_DUMP.
---
arch/powerpc/Kconfig | 1 -
kernel/Makefile | 3 +--
kernel/{crash_dump.c => elfcorehdr.c} | 0
kernel/kexec_internal.h | 2 ++
4 files changed, 3 insertions(+), 3 deletions(-)
rename kernel/{crash_dump.c => elfcorehdr.c} (100%)arch/powerpc/Kconfig +0 -1
@@ -692,7 +692,6 @@ config FA_DUMP depends on PPC64 && (PPC_RTAS || PPC_POWERNV) select VMCORE_INFO select CRASH_RESERVE - select CRASH_DUMP help A robust mechanism to get reliable kernel crash dump with assistance from firmware. This approach does not use kexec,
kernel/Makefile +1 -2
@@ -68,7 +68,7 @@ obj-$(CONFIG_MODULE_SIG_FORMAT) += module_signature.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o -obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o +obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o elfcorehdr.o obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o obj-$(CONFIG_KEXEC_CORE) += kexec_core.o crash_core.o obj-$(CONFIG_KEXEC) += kexec.o
@@ -121,7 +121,6 @@ obj-$(CONFIG_PERF_EVENTS) += events/ obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o obj-$(CONFIG_PADATA) += padata.o -obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o obj-$(CONFIG_TORTURE_TEST) += torture.o
kernel/elfcorehdr.c renamed from kernel/crash_dump.c +0 -0
kernel/kexec_internal.h +2 -0
@@ -4,6 +4,8 @@#include <linux/kexec.h> +struct kexec_segment ; +struct kimage *do_kimage_alloc_init (void );int sanity_check_segment_list (struct kimage *image);void kimage_free_page_list (struct list_head *list);
Signature · 1 line
2.41.0
PATCH v2 4/14 crash: split crash dumping code out from kexec_core.c
In reply to Baoquan HeCurrently, KEXEC_CORE select CRASH_CORE automatically because crash codes need be built in to avoid compiling error when building kexec code even though the crash dumping functionality is not enabled. E.g
--------------------CONFIG_CRASH_CORE=yCONFIG_KEXEC_CORE=yCONFIG_KEXEC=yCONFIG_KEXEC_FILE=y
---------------------
After splitting out crashkernel reservation code and vmcoreinfo exporting code, there's only crash related code left in kernel/crash_core.c. Now move crash related codes from kexec_core.c to crash_core.c and only build it in when CONFIG_CRASH_DUMP=y.
And also wrap up crash codes inside CONFIG_CRASH_DUMP ifdeffery scope, or replace inappropriate CONFIG_KEXEC_CORE ifdef with CONFIG_CRASH_DUMP ifdef in generic kernel files.
With these changes, crash_core codes are abstracted from kexec codes and can be disabled at all if only kexec reboot feature is wanted.
--- drivers/base/cpu.c | 6 +- include/linux/crash_core.h | 61 +++++++++ include/linux/kexec.h | 45 +------ init/initramfs.c | 2 +- kernel/Makefile | 3 +- kernel/crash_core.c | 256 +++++++++++++++++++++++++++++++++++++ kernel/kexec.c | 11 +- kernel/kexec_core.c | 250 ++---------------------------------- kernel/kexec_file.c | 13 +- kernel/ksysfs.c | 4 + 10 files changed, 359 insertions(+), 292 deletions(-)
drivers/base/cpu.c +3 -3
@@ -144,7 +144,7 @@ static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store);#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ #endif /* CONFIG_HOTPLUG_CPU */ -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP #include <linux/kexec.h> static ssize_t crash_notes_show(struct device *dev,
@@ -189,14 +189,14 @@ static const struct attribute_group crash_note_cpu_attr_group = {#endif static const struct attribute_group *common_cpu_attr_groups[] = { -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP &crash_note_cpu_attr_group, #endifNULL };static const struct attribute_group *hotplugable_cpu_attr_groups[] = { -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP &crash_note_cpu_attr_group, #endifNULL
include/linux/crash_core.h +61 -0
71 lines not on this page · raw message
include/linux/kexec.h +1 -44
75 lines not on this page · raw message
init/initramfs.c +1 -1
@@ -642,7 +642,7 @@ void __weak __init free_initrd_mem(unsigned long start, unsigned long end) "initrd"); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_RESERVE static bool __init kexec_free_initrd (void ) {unsigned long crashk_start = (unsigned long )__va (crashk_res.start);
kernel/Makefile +2 -1
@@ -70,7 +70,8 @@ obj-$(CONFIG_KALLSYMS_SELFTEST) += kallsyms_selftest.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o elfcorehdr.o obj-$(CONFIG_CRASH_RESERVE) += crash_reserve.o -obj-$(CONFIG_KEXEC_CORE) += kexec_core.o crash_core.o +obj-$(CONFIG_KEXEC_CORE) += kexec_core.o +obj-$(CONFIG_CRASH_DUMP) += crash_core.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC_FILE) += kexec_file.o obj-$(CONFIG_KEXEC_ELF) += kexec_elf.o
kernel/crash_core.c +256 -0
283 lines not on this page · raw message
kernel/kexec.c +9 -2
@@ -28,12 +28,14 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,struct kimage *image;bool kexec_on_panic = flags &KEXEC_ON_CRASH ; +#ifdef CONFIG_CRASH_DUMP if (kexec_on_panic) {/* Verify we have a valid entry point */ if ((entry <phys_to_boot_phys (crashk_res.start)) || (entry >phys_to_boot_phys (crashk_res.end)))return -EADDRNOTAVAIL ; } +#endif /* Allocate and initialize a controlling structure */ image =do_kimage_alloc_init ();
@@ -44,11 +46,13 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, image->nr_segments = nr_segments;memcpy (image->segment, segments, nr_segments *sizeof (*segments)); +#ifdef CONFIG_CRASH_DUMP if (kexec_on_panic) {/* Enable special crash kernel control page alloc policy. */ image->control_page = crashk_res.start; image->type =KEXEC_TYPE_CRASH ; } +#endif ret =sanity_check_segment_list (image);if (ret)
@@ -99,13 +103,14 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,if (!kexec_trylock ())return -EBUSY ; +#ifdef CONFIG_CRASH_DUMP if (flags &KEXEC_ON_CRASH ) { dest_image = &kexec_crash_image;if (kexec_crash_image)arch_kexec_unprotect_crashkres (); - }else { + } else +#endif dest_image = &kexec_image; - }if (nr_segments ==0 ) {/* Uninstall image */
@@ -162,8 +167,10 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, image =xchg (dest_image, image); out: +#ifdef CONFIG_CRASH_DUMP if ((flags &KEXEC_ON_CRASH ) && kexec_crash_image)arch_kexec_protect_crashkres (); +#endif kimage_free (image); out_unlock:
kernel/kexec_core.c +12 -238
331 lines not on this page · raw message
kernel/kexec_file.c +10 -3
@@ -285,11 +285,13 @@ kimage_file_alloc_init(struct kimage **rimage, int kernel_fd, kexec_file_dbg_print = !!(flags &KEXEC_FILE_DEBUG ); image->file_mode =1 ; +#ifdef CONFIG_CRASH_DUMP if (kexec_on_panic) {/* Enable special crash kernel control page alloc policy. */ image->control_page = crashk_res.start; image->type =KEXEC_TYPE_CRASH ; } +#endif ret =kimage_file_prepare_segments (image, kernel_fd, initrd_fd, cmdline_ptr, cmdline_len, flags);
@@ -349,13 +351,14 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,if (!kexec_trylock ())return -EBUSY ; +#ifdef CONFIG_CRASH_DUMP if (image_type ==KEXEC_TYPE_CRASH ) { dest_image = &kexec_crash_image;if (kexec_crash_image)arch_kexec_unprotect_crashkres (); - }else { + } else +#endif dest_image = &kexec_image; - }if (flags &KEXEC_FILE_UNLOAD ) goto exchange;
@@ -419,8 +422,10 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, exchange: image =xchg (dest_image, image); out: +#ifdef CONFIG_CRASH_DUMP if ((flags &KEXEC_FILE_ON_CRASH ) && kexec_crash_image)arch_kexec_protect_crashkres (); +#endif kexec_unlock ();kimage_free (image);
@@ -595,12 +600,14 @@ static int kexec_walk_memblock(struct kexec_buf *kbuf,static int kexec_walk_resources (struct kexec_buf *kbuf,int (*func)(struct resource *,void *)) { +#ifdef CONFIG_CRASH_DUMP if (kbuf->image->type ==KEXEC_TYPE_CRASH )return walk_iomem_res_desc (crashk_res.desc,IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , crashk_res.start, crashk_res.end, kbuf, func); -else if (kbuf->top_down) +#endif +if (kbuf->top_down)return walk_system_ram_res_rev (0 ,ULONG_MAX , kbuf, func);else return walk_system_ram_res (0 ,ULONG_MAX , kbuf, func);
kernel/ksysfs.c +4 -0
@@ -120,6 +120,7 @@ static ssize_t kexec_loaded_show(struct kobject *kobj, }KERNEL_ATTR_RO (kexec_loaded); +#ifdef CONFIG_CRASH_DUMP static ssize_t kexec_crash_loaded_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) {
@@ -152,6 +153,7 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj, }KERNEL_ATTR_RW (kexec_crash_size); +#endif /* CONFIG_CRASH_DUMP*/ #endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_VMCORE_INFO
@@ -262,9 +264,11 @@ static struct attribute * kernel_attrs[] = {#endif #ifdef CONFIG_KEXEC_CORE &kexec_loaded_attr.attr, +#ifdef CONFIG_CRASH_DUMP &kexec_crash_loaded_attr.attr, &kexec_crash_size_attr.attr, #endif +#endif #ifdef CONFIG_VMCORE_INFO &vmcoreinfo_attr.attr, #ifdef CONFIG_CRASH_HOTPLUG
Signature · 1 line
2.41.0
PATCH v2 5/14 crash: clean up kdump related config items
In reply to Baoquan HeBy splitting CRASH_RESERVE and VMCORE_INFO out from CRASH_CORE, cleaning up the dependency of FA_DMUMP on CRASH_DUMP, and moving crash codes from kexec_core.c to crash_core.c, now we can rearrange CRASH_DUMP to depend on KEXEC_CORE, and make CRASH_DUMP select CRASH_RESERVE and VMCORE_INFO.
KEXEC_CORE won't select CRASH_RESERVE and VMCORE_INFO any more because KEXEC_CORE enables codes which allocate control pages, copy kexec/kdump segments, and prepare for switching. These codes are shared by both kexec reboot and crash dumping.
Doing this makes codes and the corresponding config items more logical (the right item depends on or is selected by the left item).
PROC_KCORE -----------> VMCORE_INFO
|----------> VMCORE_INFO
FA_DUMP----|
|----------> CRASH_RESERVE ---->VMCORE_INFO
/
|---->CRASH_RESERVE
KEXEC --| /|
|--> KEXEC_CORE--> CRASH_DUMP-->/-|---->PROC_VMCORE
KEXEC_FILE --| \ |
\---->CRASH_HOTPLUGKEXEC --|
|--> KEXEC_CORE--> kexec reboot
KEXEC_FILE --|--- kernel/Kconfig.kexec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/Kconfig.kexec +4 -3
@@ -9,8 +9,6 @@ config VMCORE_INFO bool config KEXEC_CORE - select VMCORE_INFO - select CRASH_RESERVE bool config KEXEC_ELF
@@ -99,8 +97,11 @@ config KEXEC_JUMP config CRASH_DUMP bool "kernel crash dumps" + default y depends on ARCH_SUPPORTS_CRASH_DUMP - select KEXEC_CORE + depends on KEXEC_CORE + select VMCORE_INFO + select CRASH_RESERVE help Generate crash dump after being started by kexec. This should be normally only set in special crash dump kernels
Signature · 1 line
2.41.0
PATCH v2 6/14 x86, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on x86 with some adjustments.
Here, also change some ifdefs or IS_ENABLED() check to more appropriate ones, e,g
- #ifdef CONFIG_KEXEC_CORE -> #ifdef CONFIG_CRASH_DUMP
- (!IS_ENABLED(CONFIG_KEXEC_CORE)) - > (!IS_ENABLED(CONFIG_CRASH_RESERVE))
--- arch/x86/kernel/Makefile | 4 ++-- arch/x86/kernel/cpu/mshyperv.c | 4 ++++ arch/x86/kernel/kexec-bzimage64.c | 4 ++++ arch/x86/kernel/kvm.c | 4 ++-- arch/x86/kernel/machine_kexec_64.c | 3 +++ arch/x86/kernel/reboot.c | 2 +- arch/x86/kernel/setup.c | 2 +- arch/x86/kernel/smp.c | 2 +- arch/x86/xen/enlighten_hvm.c | 4 ++++ 9 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/kernel/Makefile +2 -2
@@ -100,9 +100,9 @@ obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_RETHOOK) += rethook.o obj-$(CONFIG_VMCORE_INFO) += vmcore_info_$(BITS).o obj-$(CONFIG_KEXEC_CORE) += machine_kexec_$(BITS).o -obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o crash.o +obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.o -obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o +obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o crash.o obj-y += kprobes/ obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_X86_32) += doublefault_32.o
arch/x86/kernel/cpu/mshyperv.c +4 -0
@@ -210,6 +210,7 @@ static void hv_machine_shutdown(void)hyperv_cleanup (); } +#ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown (struct pt_regs *regs) {if (hv_crash_handler)
@@ -221,6 +222,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_HYPERV */
@@ -497,7 +499,9 @@ static void __init ms_hyperv_init_platform(void)#if IS_ENABLED (CONFIG_HYPERV ) && defined(CONFIG_KEXEC_CORE ) machine_ops.shutdown = hv_machine_shutdown; +#ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = hv_machine_crash_shutdown; +#endif #endif if (ms_hyperv.features &HV_ACCESS_TSC_INVARIANT ) {/*
arch/x86/kernel/kexec-bzimage64.c +4 -0
@@ -263,11 +263,13 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,memset (¶ms->hd0_info,0 ,sizeof (params->hd0_info));memset (¶ms->hd1_info,0 ,sizeof (params->hd1_info)); +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) { ret =crash_setup_memmap_entries (image, params);if (ret)return ret; } else +#endif setup_e820_entries (params); nr_e820_entries = params->e820_entries;
@@ -433,12 +435,14 @@ static void *bzImage64_load(struct kimage *image, char *kernel,return ERR_PTR (-EINVAL ); } +#ifdef CONFIG_CRASH_DUMP /* Allocate and load backup region */ if (image->type ==KEXEC_TYPE_CRASH ) { ret =crash_load_segments (image);if (ret)return ERR_PTR (ret); } +#endif /* * Load purgatory. For 64bit entry point, purgatory code can be
arch/x86/kernel/kvm.c +2 -2
@@ -769,7 +769,7 @@ static struct notifier_block kvm_pv_reboot_nb = {* won't be valid. In cases like kexec, in which you install a new kernel, this * means a random memory location will be kept being written. */ -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP static void kvm_crash_shutdown (struct pt_regs *regs) {kvm_guest_cpu_offline (true);
@@ -852,7 +852,7 @@ static void __init kvm_guest_init(void)kvm_guest_cpu_init ();#endif -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = kvm_crash_shutdown;#endif
arch/x86/kernel/machine_kexec_64.c +3 -0
@@ -508,6 +508,8 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) }#endif /* CONFIG_KEXEC_FILE */ +#ifdef CONFIG_CRASH_DUMP +static int kexec_mark_range (unsigned long start,unsigned long end,bool protect) {
@@ -552,6 +554,7 @@ void arch_kexec_unprotect_crashkres(void) {kexec_mark_crashkres (false); } +#endif /* * During a traditional boot under SME, SME will encrypt the kernel,
arch/x86/kernel/reboot.c +1 -1
@@ -796,7 +796,7 @@ struct machine_ops machine_ops __ro_after_init = { .emergency_restart = native_machine_emergency_restart, .restart = native_machine_restart, .halt = native_machine_halt, -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP .crash_shutdown = native_machine_crash_shutdown,#endif };
arch/x86/kernel/setup.c +1 -1
@@ -471,7 +471,7 @@ static void __init arch_reserve_crashkernel(void)bool high = false;int ret; -if (!IS_ENABLED (CONFIG_KEXEC_CORE )) +if (!IS_ENABLED (CONFIG_CRASH_RESERVE ))return ; ret = parse_crashkernel(cmdline, memblock_phys_mem_size(),
arch/x86/kernel/smp.c +1 -1
@@ -282,7 +282,7 @@ struct smp_ops smp_ops = { .smp_cpus_done = native_smp_cpus_done, .stop_other_cpus = native_stop_other_cpus, -#if defined(CONFIG_KEXEC_CORE) +#if defined(CONFIG_CRASH_DUMP) .crash_stop_other_cpus = kdump_nmi_shootdown_cpus, #endif .smp_send_reschedule = native_smp_send_reschedule,
arch/x86/xen/enlighten_hvm.c +4 -0
@@ -149,12 +149,14 @@ static void xen_hvm_shutdown(void) xen_reboot(SHUTDOWN_soft_reset); } +#ifdef CONFIG_CRASH_DUMP static void xen_hvm_crash_shutdown (struct pt_regs *regs) {native_machine_crash_shutdown (regs);xen_reboot (SHUTDOWN_soft_reset); }#endif +#endif static int xen_cpu_up_prepare_hvm (unsigned int cpu) {
@@ -236,8 +238,10 @@ static void __init xen_hvm_guest_init(void)#ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; +#ifdef CONFIG_CRASH_DUMP machine_ops.crash_shutdown = xen_hvm_crash_shutdown;#endif +#endif }static __init int xen_parse_nopv (char *arg)
Signature · 1 line
2.41.0
PATCH v2 7/14 arm64, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on arm64 with some adjustments.
Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery.
--- arch/arm64/include/asm/kexec.h | 2 +- arch/arm64/kernel/machine_kexec.c | 2 +- arch/arm64/kernel/machine_kexec_file.c | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-)
arch/arm64/include/asm/kexec.h +1 -1
@@ -80,7 +80,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs, } } -#if defined(CONFIG_KEXEC_CORE ) && defined(CONFIG_HIBERNATION ) +#if defined(CONFIG_CRASH_DUMP ) && defined(CONFIG_HIBERNATION )extern bool crash_is_nosave (unsigned long pfn);extern void crash_prepare_suspend (void );extern void crash_post_resume (void );
arch/arm64/kernel/machine_kexec.c +1 -1
@@ -255,7 +255,7 @@ void machine_crash_shutdown(struct pt_regs *regs)pr_info ("Starting crashdump kernel...\n" ); } -#ifdef CONFIG_HIBERNATION +#if defined(CONFIG_CRASH_DUMP ) && defined(CONFIG_HIBERNATION )/* * To preserve the crash dump kernel image, the relevant memory segments * should be mapped again around the hibernation.
arch/arm64/kernel/machine_kexec_file.c +8 -2
@@ -39,6 +39,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } +#ifdef CONFIG_CRASH_DUMP static int prepare_elf_headers (void **addr,unsigned long *sz) {struct crash_mem *cmem;
@@ -80,6 +81,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)kfree (cmem); return ret; } +#endif /* * Tries to add the initrd and DTB to the image. If it is not possible to find
@@ -93,8 +95,8 @@ int load_other_segments(struct kimage *image, char *cmdline) {struct kexec_buf kbuf; -void *headers, *dtb =NULL ; -unsigned long headers_sz, initrd_load_addr =0 , dtb_len, +void *dtb =NULL ; +unsigned long initrd_load_addr =0 , dtb_len, orig_segments = image->nr_segments;int ret =0 ;
@@ -102,7 +104,10 @@ int load_other_segments(struct kimage *image,/* not allocate anything below the kernel */ kbuf.buf_min = kernel_load_addr + kernel_size; +#ifdef CONFIG_CRASH_DUMP /* load elf core header */ +void *headers; +unsigned long headers_sz;if (image->type ==KEXEC_TYPE_CRASH ) { ret =prepare_elf_headers (&headers, &headers_sz);if (ret) {
@@ -130,6 +135,7 @@ int load_other_segments(struct kimage *image,kexec_dprintk ("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , image->elf_load_addr, kbuf.bufsz, kbuf.memsz); } +#endif /* load initrd */ if (initrd) {
Signature · 1 line
2.41.0
PATCH v2 8/14 ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
In reply to Baoquan HeIn PowerPC, the crash dumping and kexec reboot share code in arch_kexec_locate_mem_hole(), in which struct crash_mem is used.
Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.
--- arch/powerpc/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/Kconfig +5 -0
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE config ARCH_SUPPORTS_KEXEC def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP) +config ARCH_SELECTS_KEXEC + def_bool y + select CRASH_DUMP + config ARCH_SUPPORTS_KEXEC_FILE def_bool PPC64
@@ -618,6 +622,7 @@ config ARCH_SELECTS_KEXEC_FILE def_bool y depends on KEXEC_FILE select KEXEC_ELF + select CRASH_DUMP select HAVE_IMA_KEXEC if IMA config PPC64_BIG_ENDIAN_ELF_ABI_V2
Signature · 1 line
2.41.0
PATCH v2 9/14 s390, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on s390 with some adjustments.
Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery.
--- arch/s390/kernel/kexec_elf.c | 2 ++ arch/s390/kernel/kexec_image.c | 2 ++ arch/s390/kernel/machine_kexec_file.c | 10 ++++++++++ 3 files changed, 14 insertions(+)
arch/s390/kernel/kexec_elf.c +2 -0
@@ -40,8 +40,10 @@ static int kexec_file_add_kernel_elf(struct kimage *image, buf.bufsz = phdr->p_filesz; buf.mem =ALIGN (phdr->p_paddr, phdr->p_align); +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) buf.mem += crashk_res.start; +#endif buf.memsz = phdr->p_memsz; data->memsz =ALIGN (data->memsz, phdr->p_align) + buf.memsz;
arch/s390/kernel/kexec_image.c +2 -0
@@ -24,8 +24,10 @@ static int kexec_file_add_kernel_image(struct kimage *image, buf.bufsz = image->kernel_buf_len; buf.mem =0 ; +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) buf.mem += crashk_res.start; +#endif buf.memsz = buf.bufsz; data->kernel_buf = image->kernel_buf;
arch/s390/kernel/machine_kexec_file.c +10 -0
@@ -105,6 +105,7 @@ static int kexec_file_update_purgatory(struct kimage *image,if (ret)return ret; +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) {u64 crash_size;
@@ -121,6 +122,7 @@ static int kexec_file_update_purgatory(struct kimage *image,sizeof (crash_size), false); } +#endif return ret; }
@@ -134,8 +136,10 @@ static int kexec_file_add_purgatory(struct kimage *image, data->memsz =ALIGN (data->memsz,PAGE_SIZE ); buf.mem = data->memsz; +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) buf.mem += crashk_res.start; +#endif ret =kexec_load_purgatory (image, &buf);if (ret)
@@ -158,8 +162,10 @@ static int kexec_file_add_initrd(struct kimage *image, data->memsz =ALIGN (data->memsz,PAGE_SIZE ); buf.mem = data->memsz; +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) buf.mem += crashk_res.start; +#endif buf.memsz = buf.bufsz; data->parm->initrd_start = data->memsz;
@@ -223,8 +229,10 @@ static int kexec_file_add_ipl_report(struct kimage *image, data->kernel_buf + offsetof(struct lowcore , ipl_parmblock_ptr); *lc_ipl_parmblock_ptr = (__u32 )buf.mem; +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) buf.mem += crashk_res.start; +#endif ret =kexec_add_buffer (&buf); out:
@@ -268,10 +276,12 @@ void *kexec_file_add_components(struct kimage *image,memcpy (data.parm->command_line, image->cmdline_buf, image->cmdline_buf_len); +#ifdef CONFIG_CRASH_DUMP if (image->type ==KEXEC_TYPE_CRASH ) { data.parm->oldmem_base = crashk_res.start; data.parm->oldmem_size = crashk_res.end - crashk_res.start +1 ; } +#endif if (image->initrd_buf) { ret =kexec_file_add_initrd (image, &data);
Signature · 1 line
2.41.0
PATCH v2 10/14 sh, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on SuperH with some adjustments.
Here wrap up crashkernel reservation code inside CONFIG_CRASH_RESERVE ifdeffery scope.
--- arch/sh/kernel/machine_kexec.c | 3 +++ arch/sh/kernel/setup.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
arch/sh/kernel/machine_kexec.c +3 -0
@@ -153,6 +153,9 @@ void __init reserve_crashkernel(void)unsigned long long crash_size, crash_base;int ret; +if (!IS_ENABLED (CONFIG_CRASH_RESERVE )) +return ; + ret =parse_crashkernel (boot_command_line,memblock_phys_mem_size (), &crash_size, &crash_base,NULL ,NULL );if (ret ==0 && crash_size >0 ) {
arch/sh/kernel/setup.c +1 -1
@@ -220,7 +220,7 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,request_resource (res, &code_resource);request_resource (res, &data_resource);request_resource (res, &bss_resource); -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_RESERVE request_resource (res, &crashk_res);#endif
Signature · 1 line
2.41.0
PATCH v2 11/14 arm, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on arm with some adjustments.
Here use IS_ENABLED(CONFIG_CRASH_RESERVE) check to decide if compiling in the crashkernel reservation code.
--- arch/arm/kernel/setup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/kernel/setup.c +3 -4
@@ -979,7 +979,6 @@ static int __init init_machine_late(void) }late_initcall (init_machine_late); -#ifdef CONFIG_KEXEC /* * The crash region must be aligned to 128MB to avoid * zImage relocating below the reserved region.
@@ -1007,6 +1006,9 @@ static void __init reserve_crashkernel(void)unsigned long long total_mem;int ret; +if (!IS_ENABLED (CONFIG_CRASH_RESERVE )) +return ; + total_mem =get_total_mem (); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base,
@@ -1064,9 +1066,6 @@ static void __init reserve_crashkernel(void)insert_resource (&iomem_resource, &crashk_boot_res); } } -#else -static inline void reserve_crashkernel (void ) {} -#endif /* CONFIG_KEXEC */ void __init hyp_mode_check (void ) {
Signature · 1 line
2.41.0
kernel test robot
build botRe: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs
kernel test robot noticed the following build errors:
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[cannot apply to tip/x86/core arm64/for-next/core powerpc/next powerpc/fixes v6.7 next-20240119] [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/kexec-split-crashkernel-reservation-code-out-from-crash_core-c/20240119-225820 base: linus/master patch link: https://lore.kernel.org/r/20240119145241.769622-12-bhe%40redhat.com patch subject: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs config: arm-randconfig-001-20240120 (https://download.01.org/0day-ci/archive/20240120/[email protected]/config) compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project d92ce344bf641e6bb025b41b3f1a77dd25e2b3e9) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240120/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> arch/arm/kernel/setup.c:1036:49: error: use of undeclared identifier 'SECTION_SIZE'
1036 | start = memblock_phys_alloc_range(crash_size, SECTION_SIZE,
| ^
1 error generated.
vim +/SECTION_SIZE +1036 arch/arm/kernel/setup.c
3c57fb43c8fcbe Mika Westerberg 2010-05-10 995
3c57fb43c8fcbe Mika Westerberg 2010-05-10 996 /**
3c57fb43c8fcbe Mika Westerberg 2010-05-10 997 * reserve_crashkernel() - reserves memory are for crash kernel
3c57fb43c8fcbe Mika Westerberg 2010-05-10 998 *
3c57fb43c8fcbe Mika Westerberg 2010-05-10 999 * This function reserves memory area given in "crashkernel=" kernel command
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1000 * line parameter. The memory reserved is used by a dump capture kernel when
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1001 * primary kernel is crashing.
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1002 */
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1003 static void __init reserve_crashkernel(void)
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1004 {
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1005 unsigned long long crash_size, crash_base;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1006 unsigned long long total_mem;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1007 int ret;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1008
8f460484669cba Baoquan He 2024-01-19 1009 if (!IS_ENABLED(CONFIG_CRASH_RESERVE))
8f460484669cba Baoquan He 2024-01-19 1010 return;
8f460484669cba Baoquan He 2024-01-19 1011
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1012 total_mem = get_total_mem();
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1013 ret = parse_crashkernel(boot_command_line, total_mem,
a9e1a3d84e4a0e Baoquan He 2023-09-14 1014 &crash_size, &crash_base,
a9e1a3d84e4a0e Baoquan He 2023-09-14 1015 NULL, NULL);
9d17f337230642 Austin Kim 2022-04-01 1016 /* invalid value specified or crashkernel=0 */
9d17f337230642 Austin Kim 2022-04-01 1017 if (ret || !crash_size)
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1018 return;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1019
61603016e2122b Russell King 2016-03-14 1020 if (crash_base <= 0) {
d0506a2395eb07 Russell King 2016-04-01 1021 unsigned long long crash_max = idmap_to_phys((u32)~0);
67556d7a851c20 Russell King 2017-07-19 1022 unsigned long long lowmem_max = __pa(high_memory - 1) + 1;
67556d7a851c20 Russell King 2017-07-19 1023 if (crash_max > lowmem_max)
67556d7a851c20 Russell King 2017-07-19 1024 crash_max = lowmem_max;
a7259df7670240 Mike Rapoport 2021-09-02 1025
a7259df7670240 Mike Rapoport 2021-09-02 1026 crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN,
a7259df7670240 Mike Rapoport 2021-09-02 1027 CRASH_ALIGN, crash_max);
61603016e2122b Russell King 2016-03-14 1028 if (!crash_base) {
61603016e2122b Russell King 2016-03-14 1029 pr_err("crashkernel reservation failed - No suitable area found.\n");
61603016e2122b Russell King 2016-03-14 1030 return;
61603016e2122b Russell King 2016-03-14 1031 }
61603016e2122b Russell King 2016-03-14 1032 } else {
a7259df7670240 Mike Rapoport 2021-09-02 1033 unsigned long long crash_max = crash_base + crash_size;
61603016e2122b Russell King 2016-03-14 1034 unsigned long long start;
61603016e2122b Russell King 2016-03-14 1035
a7259df7670240 Mike Rapoport 2021-09-02 @1036 start = memblock_phys_alloc_range(crash_size, SECTION_SIZE,
a7259df7670240 Mike Rapoport 2021-09-02 1037 crash_base, crash_max);
a7259df7670240 Mike Rapoport 2021-09-02 1038 if (!start) {
61603016e2122b Russell King 2016-03-14 1039 pr_err("crashkernel reservation failed - memory is in use.\n");
61603016e2122b Russell King 2016-03-14 1040 return;
61603016e2122b Russell King 2016-03-14 1041 }
61603016e2122b Russell King 2016-03-14 1042 }
61603016e2122b Russell King 2016-03-14 1043
1b0f6681fcbc0e Olof Johansson 2013-12-05 1044 pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n",
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1045 (unsigned long)(crash_size >> 20),
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1046 (unsigned long)(crash_base >> 20),
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1047 (unsigned long)(total_mem >> 20));
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1048
f7f0b7dc720f81 Russell King 2016-08-02 1049 /* The crashk resource must always be located in normal mem */
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1050 crashk_res.start = crash_base;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1051 crashk_res.end = crash_base + crash_size - 1;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1052 insert_resource(&iomem_resource, &crashk_res);
f7f0b7dc720f81 Russell King 2016-08-02 1053
f7f0b7dc720f81 Russell King 2016-08-02 1054 if (arm_has_idmap_alias()) {
f7f0b7dc720f81 Russell King 2016-08-02 1055 /*
f7f0b7dc720f81 Russell King 2016-08-02 1056 * If we have a special RAM alias for use at boot, we
f7f0b7dc720f81 Russell King 2016-08-02 1057 * need to advertise to kexec tools where the alias is.
f7f0b7dc720f81 Russell King 2016-08-02 1058 */
f7f0b7dc720f81 Russell King 2016-08-02 1059 static struct resource crashk_boot_res = {
f7f0b7dc720f81 Russell King 2016-08-02 1060 .name = "Crash kernel (boot alias)",
f7f0b7dc720f81 Russell King 2016-08-02 1061 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
f7f0b7dc720f81 Russell King 2016-08-02 1062 };
f7f0b7dc720f81 Russell King 2016-08-02 1063
f7f0b7dc720f81 Russell King 2016-08-02 1064 crashk_boot_res.start = phys_to_idmap(crash_base);
f7f0b7dc720f81 Russell King 2016-08-02 1065 crashk_boot_res.end = crashk_boot_res.start + crash_size - 1;
f7f0b7dc720f81 Russell King 2016-08-02 1066 insert_resource(&iomem_resource, &crashk_boot_res);
f7f0b7dc720f81 Russell King 2016-08-02 1067 }
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1068 }
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1069 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs
Quoted 18 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[cannot apply to tip/x86/core arm64/for-next/core powerpc/next powerpc/fixes v6.7 next-20240119] [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/kexec-split-crashkernel-reservation-code-out-from-crash_core-c/20240119-225820 base: linus/master patch link: https://lore.kernel.org/r/20240119145241.769622-12-bhe%40redhat.com patch subject: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs config: arm-randconfig-001-20240120 (https://download.01.org/0day-ci/archive/20240120/[email protected]/config) compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project d92ce344bf641e6bb025b41b3f1a77dd25e2b3e9) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240120/[email protected]/reproduce)
Quoted 4 lines
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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Thanks for reporting this, I can reproduce it.
In the provided config, it has:
# CONFIG_MMU is not set
and all kexec/kdump related config items are unset.
The if (!IS_ENABLED(CONFIG_CRASH_RESERVE)) checking will cause funciton reserve_crashkernel() is compiled, but not built in. With CONFIG_MMU=no, SECTION_SIZE is undefined on arm. So fix it by wrapping up reserve_crashkernel() inside CONFIG_CRASH_RESERVE ifdeffery scope.
From d580b65f6aa042233e228aab45609c3de88ab29e Mon Sep 17 00:00:00 2001
From: Baoquan He <[email protected]>
Date: Mon, 15 Jan 2024 22:32:19 -0500
Subject: [PATCH] arm, crash: wrap crash dumping code into crash related ifdefs
Content-type: text/plain
Now crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on arm with some adjustments.
Here use CONFIG_CRASH_RESERVE ifdef to replace CONFIG_KEXEC ifdef.
--- arch/arm/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/setup.c +2 -2
@@ -979,7 +979,7 @@ static int __init init_machine_late(void) }late_initcall (init_machine_late); -#ifdef CONFIG_KEXEC +#ifdef CONFIG_CRASH_RESERVE /* * The crash region must be aligned to 128MB to avoid * zImage relocating below the reserved region.
@@ -1066,7 +1066,7 @@ static void __init reserve_crashkernel(void) }#else static inline void reserve_crashkernel (void ) {} -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_CRASH_RESERVE*/ void __init hyp_mode_check (void ) {
Signature · 1 line
2.41.0
kernel test robot
build botRe: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan Hekernel test robot noticed the following build errors:
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[cannot apply to tip/x86/core arm64/for-next/core powerpc/next powerpc/fixes v6.7 next-20240119] [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/kexec-split-crashkernel-reservation-code-out-from-crash_core-c/20240119-225820 base: linus/master patch link: https://lore.kernel.org/r/20240119145241.769622-12-bhe%40redhat.com patch subject: [PATCH v2 11/14] arm, crash: wrap crash dumping code into crash related ifdefs config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20240120/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240120/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
arch/arm/kernel/setup.c: In function 'reserve_crashkernel':
>> arch/arm/kernel/setup.c:1036:63: error: 'SECTION_SIZE' undeclared (first use in this function); did you mean 'SECTIONS_SHIFT'?
1036 | start = memblock_phys_alloc_range(crash_size, SECTION_SIZE,
| ^~~~~~~~~~~~
| SECTIONS_SHIFT arch/arm/kernel/setup.c:1036:63: note: each undeclared identifier is reported only once for each function it appears in In file included from arch/arm/include/asm/efi.h:12,
from arch/arm/kernel/setup.c:37:
arch/arm/include/asm/fixmap.h: At top level:
arch/arm/include/asm/fixmap.h:39:35: warning: '__end_of_fixed_addresses' defined but not used [-Wunused-const-variable=]
39 | static const enum fixed_addresses __end_of_fixed_addresses =
| ^~~~~~~~~~~~~~~~~~~~~~~~
vim +1036 arch/arm/kernel/setup.c
3c57fb43c8fcbe Mika Westerberg 2010-05-10 995
3c57fb43c8fcbe Mika Westerberg 2010-05-10 996 /**
3c57fb43c8fcbe Mika Westerberg 2010-05-10 997 * reserve_crashkernel() - reserves memory are for crash kernel
3c57fb43c8fcbe Mika Westerberg 2010-05-10 998 *
3c57fb43c8fcbe Mika Westerberg 2010-05-10 999 * This function reserves memory area given in "crashkernel=" kernel command
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1000 * line parameter. The memory reserved is used by a dump capture kernel when
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1001 * primary kernel is crashing.
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1002 */
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1003 static void __init reserve_crashkernel(void)
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1004 {
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1005 unsigned long long crash_size, crash_base;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1006 unsigned long long total_mem;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1007 int ret;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1008
8f460484669cba Baoquan He 2024-01-19 1009 if (!IS_ENABLED(CONFIG_CRASH_RESERVE))
8f460484669cba Baoquan He 2024-01-19 1010 return;
8f460484669cba Baoquan He 2024-01-19 1011
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1012 total_mem = get_total_mem();
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1013 ret = parse_crashkernel(boot_command_line, total_mem,
a9e1a3d84e4a0e Baoquan He 2023-09-14 1014 &crash_size, &crash_base,
a9e1a3d84e4a0e Baoquan He 2023-09-14 1015 NULL, NULL);
9d17f337230642 Austin Kim 2022-04-01 1016 /* invalid value specified or crashkernel=0 */
9d17f337230642 Austin Kim 2022-04-01 1017 if (ret || !crash_size)
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1018 return;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1019
61603016e2122b Russell King 2016-03-14 1020 if (crash_base <= 0) {
d0506a2395eb07 Russell King 2016-04-01 1021 unsigned long long crash_max = idmap_to_phys((u32)~0);
67556d7a851c20 Russell King 2017-07-19 1022 unsigned long long lowmem_max = __pa(high_memory - 1) + 1;
67556d7a851c20 Russell King 2017-07-19 1023 if (crash_max > lowmem_max)
67556d7a851c20 Russell King 2017-07-19 1024 crash_max = lowmem_max;
a7259df7670240 Mike Rapoport 2021-09-02 1025
a7259df7670240 Mike Rapoport 2021-09-02 1026 crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN,
a7259df7670240 Mike Rapoport 2021-09-02 1027 CRASH_ALIGN, crash_max);
61603016e2122b Russell King 2016-03-14 1028 if (!crash_base) {
61603016e2122b Russell King 2016-03-14 1029 pr_err("crashkernel reservation failed - No suitable area found.\n");
61603016e2122b Russell King 2016-03-14 1030 return;
61603016e2122b Russell King 2016-03-14 1031 }
61603016e2122b Russell King 2016-03-14 1032 } else {
a7259df7670240 Mike Rapoport 2021-09-02 1033 unsigned long long crash_max = crash_base + crash_size;
61603016e2122b Russell King 2016-03-14 1034 unsigned long long start;
61603016e2122b Russell King 2016-03-14 1035
a7259df7670240 Mike Rapoport 2021-09-02 @1036 start = memblock_phys_alloc_range(crash_size, SECTION_SIZE,
a7259df7670240 Mike Rapoport 2021-09-02 1037 crash_base, crash_max);
a7259df7670240 Mike Rapoport 2021-09-02 1038 if (!start) {
61603016e2122b Russell King 2016-03-14 1039 pr_err("crashkernel reservation failed - memory is in use.\n");
61603016e2122b Russell King 2016-03-14 1040 return;
61603016e2122b Russell King 2016-03-14 1041 }
61603016e2122b Russell King 2016-03-14 1042 }
61603016e2122b Russell King 2016-03-14 1043
1b0f6681fcbc0e Olof Johansson 2013-12-05 1044 pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n",
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1045 (unsigned long)(crash_size >> 20),
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1046 (unsigned long)(crash_base >> 20),
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1047 (unsigned long)(total_mem >> 20));
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1048
f7f0b7dc720f81 Russell King 2016-08-02 1049 /* The crashk resource must always be located in normal mem */
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1050 crashk_res.start = crash_base;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1051 crashk_res.end = crash_base + crash_size - 1;
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1052 insert_resource(&iomem_resource, &crashk_res);
f7f0b7dc720f81 Russell King 2016-08-02 1053
f7f0b7dc720f81 Russell King 2016-08-02 1054 if (arm_has_idmap_alias()) {
f7f0b7dc720f81 Russell King 2016-08-02 1055 /*
f7f0b7dc720f81 Russell King 2016-08-02 1056 * If we have a special RAM alias for use at boot, we
f7f0b7dc720f81 Russell King 2016-08-02 1057 * need to advertise to kexec tools where the alias is.
f7f0b7dc720f81 Russell King 2016-08-02 1058 */
f7f0b7dc720f81 Russell King 2016-08-02 1059 static struct resource crashk_boot_res = {
f7f0b7dc720f81 Russell King 2016-08-02 1060 .name = "Crash kernel (boot alias)",
f7f0b7dc720f81 Russell King 2016-08-02 1061 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
f7f0b7dc720f81 Russell King 2016-08-02 1062 };
f7f0b7dc720f81 Russell King 2016-08-02 1063
f7f0b7dc720f81 Russell King 2016-08-02 1064 crashk_boot_res.start = phys_to_idmap(crash_base);
f7f0b7dc720f81 Russell King 2016-08-02 1065 crashk_boot_res.end = crashk_boot_res.start + crash_size - 1;
f7f0b7dc720f81 Russell King 2016-08-02 1066 insert_resource(&iomem_resource, &crashk_boot_res);
f7f0b7dc720f81 Russell King 2016-08-02 1067 }
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1068 }
3c57fb43c8fcbe Mika Westerberg 2010-05-10 1069 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 12/14 mips, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on mips with some adjustments.
Here use IS_ENABLED(CONFIG_CRASH_RESERVE) check to decide if compiling in the crashkernel reservation code.
--- arch/mips/kernel/setup.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
arch/mips/kernel/setup.c +6 -11
@@ -442,8 +442,6 @@ static void __init mips_reserve_vmcore(void)#endif } -#ifdef CONFIG_KEXEC -/* 64M alignment for crash kernel regions */ #define CRASH_ALIGN SZ_64M#define CRASH_ADDR_MAX SZ_512M
@@ -454,6 +452,9 @@ static void __init mips_parse_crashkernel(void)unsigned long long crash_size, crash_base;int ret; +if (!IS_ENABLED (CONFIG_CRASH_RESERVE )) +return ; + total_mem =memblock_phys_mem_size (); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base,
@@ -489,6 +490,9 @@ static void __init request_crashkernel(struct resource *res) {int ret; +if (!IS_ENABLED (CONFIG_CRASH_RESERVE )) +return ; +if (crashk_res.start == crashk_res.end)return ;
@@ -498,15 +502,6 @@ static void __init request_crashkernel(struct resource *res) (unsigned long )(resource_size (&crashk_res) >>20 ), (unsigned long)(crashk_res.start >> 20)); } -#else /* !defined(CONFIG_KEXEC) */ -static void __init mips_parse_crashkernel (void ) -{ -} - -static void __init request_crashkernel (struct resource *res) -{ -} -#endif /* !defined(CONFIG_KEXEC) */ static void __init check_kernel_sections_mem (void ) {
Signature · 1 line
2.41.0
PATCH v2 13/14 riscv, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on risc-v with some adjustments.
Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery, and use IS_ENABLED(CONFIG_CRASH_RESERVE) check to decide if compiling in the crashkernel reservation code.
--- arch/riscv/kernel/elf_kexec.c | 9 +++++++-- arch/riscv/mm/init.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
arch/riscv/kernel/elf_kexec.c +7 -2
@@ -117,6 +117,7 @@ static int elf_find_pbase(struct kimage *image, unsigned long kernel_len,return ret; } +#ifdef CONFIG_CRASH_DUMP static int get_nr_ram_ranges_callback (struct resource *res,void *arg) {unsigned int *nr_ranges = arg;
@@ -189,6 +190,7 @@ static char *setup_kdump_cmdline(struct kimage *image, char *cmdline, cmdline_ptr[COMMAND_LINE_SIZE -1 ] ='\0' ;return cmdline_ptr; } +#endif static void *elf_kexec_load(struct kimage *image, char *kernel_buf, unsigned long kernel_len, char *initrd,
@@ -196,12 +198,11 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, unsigned long cmdline_len) {int ret; +void *fdt;unsigned long old_kernel_pbase =ULONG_MAX ;unsigned long new_kernel_pbase =0UL ;unsigned long initrd_pbase =0UL ; -unsigned long headers_sz;unsigned long kernel_start; -void *fdt, *headers;struct elfhdr ehdr;struct kexec_buf kbuf;struct kexec_elf_info elf_info;
@@ -227,8 +228,11 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, kbuf.buf_min = new_kernel_pbase + kernel_len; kbuf.buf_max =ULONG_MAX ; +#ifdef CONFIG_CRASH_DUMP /* Add elfcorehdr */ if (image->type ==KEXEC_TYPE_CRASH ) { +void *headers; +unsigned long headers_sz; ret =prepare_elf_headers (&headers, &headers_sz);if (ret) {pr_err ("Preparing elf core header failed\n" );
@@ -264,6 +268,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, } cmdline = modified_cmdline; } +#endif #ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY /* Add purgatory to the image */
arch/riscv/mm/init.c +1 -1
@@ -1354,7 +1354,7 @@ static void __init arch_reserve_crashkernel(void)bool high = false;int ret; -if (!IS_ENABLED (CONFIG_KEXEC_CORE )) +if (!IS_ENABLED (CONFIG_CRASH_RESERVE ))return ; ret = parse_crashkernel(cmdline, memblock_phys_mem_size(),
Signature · 1 line
2.41.0
PATCH v2 14/14 loongarch, crash: wrap crash dumping code into crash related ifdefs
In reply to Baoquan HeNow crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on loongarch with some adjustments.
Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery, and use IS_ENABLED(CONFIG_CRASH_RESERVE) check to decide if compiling in the crashkernel reservation code.
--- arch/loongarch/kernel/setup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/loongarch/kernel/setup.c +4 -3
@@ -258,11 +258,13 @@ static void __init arch_reserve_vmcore(void)static void __init arch_parse_crashkernel (void ) { -#ifdef CONFIG_KEXEC int ret;unsigned long long total_mem;unsigned long long crash_base, crash_size; +if (!IS_ENABLED (CONFIG_CRASH_RESERVE )) +return ; + total_mem =memblock_phys_mem_size (); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base,
@@ -283,7 +285,6 @@ static void __init arch_parse_crashkernel(void) crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size -1 ; -#endif }static void __init fdt_setup (void )
@@ -468,7 +469,7 @@ static void __init resource_init(void)request_resource (res, &bss_resource); } -#ifdef CONFIG_KEXEC +#ifdef CONFIG_CRASH_RESERVE if (crashk_res.start < crashk_res.end) {insert_resource (&iomem_resource, &crashk_res); pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
Signature · 1 line
2.41.0
Hi Baoquan,
Quoted 84 lines · Baoquan He
Motivation:
=============
Previously, LKP reported a building error. When investigating, it can't be resolved reasonablly with the present messy kdump config items.https://lore.kernel.org/oe-kbuild-all/[email protected]/
The kdump (crash dumping) related config items could causes confusions:
Firstly,
---CRASH_COREenables codes including
- crashkernel reservation;
- elfcorehdr updating;
- vmcoreinfo exporting;
- crash hotplug handling;Now fadump of powerpc, kcore dynamic debugging and kdump all selects
CRASH_CORE, while fadump
- fadump needs crashkernel parsing, vmcoreinfo exporting, and accessingglobal variable 'elfcorehdr_addr';- kcore only needs vmcoreinfo exporting;
- kdump needs all of the currentkernel/crash_core.c.So only enabling
PROC_COREorFA_DUMPwill enableCRASH_CORE, this mislead people that we enable crash dumping, actual it's not.Secondly,
---
It's not reasonable to allowKEXEC_COREselectCRASH_CORE.Because
KEXEC_COREenables codes which allocate control pages, copy kexec/kdump segments, and prepare for switching. These codes are shared by both kexec reboot and kdump. We could want kexec reboot, but disable kdump. In that case,CRASH_COREshould not be selected.--------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y---------------------Thirdly,
---
It's not reasonable to allowCRASH_DUMPselectKEXEC_CORE.That could make
KEXEC_CORE,CRASH_DUMPare enabled independently from KEXEC orKEXEC_FILE. However, w/o KEXEC orKEXEC_FILE, theKEXEC_COREcode built in doesn't make any sense because no kernel loading or switching will happen to utilize theKEXEC_COREcode.
---------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
---------------------In this case, what is worse, on arch sh and arm, KEXEC relies on MMU, while
CRASH_DUMPcan still be enabled when !MMU, then compiling error is seen as the lkp test robot reported in above link.------arch/sh/Kconfig------
configARCH_SUPPORTS_KEXEC
def_boolMMUconfig
ARCH_SUPPORTS_CRASH_DUMP
def_boolBROKEN_ON_SMP
---------------------------Changes:
===========
1, split outcrash_reserve.cfromcrash_core.c;
2, split outvmcore_infoc. fromcrash_core.c;
3, move crash related codes inkexec_core.cintocrash_core.c; 4, remove dependency ofFA_DUMPonCRASH_DUMP;
5, clean up kdump related config items;
6, wrap up crash codes in crash related ifdefs on all 9 arch-eswhich support crash dumping;Achievement:
===========
With above changes, I can rearrange the config item logic as below (the right item depends on or is selected by the left item):
Quoted 5 lines
PROC_KCORE -----------> VMCORE_INFO
|----------> VMCORE_INFO
FA_DUMP----|
|----------> CRASH_RESERVEFA_DUMP also needs PROC_VMCORE (CRASH_DUMP by dependency, I guess). So, the FA_DUMP related changes here will need a relook..
Quoted 44 lines
---->VMCORE_INFO / |---->CRASH_RESERVE KEXEC --| /| |--> KEXEC_CORE--> CRASH_DUMP-->/-|---->PROC_VMCORE KEXEC_FILE --| \ | \---->CRASH_HOTPLUG KEXEC --| |--> KEXEC_CORE (for kexec reboot only) KEXEC_FILE --|Test
========
On all 8 architectures, includingx86_64, arm64, s390x, sh, arm, mips, riscv, loongarch, I did below three cases of config item setting and building all passed. Let me take configs onx86_64as exampmle here:(1) Both
CONFIG_KEXECandKEXEC_FILEis unset, then all kexec/kdump items are unset automatically:
# Kexec and crash features
#CONFIG_KEXECis not set
#CONFIG_KEXEC_FILEis not set# end of Kexec and crash features(2) set
CONFIG_KEXEC_FILEand 'make olddefconfig':
---------------
# Kexec and crash featuresCONFIG_CRASH_RESERVE=yCONFIG_VMCORE_INFO=yCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=yCONFIG_CRASH_DUMP=yCONFIG_CRASH_HOTPLUG=yCONFIG_CRASH_MAX_MEMORY_RANGES=8192# end of Kexec and crash features ---------------(3) unset
CONFIG_CRASH_DUMPin case 2 and execute 'make olddefconfig':
------------------------
# Kexec and crash featuresCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=y
Quoted 6 lines
# end of Kexec and crash features ------------------------Note:
For ppc, it needs investigation to make clear how to split out crash code in arch folder.
On powerpc, both kdump and fadump need PROC_VMCORE & CRASH_DUMP. Hope that clears things. So, patch 3/14 breaks things for FA_DUMP..
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.
Sure. I will take a closer look...
Thanks
Hari
Quoted 87 lines · Hari Bathini
Hi Baoquan,
Quoted 84 lines · Baoquan He
Motivation:
=============
Previously, LKP reported a building error. When investigating, it can't be resolved reasonablly with the present messy kdump config items.https://lore.kernel.org/oe-kbuild-all/[email protected]/
The kdump (crash dumping) related config items could causes confusions:
Firstly,
---CRASH_COREenables codes including
- crashkernel reservation;
- elfcorehdr updating;
- vmcoreinfo exporting;
- crash hotplug handling;Now fadump of powerpc, kcore dynamic debugging and kdump all selects
CRASH_CORE, while fadump
- fadump needs crashkernel parsing, vmcoreinfo exporting, and accessingglobal variable 'elfcorehdr_addr';- kcore only needs vmcoreinfo exporting;
- kdump needs all of the currentkernel/crash_core.c.So only enabling
PROC_COREorFA_DUMPwill enableCRASH_CORE, this mislead people that we enable crash dumping, actual it's not.Secondly,
---
It's not reasonable to allowKEXEC_COREselectCRASH_CORE.Because
KEXEC_COREenables codes which allocate control pages, copy kexec/kdump segments, and prepare for switching. These codes are shared by both kexec reboot and kdump. We could want kexec reboot, but disable kdump. In that case,CRASH_COREshould not be selected.--------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y---------------------Thirdly,
---
It's not reasonable to allowCRASH_DUMPselectKEXEC_CORE.That could make
KEXEC_CORE,CRASH_DUMPare enabled independently from KEXEC orKEXEC_FILE. However, w/o KEXEC orKEXEC_FILE, theKEXEC_COREcode built in doesn't make any sense because no kernel loading or switching will happen to utilize theKEXEC_COREcode.
---------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
---------------------In this case, what is worse, on arch sh and arm, KEXEC relies on MMU, while
CRASH_DUMPcan still be enabled when !MMU, then compiling error is seen as the lkp test robot reported in above link.------arch/sh/Kconfig------
configARCH_SUPPORTS_KEXEC
def_boolMMUconfig
ARCH_SUPPORTS_CRASH_DUMP
def_boolBROKEN_ON_SMP
---------------------------Changes:
===========
1, split outcrash_reserve.cfromcrash_core.c;
2, split outvmcore_infoc. fromcrash_core.c;
3, move crash related codes inkexec_core.cintocrash_core.c; 4, remove dependency ofFA_DUMPonCRASH_DUMP;
5, clean up kdump related config items;
6, wrap up crash codes in crash related ifdefs on all 9 arch-eswhich support crash dumping;Achievement:
===========
With above changes, I can rearrange the config item logic as below (the right item depends on or is selected by the left item):
Quoted 8 lines
Quoted 5 lines
PROC_KCORE -----------> VMCORE_INFO |----------> VMCORE_INFO FA_DUMP----| |----------> CRASH_RESERVE
FA_DUMPalso needsPROC_VMCORE(CRASH_DUMPby dependency, I guess). So, theFA_DUMPrelated changes here will need a relook..
Thanks for checking this.
So FA_DUMP needs vmcoreinfo exporting, crashkernel reservation, /proc/vmcore. Then it's easy to adjust the kernel config item of FA_DUMP to make it select CRASH_DUMP. Except of this, do you have concern about the current code and Kconfig refactorying?
---->VMCORE_INFO
/|
FA_DUMP--> CRASH_DUMP-->/-|---->CRASH_RESERVE
\ |
\---->PROC_VMCOREQuoted 49 lines
Quoted 49 lines
---->VMCORE_INFO / |---->CRASH_RESERVE KEXEC --| /| |--> KEXEC_CORE--> CRASH_DUMP-->/-|---->PROC_VMCORE KEXEC_FILE --| \ | \---->CRASH_HOTPLUG KEXEC --| |--> KEXEC_CORE (for kexec reboot only) KEXEC_FILE --|Test
========
On all 8 architectures, includingx86_64, arm64, s390x, sh, arm, mips, riscv, loongarch, I did below three cases of config item setting and building all passed. Let me take configs onx86_64as exampmle here:(1) Both
CONFIG_KEXECandKEXEC_FILEis unset, then all kexec/kdump items are unset automatically:
# Kexec and crash features
#CONFIG_KEXECis not set
#CONFIG_KEXEC_FILEis not set# end of Kexec and crash features(2) set
CONFIG_KEXEC_FILEand 'make olddefconfig':
---------------
# Kexec and crash featuresCONFIG_CRASH_RESERVE=yCONFIG_VMCORE_INFO=yCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=yCONFIG_CRASH_DUMP=yCONFIG_CRASH_HOTPLUG=yCONFIG_CRASH_MAX_MEMORY_RANGES=8192# end of Kexec and crash features ---------------(3) unset
CONFIG_CRASH_DUMPin case 2 and execute 'make olddefconfig':
------------------------
# Kexec and crash featuresCONFIG_KEXEC_CORE=yCONFIG_KEXEC_FILE=y# end of Kexec and crash features ------------------------
Quoted 6 lines
Quoted 3 lines
Note:
For ppc, it needs investigation to make clear how to split out crash code in arch folder.On powerpc, both kdump and fadump need
PROC_VMCORE&CRASH_DUMP. Hope that clears things. So, patch 3/14 breaks things forFA_DUMP..
I see it now. We can easily fix that with below patch. What do you think?
By the way, do you have chance to help test these on powerpc system? I can find ppc64le machine, while I don't know how to operate to test fadump.
From fa8e6c3930d4f22f2b3768399c5bf0523c17adde Mon Sep 17 00:00:00 2001
From: Baoquan He <[email protected]>
Date: Sun, 4 Feb 2024 11:06:54 +0800
Subject: [PATCH] power/fadump: make FA_DUMP select CRASH_DUMP
Content-type: text/plain
FA_DUMP which is similar with kdump needs vmcoreinfo exporting, crashkernel reservation and /proc/vmcore file . After refactoring crash related codes and Kconfig items, make FA_DUMP select CRASH_DUMP. Now the dependency layout is like below:
---->VMCORE_INFO
/|
FA_DUMP--> CRASH_DUMP-->/-|---->CRASH_RESERVE
\ |
\---->PROC_VMCORE--- arch/powerpc/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/Kconfig +1 -2
@@ -695,8 +695,7 @@ config ARCH_SELECTS_CRASH_DUMP config FA_DUMP bool "Firmware-assisted dump" depends on PPC64 && (PPC_RTAS || PPC_POWERNV) - select VMCORE_INFO - select CRASH_RESERVE + select CRASH_DUMP help A robust mechanism to get reliable kernel crash dump with assistance from firmware. This approach does not use kexec,
Signature · 1 line
2.41.0
Quoted 7 lines
Quoted 4 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Hi Baoquan,
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
https://lore.kernel.org/all/[email protected]/
Please take a look.
Thanks
Hari
Quoted 11 lines · Hari Bathini
Hi Baoquan,
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Quoted 7 lines
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
https://lore.kernel.org/all/[email protected]/
Please take a look.
I added a comment to the patch 1 consulting if the "struct crash_mem" is appropriate to cover other cases except of kdump memory regions. I am wondering if its name need be adjusted, or other kind of memory you mentioned can use other structures or create a new one.
If it's has to be done like that, it's fine.
Andrew Morton
maintainerQuoted 6 lines · On Wed, 21 Feb 2024 11:15:00 +0530 Hari Bathini <[email protected]> wrote:
Quoted 5 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Quoted 8 lines
Quoted 2 lines
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
So can we take it that you're OK with Baoquan's series as-is?
Baoquan, do you believe the patches in mm-unstable are ready for moving into mm-stable in preparation for an upstream merge?
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Wed, 21 Feb 2024 11:15:00 +0530 Hari Bathini <[email protected]> wrote:
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Quoted 7 lines
Quoted 5 lines
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
So can we take it that you're OK with Baoquan's series as-is?
Hi Andrew,
If you mean
v3 (https://lore.kernel.org/all/[email protected]/)
+
follow-up from Baoquan (https://lore.kernel.org/all/Zb8D1ASrgX0qVm9z@MiWiFi-R3L-srv/)
Yes.
My changes are based on top of the above patches..
Thanks
Hari
Andrew Morton
maintainerQuoted 24 lines · On Thu, 22 Feb 2024 10:47:29 +0530 Hari Bathini <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Wed, 21 Feb 2024 11:15:00 +0530 Hari Bathini <[email protected]> wrote:
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Quoted 7 lines
Quoted 5 lines
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
So can we take it that you're OK with Baoquan's series as-is?
Hi Andrew,
Quoted 9 lines
If you mean
v3 (https://lore.kernel.org/all/[email protected]/)
+
follow-up from Baoquan
(https://lore.kernel.org/all/Zb8D1ASrgX0qVm9z@MiWiFi-R3L-srv/)Yes.
Can I add your Acked-by: and/or Tested-by: to the patches in this series?
Hari Bathini
Acked-byQuoted 33 lines · Andrew Morton
Quoted 31 lines · On Thu, 22 Feb 2024 10:47:29 +0530 Hari Bathini <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Wed, 21 Feb 2024 11:15:00 +0530 Hari Bathini <[email protected]> wrote:
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Quoted 7 lines
Quoted 5 lines
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
So can we take it that you're OK with Baoquan's series as-is?
Hi Andrew,
If you mean
v3 (https://lore.kernel.org/all/[email protected]/)
+
follow-up from Baoquan
(https://lore.kernel.org/all/Zb8D1ASrgX0qVm9z@MiWiFi-R3L-srv/)
Quoted 4 lines
Quoted 2 lines
Yes.
Can I add your Acked-by: and/or Tested-by: to the patches in this series?
Sure, Andrew.
for..
Patches 1-5 & 8 in:
https://lore.kernel.org/all/[email protected]/
and this follow-up patch:
https://lore.kernel.org/all/Zb8D1ASrgX0qVm9z@MiWiFi-R3L-srv/
Thanks
Hari
Quoted 15 lines · Andrew Morton
Quoted 13 lines · On Wed, 21 Feb 2024 11:15:00 +0530 Hari Bathini <[email protected]> wrote:
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 3 lines
Hope Hari and Pingfan can help have a look, see if
it's doable. Now, I make it either have both kexec and crash enabled, or disable both of them altogether.Sure. I will take a closer look...
Thanks a lot. Please feel free to post patches to make that, or I can do it with your support or suggestion.
Tested your changes and on top of these changes, came up with the below changes to get it working for powerpc:
Quoted 6 lines
Quoted 1 line
So can we take it that you're OK with Baoquan's series as-is?
Baoquan, do you believe the patches in mm-unstable are ready for moving into mm-stable in preparation for an upstream merge?
Yeah, I think they are ready to go for merging.
For Hari's patchset, the main part was planned before. And I am not familiar with fadump in powerpc, the Kconfig fix from Hari is a good guarantee with the expertise. Surely, I will await Hari's comment on that.