diff --git a/config/arm64/rt b/config/arm64/rt index c78f7a3..2200221 100644 --- a/config/arm64/rt +++ b/config/arm64/rt @@ -482,6 +482,7 @@ CONFIG_ARCH_SUPPORTS_KEXEC_SIG=y CONFIG_ARCH_SUPPORTS_KEXEC_IMAGE_VERIFY_SIG=y CONFIG_ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG=y CONFIG_ARCH_SUPPORTS_CRASH_DUMP=y +CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION=y CONFIG_TRANS_TABLE=y # CONFIG_XEN is not set CONFIG_ARCH_FORCE_MAX_ORDER=10 diff --git a/config/x86_64/rt b/config/x86_64/rt index f59c7d0..e07f970 100644 --- a/config/x86_64/rt +++ b/config/x86_64/rt @@ -527,6 +527,7 @@ CONFIG_ARCH_SUPPORTS_KEXEC_BZIMAGE_VERIFY_SIG=y CONFIG_ARCH_SUPPORTS_KEXEC_JUMP=y CONFIG_ARCH_SUPPORTS_CRASH_DUMP=y CONFIG_ARCH_SUPPORTS_CRASH_HOTPLUG=y +CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION=y CONFIG_PHYSICAL_START=0x1000000 CONFIG_RELOCATABLE=y CONFIG_RANDOMIZE_BASE=y diff --git a/patches.suse/add-product-identifying-information-to-vmcoreinfo.patch b/patches.suse/add-product-identifying-information-to-vmcoreinfo.patch index 9e196cb..dcd969c 100644 --- a/patches.suse/add-product-identifying-information-to-vmcoreinfo.patch +++ b/patches.suse/add-product-identifying-information-to-vmcoreinfo.patch @@ -15,15 +15,15 @@ Signed-off-by: Petr Tesarik --- a/kernel/crash_core.c +++ b/kernel/crash_core.c -@@ -13,6 +13,7 @@ - #include - #include - #include +@@ -17,6 +17,7 @@ + #include + #include + #include +#include #include #include -@@ -607,6 +608,7 @@ static int __init crash_save_vmcoreinfo_ +@@ -834,6 +835,7 @@ static int __init crash_save_vmcoreinfo_ } VMCOREINFO_OSRELEASE(init_uts_ns.name.release); diff --git a/patches.suse/arm64-kdump-simplify-the-reservation-behaviour-of-crashkernel-high.patch b/patches.suse/arm64-kdump-simplify-the-reservation-behaviour-of-crashkernel-high.patch new file mode 100644 index 0000000..57a6757 --- /dev/null +++ b/patches.suse/arm64-kdump-simplify-the-reservation-behaviour-of-crashkernel-high.patch @@ -0,0 +1,189 @@ +From: Baoquan He +Date: Mon, 15 May 2023 17:54:16 +0800 +Subject: arm64: kdump: simplify the reservation behaviour of crashkernel=,high +Git-commit: 6c4dcaddbd36ffc0f29dd874bbddbab30d8edca8 +Patch-mainline: v6.5-rc1 +References: jsc#PED-7249 + +On arm64, reservation for 'crashkernel=xM,high' is taken by searching for +suitable memory region top down. If the 'xM' of crashkernel high memory +is reserved from high memory successfully, it will try to reserve +crashkernel low memory later accoringly. Otherwise, it will try to search +low memory area for the 'xM' suitable region. Please see the details in +Documentation/admin-guide/kernel-parameters.txt. + +While we observed an unexpected case where a reserved region crosses the +high and low meomry boundary. E.g on a system with 4G as low memory end, +user added the kernel parameters like: 'crashkernel=512M,high', it could +finally have [4G-126M, 4G+386M], [1G, 1G+128M] regions in running kernel. +The crashkernel high region crossing low and high memory boudary will bring +issues: + +1) For crashkernel=x,high, if getting crashkernel high region across +low and high memory boundary, then user will see two memory regions in +low memory, and one memory region in high memory. The two crashkernel +low memory regions are confusing as shown in above example. + +2) If people explicityly specify "crashkernel=x,high crashkernel=y,low" +and y <= 128M, when crashkernel high region crosses low and high memory +boundary and the part of crashkernel high reservation below boundary is +bigger than y, the expected crahskernel low reservation will be skipped. +But the expected crashkernel high reservation is shrank and could not +satisfy user space requirement. + +3) The crossing boundary behaviour of crahskernel high reservation is +different than x86 arch. On x86_64, the low memory end is 4G fixedly, +and the memory near 4G is reserved by system, e.g for mapping firmware, +pci mapping, so the crashkernel reservation crossing boundary never happens. +From distros point of view, this brings inconsistency and confusion. Users +need to dig into x86 and arm64 system details to find out why. + +For kernel itself, the impact of issue 3) could be slight. While issue +1) and 2) cause actual impact because it brings obscure semantics and +behaviour to crashkernel=,high reservation. + +Here, for crashkernel=xM,high, search the high memory for the suitable +region only in high memory. If failed, try reserving the suitable +region only in low memory. Like this, the crashkernel high region will +only exist in high memory, and crashkernel low region only exists in low +memory. The reservation behaviour for crashkernel=,high is clearer and +simpler. + +Note: RPi4 has different zone ranges than normal memory. Its DMA zone is +0~1G, and DMA32 zone is 1G~4G if CONFIG_ZONE_DMA|DMA32 are enabled by +default. The low memory end is 1G in order to validate all devices, high +memory starts at 1G memory. However, for being consistent with normal +arm64 system, its low memory end is still 1G, while reserving crashkernel +high memory from 4G if crashkernel=size,high specified. This will remove +confusion. + +With above change applied, summary of arm64 crashkernel reservation range: +1) +RPi4(zone DMA:0~1G; DMA32:1G~4G): + crashkernel=size + 0~1G: low memory | 1G~top: high memory + + crashkernel=size,high + 0~1G: low memory | 4G~top: high memory + +2) +Other normal system: + crashkernel=size + crashkernel=size,high + 0~4G: low memory | 4G~top: high memory + +3) +Systems w/o zone DMA|DMA32 + crashkernel=size + crashkernel=size,high + 0~top: low memory + +Signed-off-by: Baoquan He +Reviewed-by: Catalin Marinas +Reviewed-by: Zhen Lei +Link: https://lore.kernel.org/r/ZGIBSEoZ7VRVvP8H@MiWiFi-R3L-srv +Signed-off-by: Catalin Marinas +Acked-by: Jiri Bohac +--- + arch/arm64/mm/init.c | 44 ++++++++++++++++++++++++++++++++++---------- + 1 file changed, 34 insertions(+), 10 deletions(-) + +diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c +index 66e70ca47680..c28c2c8483cc 100644 +--- a/arch/arm64/mm/init.c ++++ b/arch/arm64/mm/init.c +@@ -69,6 +69,7 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit; + + #define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit + #define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1) ++#define CRASH_HIGH_SEARCH_BASE SZ_4G + + #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) + +@@ -101,12 +102,13 @@ static int __init reserve_crashkernel_low(unsigned long long low_size) + */ + static void __init reserve_crashkernel(void) + { +- unsigned long long crash_base, crash_size; +- unsigned long long crash_low_size = 0; ++ unsigned long long crash_low_size = 0, search_base = 0; + unsigned long long crash_max = CRASH_ADDR_LOW_MAX; ++ unsigned long long crash_base, crash_size; + char *cmdline = boot_command_line; +- int ret; + bool fixed_base = false; ++ bool high = false; ++ int ret; + + if (!IS_ENABLED(CONFIG_KEXEC_CORE)) + return; +@@ -129,7 +131,9 @@ static void __init reserve_crashkernel(void) + else if (ret) + return; + ++ search_base = CRASH_HIGH_SEARCH_BASE; + crash_max = CRASH_ADDR_HIGH_MAX; ++ high = true; + } else if (ret || !crash_size) { + /* The specified value is invalid */ + return; +@@ -140,31 +144,51 @@ static void __init reserve_crashkernel(void) + /* User specifies base address explicitly. */ + if (crash_base) { + fixed_base = true; ++ search_base = crash_base; + crash_max = crash_base + crash_size; + } + + retry: + crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, +- crash_base, crash_max); ++ search_base, crash_max); + if (!crash_base) { + /* +- * If the first attempt was for low memory, fall back to +- * high memory, the minimum required low memory will be +- * reserved later. ++ * For crashkernel=size[KMG]@offset[KMG], print out failure ++ * message if can't reserve the specified region. + */ +- if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX)) { ++ if (fixed_base) { ++ pr_warn("crashkernel reservation failed - memory is in use.\n"); ++ return; ++ } ++ ++ /* ++ * For crashkernel=size[KMG], if the first attempt was for ++ * low memory, fall back to high memory, the minimum required ++ * low memory will be reserved later. ++ */ ++ if (!high && crash_max == CRASH_ADDR_LOW_MAX) { + crash_max = CRASH_ADDR_HIGH_MAX; ++ search_base = CRASH_ADDR_LOW_MAX; + crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; + goto retry; + } + ++ /* ++ * For crashkernel=size[KMG],high, if the first attempt was ++ * for high memory, fall back to low memory. ++ */ ++ if (high && crash_max == CRASH_ADDR_HIGH_MAX) { ++ crash_max = CRASH_ADDR_LOW_MAX; ++ search_base = 0; ++ goto retry; ++ } + pr_warn("cannot allocate crashkernel (size:0x%llx)\n", + crash_size); + return; + } + +- if ((crash_base > CRASH_ADDR_LOW_MAX - crash_low_size) && +- crash_low_size && reserve_crashkernel_low(crash_low_size)) { ++ if ((crash_base >= CRASH_ADDR_LOW_MAX) && crash_low_size && ++ reserve_crashkernel_low(crash_low_size)) { + memblock_phys_free(crash_base, crash_size); + return; + } + diff --git a/patches.suse/arm64-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch b/patches.suse/arm64-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch new file mode 100644 index 0000000..9ee8530 --- /dev/null +++ b/patches.suse/arm64-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch @@ -0,0 +1,231 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:40 +0800 +Subject: arm64: kdump: use generic interface to simplify crashkernel + reservation +Git-commit: fdc268232dbbae8d3acdc5536370b53327be3bb0 +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +With the help of newly changed function parse_crashkernel() and generic +reserve_crashkernel_generic(), crashkernel reservation can be simplified +by steps: + +1) Add a new header file , and define CRASH_ALIGN, + CRASH_ADDR_LOW_MAX, CRASH_ADDR_HIGH_MAX and + DEFAULT_CRASH_KERNEL_LOW_SIZE in ; + +2) Add arch_reserve_crashkernel() to call parse_crashkernel() and + reserve_crashkernel_generic(); + +3) Add ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION Kconfig in + arch/arm64/Kconfig. + +The old reserve_crashkernel_low() and reserve_crashkernel() can be +removed. + +Link: https://lkml.kernel.org/r/20230914033142.676708-8-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + arch/arm64/Kconfig | 3 + arch/arm64/include/asm/crash_core.h | 10 ++ + arch/arm64/mm/init.c | 140 ++---------------------------------- + 3 files changed, 21 insertions(+), 132 deletions(-) + +--- a/arch/arm64/Kconfig ++++ b/arch/arm64/Kconfig +@@ -1491,6 +1491,9 @@ config ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_S + config ARCH_SUPPORTS_CRASH_DUMP + def_bool y + ++config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++ def_bool CRASH_CORE ++ + config TRANS_TABLE + def_bool y + depends on HIBERNATION || KEXEC_CORE +--- /dev/null ++++ b/arch/arm64/include/asm/crash_core.h +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++#ifndef _ARM64_CRASH_CORE_H ++#define _ARM64_CRASH_CORE_H ++ ++/* Current arm64 boot protocol requires 2MB alignment */ ++#define CRASH_ALIGN SZ_2M ++ ++#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit ++#define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1) ++#endif +--- a/arch/arm64/mm/init.c ++++ b/arch/arm64/mm/init.c +@@ -64,149 +64,25 @@ EXPORT_SYMBOL(memstart_addr); + */ + phys_addr_t __ro_after_init arm64_dma_phys_limit; + +-/* Current arm64 boot protocol requires 2MB alignment */ +-#define CRASH_ALIGN SZ_2M +- +-#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit +-#define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1) +-#define CRASH_HIGH_SEARCH_BASE SZ_4G +- +-#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) +- +-static int __init reserve_crashkernel_low(unsigned long long low_size) ++static void __init arch_reserve_crashkernel(void) + { +- unsigned long long low_base; +- +- low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); +- if (!low_base) { +- pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); +- return -ENOMEM; +- } +- +- pr_info("crashkernel low memory reserved: 0x%08llx - 0x%08llx (%lld MB)\n", +- low_base, low_base + low_size, low_size >> 20); +- +- crashk_low_res.start = low_base; +- crashk_low_res.end = low_base + low_size - 1; +- insert_resource(&iomem_resource, &crashk_low_res); +- +- return 0; +-} +- +-/* +- * reserve_crashkernel() - reserves memory for crash kernel +- * +- * This function reserves memory area given in "crashkernel=" kernel command +- * line parameter. The memory reserved is used by dump capture kernel when +- * primary kernel is crashing. +- */ +-static void __init reserve_crashkernel(void) +-{ +- unsigned long long crash_low_size = 0, search_base = 0; +- unsigned long long crash_max = CRASH_ADDR_LOW_MAX; ++ unsigned long long low_size = 0; + unsigned long long crash_base, crash_size; + char *cmdline = boot_command_line; +- bool fixed_base = false; + bool high = false; + int ret; + + if (!IS_ENABLED(CONFIG_KEXEC_CORE)) + return; + +- /* crashkernel=X[@offset] */ + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), +- &crash_size, &crash_base, NULL, NULL); +- if (ret == -ENOENT) { +- ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); +- if (ret || !crash_size) +- return; +- +- /* +- * crashkernel=Y,low can be specified or not, but invalid value +- * is not allowed. +- */ +- ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base); +- if (ret == -ENOENT) +- crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; +- else if (ret) +- return; +- +- search_base = CRASH_HIGH_SEARCH_BASE; +- crash_max = CRASH_ADDR_HIGH_MAX; +- high = true; +- } else if (ret || !crash_size) { +- /* The specified value is invalid */ ++ &crash_size, &crash_base, ++ &low_size, &high); ++ if (ret) + return; +- } +- +- crash_size = PAGE_ALIGN(crash_size); +- +- /* User specifies base address explicitly. */ +- if (crash_base) { +- fixed_base = true; +- search_base = crash_base; +- crash_max = crash_base + crash_size; +- } + +-retry: +- crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, +- search_base, crash_max); +- if (!crash_base) { +- /* +- * For crashkernel=size[KMG]@offset[KMG], print out failure +- * message if can't reserve the specified region. +- */ +- if (fixed_base) { +- pr_warn("crashkernel reservation failed - memory is in use.\n"); +- return; +- } +- +- /* +- * For crashkernel=size[KMG], if the first attempt was for +- * low memory, fall back to high memory, the minimum required +- * low memory will be reserved later. +- */ +- if (!high && crash_max == CRASH_ADDR_LOW_MAX) { +- crash_max = CRASH_ADDR_HIGH_MAX; +- search_base = CRASH_ADDR_LOW_MAX; +- crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; +- goto retry; +- } +- +- /* +- * For crashkernel=size[KMG],high, if the first attempt was +- * for high memory, fall back to low memory. +- */ +- if (high && crash_max == CRASH_ADDR_HIGH_MAX) { +- crash_max = CRASH_ADDR_LOW_MAX; +- search_base = 0; +- goto retry; +- } +- pr_warn("cannot allocate crashkernel (size:0x%llx)\n", +- crash_size); +- return; +- } +- +- if ((crash_base >= CRASH_ADDR_LOW_MAX) && crash_low_size && +- reserve_crashkernel_low(crash_low_size)) { +- memblock_phys_free(crash_base, crash_size); +- return; +- } +- +- pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", +- crash_base, crash_base + crash_size, crash_size >> 20); +- +- /* +- * The crashkernel memory will be removed from the kernel linear +- * map. Inform kmemleak so that it won't try to access it. +- */ +- kmemleak_ignore_phys(crash_base); +- if (crashk_low_res.end) +- kmemleak_ignore_phys(crashk_low_res.start); +- +- crashk_res.start = crash_base; +- crashk_res.end = crash_base + crash_size - 1; +- insert_resource(&iomem_resource, &crashk_res); ++ reserve_crashkernel_generic(cmdline, crash_size, crash_base, ++ low_size, high); + } + + /* +@@ -454,7 +330,7 @@ void __init bootmem_init(void) + * request_standard_resources() depends on crashkernel's memory being + * reserved, so do it here. + */ +- reserve_crashkernel(); ++ arch_reserve_crashkernel(); + + memblock_dump_all(); + } diff --git a/patches.suse/crash_core-add-generic-function-to-do-reservation.patch b/patches.suse/crash_core-add-generic-function-to-do-reservation.patch new file mode 100644 index 0000000..edfc9f9 --- /dev/null +++ b/patches.suse/crash_core-add-generic-function-to-do-reservation.patch @@ -0,0 +1,203 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:37 +0800 +Subject: crash_core: add generic function to do reservation +Git-commit: 0ab97169aa0517079b22c2e64192906caa5dc6d5 +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +In architecture like x86_64, arm64 and riscv, they have vast virtual +address space and usually have huge physical memory RAM. Their +crashkernel reservation doesn't have to be limited under 4G RAM, but can +be extended to the whole physical memory via crashkernel=,high support. + +Now add function reserve_crashkernel_generic() to reserve crashkernel +memory if users specify any case of kernel pamameters, like +crashkernel=xM[@offset] or crashkernel=,high|low. + +This is preparation to simplify code of crashkernel=,high support in +architecutures. + +Link: https://lkml.kernel.org/r/20230914033142.676708-5-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + include/linux/crash_core.h | 28 ++++++++++++ + kernel/crash_core.c | 107 ++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 134 insertions(+), 1 deletion(-) + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index d8050a7eab01..4dbd6565e0ff 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -93,6 +93,34 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, + int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, + unsigned long long *crash_size, unsigned long long *crash_base); + ++#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 + +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 99a243540a35..72e358197b52 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -5,7 +5,6 @@ + */ + + #include +-#include + #include + #include + #include +@@ -13,6 +12,9 @@ + #include + #include + #include ++#include ++#include ++#include + + #include + #include +@@ -360,6 +362,109 @@ static int __init parse_crashkernel_dummy(char *arg) + } + early_param("crashkernel", parse_crashkernel_dummy); + ++#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++static int __init reserve_crashkernel_low(unsigned long long low_size) ++{ ++#ifdef CONFIG_64BIT ++ unsigned long long low_base; ++ ++ low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); ++ if (!low_base) { ++ pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); ++ return -ENOMEM; ++ } ++ ++ pr_info("crashkernel low memory reserved: 0x%08llx - 0x%08llx (%lld MB)\n", ++ low_base, low_base + low_size, low_size >> 20); ++ ++ crashk_low_res.start = low_base; ++ crashk_low_res.end = low_base + low_size - 1; ++ insert_resource(&iomem_resource, &crashk_low_res); ++#endif ++ return 0; ++} ++ ++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) ++{ ++ unsigned long long search_end = CRASH_ADDR_LOW_MAX, search_base = 0; ++ bool fixed_base = false; ++ ++ /* User specifies base address explicitly. */ ++ if (crash_base) { ++ fixed_base = true; ++ search_base = crash_base; ++ search_end = crash_base + crash_size; ++ } else if (high) { ++ search_base = CRASH_ADDR_LOW_MAX; ++ search_end = CRASH_ADDR_HIGH_MAX; ++ } ++ ++retry: ++ crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, ++ search_base, search_end); ++ if (!crash_base) { ++ /* ++ * For crashkernel=size[KMG]@offset[KMG], print out failure ++ * message if can't reserve the specified region. ++ */ ++ if (fixed_base) { ++ pr_warn("crashkernel reservation failed - memory is in use.\n"); ++ return; ++ } ++ ++ /* ++ * For crashkernel=size[KMG], if the first attempt was for ++ * low memory, fall back to high memory, the minimum required ++ * low memory will be reserved later. ++ */ ++ if (!high && search_end == CRASH_ADDR_LOW_MAX) { ++ search_end = CRASH_ADDR_HIGH_MAX; ++ search_base = CRASH_ADDR_LOW_MAX; ++ crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; ++ goto retry; ++ } ++ ++ /* ++ * For crashkernel=size[KMG],high, if the first attempt was ++ * for high memory, fall back to low memory. ++ */ ++ if (high && search_end == CRASH_ADDR_HIGH_MAX) { ++ search_end = CRASH_ADDR_LOW_MAX; ++ search_base = 0; ++ goto retry; ++ } ++ pr_warn("cannot allocate crashkernel (size:0x%llx)\n", ++ crash_size); ++ return; ++ } ++ ++ if ((crash_base > CRASH_ADDR_LOW_MAX) && ++ crash_low_size && reserve_crashkernel_low(crash_low_size)) { ++ memblock_phys_free(crash_base, crash_size); ++ return; ++ } ++ ++ pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", ++ crash_base, crash_base + crash_size, crash_size >> 20); ++ ++ /* ++ * The crashkernel memory will be removed from the kernel linear ++ * map. Inform kmemleak so that it won't try to access it. ++ */ ++ kmemleak_ignore_phys(crash_base); ++ if (crashk_low_res.end) ++ kmemleak_ignore_phys(crashk_low_res.start); ++ ++ crashk_res.start = crash_base; ++ crashk_res.end = crash_base + crash_size - 1; ++ insert_resource(&iomem_resource, &crashk_res); ++} ++#endif ++ + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) + { + diff --git a/patches.suse/crash_core-change-parse_crashkernel-to-support-crashkernel-high-low-parsing.patch b/patches.suse/crash_core-change-parse_crashkernel-to-support-crashkernel-high-low-parsing.patch new file mode 100644 index 0000000..46828c4 --- /dev/null +++ b/patches.suse/crash_core-change-parse_crashkernel-to-support-crashkernel-high-low-parsing.patch @@ -0,0 +1,99 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:36 +0800 +Subject: crash_core: change parse_crashkernel() to support + crashkernel=,high|low parsing +Git-commit: 70916e9c8d9f1a286c99727072b22e395097909f +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +Now parse_crashkernel() is a real entry point for all kinds of crahskernel +parsing on any architecture. + +And wrap the crahskernel=,high|low handling inside +CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope. + +Link: https://lkml.kernel.org/r/20230914033142.676708-4-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + include/linux/crash_core.h | 6 ++++++ + kernel/crash_core.c | 36 +++++++++++++++++++++++++++++++++--- + 2 files changed, 39 insertions(+), 3 deletions(-) + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 6156355ef831..d8050a7eab01 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -79,6 +79,12 @@ 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); + ++#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE ++#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) ++#endif ++#endif ++ + 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); +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 33ced5b5ed4e..99a243540a35 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -283,6 +283,9 @@ static int __init __parse_crashkernel(char *cmdline, + /* + * That function is the entry point for command line parsing and should be + * called from the arch-specific code. ++ * ++ * If crashkernel=,high|low is supported on architecture, non-NULL values ++ * should be passed to parameters 'low_size' and 'high'. + */ + int __init parse_crashkernel(char *cmdline, + unsigned long long system_ram, +@@ -296,10 +299,37 @@ int __init parse_crashkernel(char *cmdline, + /* crashkernel=X[@offset] */ + ret = __parse_crashkernel(cmdline, system_ram, crash_size, + crash_base, NULL); +- if (!high) +- return ret; ++#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++ /* ++ * If non-NULL 'high' passed in and no normal crashkernel ++ * setting detected, try parsing crashkernel=,high|low. ++ */ ++ if (high && ret == -ENOENT) { ++ ret = __parse_crashkernel(cmdline, 0, crash_size, ++ crash_base, suffix_tbl[SUFFIX_HIGH]); ++ if (ret || !*crash_size) ++ return -EINVAL; + +- return 0; ++ /* ++ * crashkernel=Y,low can be specified or not, but invalid value ++ * is not allowed. ++ */ ++ ret = __parse_crashkernel(cmdline, 0, low_size, ++ crash_base, suffix_tbl[SUFFIX_LOW]); ++ if (ret == -ENOENT) { ++ *low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; ++ ret = 0; ++ } else if (ret) { ++ return ret; ++ } ++ ++ *high = true; ++ } ++#endif ++ if (!*crash_size) ++ ret = -EINVAL; ++ ++ return ret; + } + + int __init parse_crashkernel_high(char *cmdline, + diff --git a/patches.suse/crash_core-change-the-prototype-of-function-parse_crashkernel.patch b/patches.suse/crash_core-change-the-prototype-of-function-parse_crashkernel.patch new file mode 100644 index 0000000..0695fdd --- /dev/null +++ b/patches.suse/crash_core-change-the-prototype-of-function-parse_crashkernel.patch @@ -0,0 +1,240 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:35 +0800 +Subject: crash_core: change the prototype of function parse_crashkernel() +Git-commit: a9e1a3d84e4a0ea560ed4d84c28d06dbfdffed22 +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +Add two parameters 'low_size' and 'high' to function parse_crashkernel(), +later crashkernel=,high|low parsing will be added. Make adjustments in +all call sites of parse_crashkernel() in arch. + +Link: https://lkml.kernel.org/r/20230914033142.676708-3-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + arch/arm/kernel/setup.c | 3 ++- + arch/arm64/mm/init.c | 2 +- + arch/ia64/kernel/setup.c | 2 +- + arch/loongarch/kernel/setup.c | 4 +++- + arch/mips/kernel/setup.c | 3 ++- + arch/powerpc/kernel/fadump.c | 2 +- + arch/powerpc/kexec/core.c | 2 +- + arch/powerpc/mm/nohash/kaslr_booke.c | 2 +- + arch/riscv/mm/init.c | 2 +- + arch/s390/kernel/setup.c | 4 ++-- + arch/sh/kernel/machine_kexec.c | 2 +- + arch/x86/kernel/setup.c | 3 ++- + include/linux/crash_core.h | 3 ++- + kernel/crash_core.c | 15 ++++++++++++--- + 14 files changed, 32 insertions(+), 17 deletions(-) + +diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c +index c66b560562b3..e2bb7afd0683 100644 +--- a/arch/arm/kernel/setup.c ++++ b/arch/arm/kernel/setup.c +@@ -1010,7 +1010,8 @@ static void __init reserve_crashkernel(void) + + total_mem = get_total_mem(); + ret = parse_crashkernel(boot_command_line, total_mem, +- &crash_size, &crash_base); ++ &crash_size, &crash_base, ++ NULL, NULL); + /* invalid value specified or crashkernel=0 */ + if (ret || !crash_size) + return; +diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c +index 8a0f8604348b..801c59c39a8f 100644 +--- a/arch/arm64/mm/init.c ++++ b/arch/arm64/mm/init.c +@@ -142,7 +142,7 @@ static void __init reserve_crashkernel(void) + + /* crashkernel=X[@offset] */ + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), +- &crash_size, &crash_base); ++ &crash_size, &crash_base, NULL, NULL); + if (ret == -ENOENT) { + ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); + if (ret || !crash_size) +diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c +index 5a55ac82c13a..4faea2d2cf07 100644 +--- a/arch/ia64/kernel/setup.c ++++ b/arch/ia64/kernel/setup.c +@@ -277,7 +277,7 @@ static void __init setup_crashkernel(unsigned long total, int *n) + int ret; + + ret = parse_crashkernel(boot_command_line, total, +- &size, &base); ++ &size, &base, NULL, NULL); + if (ret == 0 && size > 0) { + if (!base) { + sort_regions(rsvd_region, *n); +diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c +index 7783f0a3d742..4de32b07c0dc 100644 +--- a/arch/loongarch/kernel/setup.c ++++ b/arch/loongarch/kernel/setup.c +@@ -267,7 +267,9 @@ static void __init arch_parse_crashkernel(void) + unsigned long long crash_base, crash_size; + + total_mem = memblock_phys_mem_size(); +- ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base); ++ ret = parse_crashkernel(boot_command_line, total_mem, ++ &crash_size, &crash_base, ++ NULL, NULL); + if (ret < 0 || crash_size <= 0) + return; + +diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c +index cb871eb784a7..08321c945ac4 100644 +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -460,7 +460,8 @@ static void __init mips_parse_crashkernel(void) + + total_mem = memblock_phys_mem_size(); + ret = parse_crashkernel(boot_command_line, total_mem, +- &crash_size, &crash_base); ++ &crash_size, &crash_base, ++ NULL, NULL); + if (ret != 0 || crash_size <= 0) + return; + +diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c +index 3ff2da7b120b..d14eda1e8589 100644 +--- a/arch/powerpc/kernel/fadump.c ++++ b/arch/powerpc/kernel/fadump.c +@@ -313,7 +313,7 @@ static __init u64 fadump_calculate_reserve_size(void) + * memory at a predefined offset. + */ + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), +- &size, &base); ++ &size, &base, NULL, NULL); + if (ret == 0 && size > 0) { + unsigned long max_size; + +diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c +index de64c7962991..9346c960b296 100644 +--- a/arch/powerpc/kexec/core.c ++++ b/arch/powerpc/kexec/core.c +@@ -109,7 +109,7 @@ void __init reserve_crashkernel(void) + total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size(); + /* use common parsing */ + ret = parse_crashkernel(boot_command_line, total_mem_sz, +- &crash_size, &crash_base); ++ &crash_size, &crash_base, NULL, NULL); + if (ret == 0 && crash_size > 0) { + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c +index 2fb3edafe9ab..b4f2786a7d2b 100644 +--- a/arch/powerpc/mm/nohash/kaslr_booke.c ++++ b/arch/powerpc/mm/nohash/kaslr_booke.c +@@ -178,7 +178,7 @@ static void __init get_crash_kernel(void *fdt, unsigned long size) + int ret; + + ret = parse_crashkernel(boot_command_line, size, &crash_size, +- &crash_base); ++ &crash_base, NULL, NULL); + if (ret != 0 || crash_size == 0) + return; + if (crash_base == 0) +diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c +index 0798bd861dcb..9fe448900059 100644 +--- a/arch/riscv/mm/init.c ++++ b/arch/riscv/mm/init.c +@@ -1388,7 +1388,7 @@ static void __init reserve_crashkernel(void) + } + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), +- &crash_size, &crash_base); ++ &crash_size, &crash_base, NULL, NULL); + if (ret == -ENOENT) { + /* Fallback to crashkernel=X,[high,low] */ + ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); +diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c +index de6ad0fb2328..e555b576d3c8 100644 +--- a/arch/s390/kernel/setup.c ++++ b/arch/s390/kernel/setup.c +@@ -625,8 +625,8 @@ static void __init reserve_crashkernel(void) + phys_addr_t low, high; + int rc; + +- rc = parse_crashkernel(boot_command_line, ident_map_size, &crash_size, +- &crash_base); ++ rc = parse_crashkernel(boot_command_line, ident_map_size, ++ &crash_size, &crash_base, NULL, NULL); + + crash_base = ALIGN(crash_base, KEXEC_CRASH_MEM_ALIGN); + crash_size = ALIGN(crash_size, KEXEC_CRASH_MEM_ALIGN); +diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c +index 223c14f44af7..fa3a7b36190a 100644 +--- a/arch/sh/kernel/machine_kexec.c ++++ b/arch/sh/kernel/machine_kexec.c +@@ -154,7 +154,7 @@ void __init reserve_crashkernel(void) + int ret; + + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), +- &crash_size, &crash_base); ++ &crash_size, &crash_base, NULL, NULL); + if (ret == 0 && crash_size > 0) { + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c +index b098b1fa2470..655c04812905 100644 +--- a/arch/x86/kernel/setup.c ++++ b/arch/x86/kernel/setup.c +@@ -553,7 +553,8 @@ static void __init reserve_crashkernel(void) + total_mem = memblock_phys_mem_size(); + + /* crashkernel=XM */ +- ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base); ++ ret = parse_crashkernel(boot_command_line, total_mem, ++ &crash_size, &crash_base, NULL, NULL); + if (ret != 0 || crash_size <= 0) { + /* crashkernel=X,high */ + ret = parse_crashkernel_high(boot_command_line, total_mem, +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 0c06561bf5ff..6156355ef831 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -80,7 +80,8 @@ Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, + 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 *crash_size, unsigned long long *crash_base, ++ unsigned long long *low_size, bool *high); + int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, + unsigned long long *crash_size, unsigned long long *crash_base); + int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 507113932aa9..33ced5b5ed4e 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -287,10 +287,19 @@ static int __init __parse_crashkernel(char *cmdline, + int __init parse_crashkernel(char *cmdline, + unsigned long long system_ram, + unsigned long long *crash_size, +- unsigned long long *crash_base) ++ unsigned long long *crash_base, ++ unsigned long long *low_size, ++ bool *high) + { +- return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- NULL); ++ int ret; ++ ++ /* crashkernel=X[@offset] */ ++ ret = __parse_crashkernel(cmdline, system_ram, crash_size, ++ crash_base, NULL); ++ if (!high) ++ return ret; ++ ++ return 0; + } + + int __init parse_crashkernel_high(char *cmdline, + diff --git a/patches.suse/crash_core-fix-the-check-for-whether-crashkernel-is-from-high-memory.patch b/patches.suse/crash_core-fix-the-check-for-whether-crashkernel-is-from-high-memory.patch new file mode 100644 index 0000000..a38af1c --- /dev/null +++ b/patches.suse/crash_core-fix-the-check-for-whether-crashkernel-is-from-high-memory.patch @@ -0,0 +1,68 @@ +From: Yuntao Wang +Date: Sat, 9 Dec 2023 22:14:38 +0800 +Subject: crash_core: fix the check for whether crashkernel is from high memory +Git-commit: 1dd11e977360ad3493812da0b05ffd9adcdd15a1 +Patch-mainline: v6.7-rc6 +References: jsc#PED-7249 + +If crash_base is equal to CRASH_ADDR_LOW_MAX, it also indicates that +the crashkernel memory is allocated from high memory. However, the +current check only considers the case where crash_base is greater than +CRASH_ADDR_LOW_MAX. Fix it. + +The runtime effects is that crashkernel high memory is successfully +reserved, whereas the crashkernel low memory is bypassed in this case, +then kdump kernel bootup will fail because of no low memory under 4G. + +This patch also includes some minor cleanups. + +Link: https://lkml.kernel.org/r/20231209141438.77233-1-ytcoode@gmail.com +Fixes: 0ab97169aa05 ("crash_core: add generic function to do reservation") +Signed-off-by: Yuntao Wang +Cc: Baoquan He +Cc: Dave Young +Cc: Vivek Goyal +Cc: Zhen Lei +Cc: "Eric W. Biederman" +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + kernel/crash_core.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index efe87d501c8c..d4313b53837e 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -199,7 +199,7 @@ static __initdata char *suffix_tbl[] = { + * It returns 0 on success and -EINVAL on failure. + */ + static int __init parse_crashkernel_suffix(char *cmdline, +- unsigned long long *crash_size, ++ unsigned long long *crash_size, + const char *suffix) + { + char *cur = cmdline; +@@ -268,9 +268,9 @@ static int __init __parse_crashkernel(char *cmdline, + unsigned long long *crash_base, + const char *suffix) + { +- char *first_colon, *first_space; +- char *ck_cmdline; +- char *name = "crashkernel="; ++ char *first_colon, *first_space; ++ char *ck_cmdline; ++ char *name = "crashkernel="; + + BUG_ON(!crash_size || !crash_base); + *crash_size = 0; +@@ -440,7 +440,7 @@ void __init reserve_crashkernel_generic(char *cmdline, + return; + } + +- if ((crash_base > CRASH_ADDR_LOW_MAX) && ++ if ((crash_base >= CRASH_ADDR_LOW_MAX) && + crash_low_size && reserve_crashkernel_low(crash_low_size)) { + memblock_phys_free(crash_base, crash_size); + return; + diff --git a/patches.suse/crash_core-move-crashk_-res-definition-into-crash_core.c.patch b/patches.suse/crash_core-move-crashk_-res-definition-into-crash_core.c.patch new file mode 100644 index 0000000..2cdf310 --- /dev/null +++ b/patches.suse/crash_core-move-crashk_-res-definition-into-crash_core.c.patch @@ -0,0 +1,125 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:38 +0800 +Subject: crash_core: move crashk_*res definition into crash_core.c +Git-commit: b631b95dded5e7f007a3a79cbaf82ef50c1e2cf7 +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +Both crashk_res and crashk_low_res are used to mark the reserved +crashkernel regions in iomem_resource tree. And later the generic +crashkernel resrvation will be added into crash_core.c. So move +crashk_res and crashk_low_res definition into crash_core.c to avoid +compiling error if CONFIG_CRASH_CORE=on while CONFIG_KEXEC_CORE is unset. + +Meanwhile include in if generic +reservation is needed. In that case, need be added by +ARCH. In asm/crash_core.h, ARCH can provide its own macro definitions to +override macros in if needed. Wrap the including +into CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope to +avoid compiling error in other ARCH-es which don't take the generic +reservation way yet. + +Link: https://lkml.kernel.org/r/20230914033142.676708-6-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + include/linux/crash_core.h | 8 ++++++++ + include/linux/kexec.h | 4 ---- + kernel/crash_core.c | 16 ++++++++++++++++ + kernel/kexec_core.c | 17 ----------------- + 4 files changed, 24 insertions(+), 21 deletions(-) + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 4dbd6565e0ff..3c735a7e33fb 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -5,6 +5,14 @@ + #include + #include + #include ++#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++#include ++#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) +diff --git a/include/linux/kexec.h b/include/linux/kexec.h +index 32c78078552c..8227455192b7 100644 +--- a/include/linux/kexec.h ++++ b/include/linux/kexec.h +@@ -22,10 +22,6 @@ + #include + #include + +-/* Location of a reserved region to hold the crash kernel. +- */ +-extern struct resource crashk_res; +-extern struct resource crashk_low_res; + extern note_buf_t __percpu *crash_notes; + + #ifdef CONFIG_KEXEC_CORE +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 72e358197b52..fa8808c4f00e 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -35,6 +35,22 @@ u32 *vmcoreinfo_note; + /* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ + static unsigned char *vmcoreinfo_data_safecopy; + ++/* Location of the reserved area for the crash kernel */ ++struct resource crashk_res = { ++ .name = "Crash kernel", ++ .start = 0, ++ .end = 0, ++ .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, ++ .desc = IORES_DESC_CRASH_KERNEL ++}; ++struct resource crashk_low_res = { ++ .name = "Crash kernel", ++ .start = 0, ++ .end = 0, ++ .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, ++ .desc = IORES_DESC_CRASH_KERNEL ++}; ++ + /* + * parsing the "crashkernel" commandline + * +diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c +index 9dc728982d79..be5642a4ec49 100644 +--- a/kernel/kexec_core.c ++++ b/kernel/kexec_core.c +@@ -52,23 +52,6 @@ atomic_t __kexec_lock = ATOMIC_INIT(0); + /* Flag to indicate we are going to kexec a new kernel */ + bool kexec_in_progress = false; + +- +-/* Location of the reserved area for the crash kernel */ +-struct resource crashk_res = { +- .name = "Crash kernel", +- .start = 0, +- .end = 0, +- .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, +- .desc = IORES_DESC_CRASH_KERNEL +-}; +-struct resource crashk_low_res = { +- .name = "Crash kernel", +- .start = 0, +- .end = 0, +- .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, +- .desc = IORES_DESC_CRASH_KERNEL +-}; +- + int kexec_should_crash(struct task_struct *p) + { + /* + diff --git a/patches.suse/crash_core.c-remove-unnecessary-parameter-of-function.patch b/patches.suse/crash_core.c-remove-unnecessary-parameter-of-function.patch new file mode 100644 index 0000000..7a9817d --- /dev/null +++ b/patches.suse/crash_core.c-remove-unnecessary-parameter-of-function.patch @@ -0,0 +1,101 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:34 +0800 +Subject: crash_core.c: remove unnecessary parameter of function +Git-commit: a6304272b03ece97346f16923453f7e36ec19a5a +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +Patch series "kdump: use generic functions to simplify crashkernel +reservation in arch", v3. + +In the current arm64, crashkernel=,high support has been finished after +several rounds of posting and careful reviewing. The code in arm64 which +parses crashkernel kernel parameters firstly, then reserve memory can be a +good example for other ARCH to refer to. + +Whereas in x86_64, the code mixing crashkernel parameter parsing and +memory reserving is twisted, and looks messy. Refactoring the code to +make it more readable maintainable is necessary. + +Here, firstly abstract the crashkernel parameter parsing code into +parse_crashkernel() to make it be able to parse crashkernel=,high|low. +Then abstract the crashkernel memory reserving code into a generic +function reserve_crashkernel_generic(). Finally, in ARCH which +crashkernel=,high support is needed, a simple arch_reserve_crashkernel() +can be added to call above two functions. This can remove the duplicated +implmentation code in each ARCH, like arm64, x86_64 and riscv. + +crashkernel=512M,high +crashkernel=512M,high crashkernel=256M,low +crashkernel=512M,high crashkernel=0M,low +crashkernel=0M,high crashkernel=256M,low +crashkernel=512M +crashkernel=512M@0x4f000000 +crashkernel=1G-4G:256M,4G-64G:320M,64G-:576M +crashkernel=0M + + +This patch (of 9): + +In all call sites of __parse_crashkernel(), the parameter 'name' is +hardcoded as "crashkernel=". So remove the unnecessary parameter 'name', +add local varibale 'name' inside __parse_crashkernel() instead. + +Link: https://lkml.kernel.org/r/20230914033142.676708-1-bhe@redhat.com +Link: https://lkml.kernel.org/r/20230914033142.676708-2-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Cc: Zhen Lei +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + kernel/crash_core.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 2f675ef045d4..507113932aa9 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -248,11 +248,11 @@ static int __init __parse_crashkernel(char *cmdline, + unsigned long long system_ram, + unsigned long long *crash_size, + unsigned long long *crash_base, +- const char *name, + const char *suffix) + { + char *first_colon, *first_space; + char *ck_cmdline; ++ char *name = "crashkernel="; + + BUG_ON(!crash_size || !crash_base); + *crash_size = 0; +@@ -290,7 +290,7 @@ int __init parse_crashkernel(char *cmdline, + unsigned long long *crash_base) + { + return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- "crashkernel=", NULL); ++ NULL); + } + + int __init parse_crashkernel_high(char *cmdline, +@@ -299,7 +299,7 @@ int __init parse_crashkernel_high(char *cmdline, + unsigned long long *crash_base) + { + return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- "crashkernel=", suffix_tbl[SUFFIX_HIGH]); ++ suffix_tbl[SUFFIX_HIGH]); + } + + int __init parse_crashkernel_low(char *cmdline, +@@ -308,7 +308,7 @@ int __init parse_crashkernel_low(char *cmdline, + unsigned long long *crash_base) + { + return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- "crashkernel=", suffix_tbl[SUFFIX_LOW]); ++ suffix_tbl[SUFFIX_LOW]); + } + + /* + diff --git a/patches.suse/crash_core.c-remove-unneeded-functions.patch b/patches.suse/crash_core.c-remove-unneeded-functions.patch new file mode 100644 index 0000000..c6fbd01 --- /dev/null +++ b/patches.suse/crash_core.c-remove-unneeded-functions.patch @@ -0,0 +1,67 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:42 +0800 +Subject: crash_core.c: remove unneeded functions +Git-commit: c37e56cac3d62c69f093904afbc58fc428484d14 +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +So far, nobody calls functions parse_crashkernel_high() and +parse_crashkernel_low(), remove both of them. + +Link: https://lkml.kernel.org/r/20230914033142.676708-10-bhe@redhat.com +Signed-off-by: Baoquan He +Reviewed-by: Zhen Lei +Cc: Catalin Marinas +Cc: Chen Jiahao +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + include/linux/crash_core.h | 4 ---- + kernel/crash_core.c | 18 ------------------ + 2 files changed, 22 deletions(-) + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 3c735a7e33fb..3426f6eef60b 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -96,10 +96,6 @@ 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); +-int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, +- unsigned long long *crash_size, unsigned long long *crash_base); +-int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, +- unsigned long long *crash_size, unsigned long long *crash_base); + + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index fa8808c4f00e..efe87d501c8c 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -350,24 +350,6 @@ int __init parse_crashkernel(char *cmdline, + return ret; + } + +-int __init parse_crashkernel_high(char *cmdline, +- unsigned long long system_ram, +- unsigned long long *crash_size, +- unsigned long long *crash_base) +-{ +- return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- suffix_tbl[SUFFIX_HIGH]); +-} +- +-int __init parse_crashkernel_low(char *cmdline, +- unsigned long long system_ram, +- unsigned long long *crash_size, +- unsigned long long *crash_base) +-{ +- return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, +- suffix_tbl[SUFFIX_LOW]); +-} +- + /* + * Add a dummy early_param handler to mark crashkernel= as a known command line + * parameter and suppress incorrect warnings in init/main.c. + diff --git a/patches.suse/kdump-add-crashkernel-cma-suffix.patch b/patches.suse/kdump-add-crashkernel-cma-suffix.patch new file mode 100644 index 0000000..db68891 --- /dev/null +++ b/patches.suse/kdump-add-crashkernel-cma-suffix.patch @@ -0,0 +1,240 @@ +From: Jiri Bohac +Subject: kdump: add crashkernel= ,cma suffix +References: jsc#PED-7249 +Patch-mainline: Submitted, 2023-11-24 https://lore.kernel.org/lkml/ZWD_fAPqEWkFlEkM@dwarf.suse.cz/ + +Add a new optional ",cma" suffix to the crashkernel= command line option. + +Add a new cma_size parameter to parse_crashkernel(). +When not NULL, call __parse_crashkernel to parse the CMA +reservation size from "crashkernel=size,cma" and store it +in cma_size. + +Set cma_size to NULL in all calls to parse_crashkernel(). + +Signed-off-by: Jiri Bohac +--- + arch/arm/kernel/setup.c | 2 +- + arch/arm64/mm/init.c | 2 +- + arch/loongarch/kernel/setup.c | 2 +- + arch/mips/kernel/setup.c | 2 +- + arch/powerpc/kernel/fadump.c | 2 +- + arch/powerpc/kexec/core.c | 2 +- + arch/powerpc/mm/nohash/kaslr_booke.c | 2 +- + arch/riscv/mm/init.c | 2 +- + arch/s390/kernel/setup.c | 2 +- + arch/sh/kernel/machine_kexec.c | 2 +- + arch/x86/kernel/setup.c | 2 +- + include/linux/crash_core.h | 3 ++- + kernel/crash_core.c | 20 ++++++++++++++++---- + 13 files changed, 29 insertions(+), 16 deletions(-) + +diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c +index ff2299ce1ad7..cb940553c757 100644 +--- a/arch/arm/kernel/setup.c ++++ b/arch/arm/kernel/setup.c +@@ -1010,7 +1010,7 @@ static void __init reserve_crashkernel(void) + total_mem = get_total_mem(); + ret = parse_crashkernel(boot_command_line, total_mem, + &crash_size, &crash_base, +- NULL, NULL); ++ NULL, NULL, NULL); + /* invalid value specified or crashkernel=0 */ + if (ret || !crash_size) + return; +diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c +index 74c1db8ce271..819b8979584c 100644 +--- a/arch/arm64/mm/init.c ++++ b/arch/arm64/mm/init.c +@@ -105,7 +105,7 @@ static void __init arch_reserve_crashkernel(void) + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), + &crash_size, &crash_base, +- &low_size, &high); ++ &low_size, NULL, &high); + if (ret) + return; + +diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c +index d183a745fb85..0489c8188b83 100644 +--- a/arch/loongarch/kernel/setup.c ++++ b/arch/loongarch/kernel/setup.c +@@ -266,7 +266,7 @@ static void __init arch_parse_crashkernel(void) + total_mem = memblock_phys_mem_size(); + ret = parse_crashkernel(boot_command_line, total_mem, + &crash_size, &crash_base, +- NULL, NULL); ++ NULL, NULL, NULL); + if (ret < 0 || crash_size <= 0) + return; + +diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c +index 2d2ca024bd47..98afa80ec002 100644 +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -456,7 +456,7 @@ static void __init mips_parse_crashkernel(void) + total_mem = memblock_phys_mem_size(); + ret = parse_crashkernel(boot_command_line, total_mem, + &crash_size, &crash_base, +- NULL, NULL); ++ NULL, NULL, NULL); + if (ret != 0 || crash_size <= 0) + return; + +diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c +index d14eda1e8589..6fa5ab01f4e8 100644 +--- a/arch/powerpc/kernel/fadump.c ++++ b/arch/powerpc/kernel/fadump.c +@@ -313,7 +313,7 @@ static __init u64 fadump_calculate_reserve_size(void) + * memory at a predefined offset. + */ + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), +- &size, &base, NULL, NULL); ++ &size, &base, NULL, NULL, NULL); + if (ret == 0 && size > 0) { + unsigned long max_size; + +diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c +index 85846cadb9b5..c1e0afd94c90 100644 +--- a/arch/powerpc/kexec/core.c ++++ b/arch/powerpc/kexec/core.c +@@ -112,7 +112,7 @@ void __init reserve_crashkernel(void) + total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size(); + /* use common parsing */ + ret = parse_crashkernel(boot_command_line, total_mem_sz, +- &crash_size, &crash_base, NULL, NULL); ++ &crash_size, &crash_base, NULL, NULL, NULL); + if (ret == 0 && crash_size > 0) { + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c +index b4f2786a7d2b..df083fe158b6 100644 +--- a/arch/powerpc/mm/nohash/kaslr_booke.c ++++ b/arch/powerpc/mm/nohash/kaslr_booke.c +@@ -178,7 +178,7 @@ static void __init get_crash_kernel(void *fdt, unsigned long size) + int ret; + + ret = parse_crashkernel(boot_command_line, size, &crash_size, +- &crash_base, NULL, NULL); ++ &crash_base, NULL, NULL, NULL); + if (ret != 0 || crash_size == 0) + return; + if (crash_base == 0) +diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c +index 2e011cbddf3a..d0bae97c9a7a 100644 +--- a/arch/riscv/mm/init.c ++++ b/arch/riscv/mm/init.c +@@ -1355,7 +1355,7 @@ static void __init arch_reserve_crashkernel(void) + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), + &crash_size, &crash_base, +- &low_size, &high); ++ &low_size, NULL, &high); + if (ret) + return; + +diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c +index 5701356f4f33..4d18b6b8f5ca 100644 +--- a/arch/s390/kernel/setup.c ++++ b/arch/s390/kernel/setup.c +@@ -619,7 +619,7 @@ static void __init reserve_crashkernel(void) + int rc; + + rc = parse_crashkernel(boot_command_line, ident_map_size, +- &crash_size, &crash_base, NULL, NULL); ++ &crash_size, &crash_base, NULL, NULL, NULL); + + crash_base = ALIGN(crash_base, KEXEC_CRASH_MEM_ALIGN); + crash_size = ALIGN(crash_size, KEXEC_CRASH_MEM_ALIGN); +diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c +index fa3a7b36190a..e754860a7236 100644 +--- a/arch/sh/kernel/machine_kexec.c ++++ b/arch/sh/kernel/machine_kexec.c +@@ -154,7 +154,7 @@ void __init reserve_crashkernel(void) + int ret; + + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), +- &crash_size, &crash_base, NULL, NULL); ++ &crash_size, &crash_base, NULL, NULL, NULL); + if (ret == 0 && crash_size > 0) { + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c +index 1526747bedf2..f271b2cc3054 100644 +--- a/arch/x86/kernel/setup.c ++++ b/arch/x86/kernel/setup.c +@@ -478,7 +478,7 @@ static void __init arch_reserve_crashkernel(void) + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), + &crash_size, &crash_base, +- &low_size, &high); ++ &low_size, NULL, &high); + if (ret) + return; + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 5126a4fecb44..f1edefcf7377 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -95,7 +95,8 @@ 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); ++ unsigned long long *low_size, unsigned long long *cma_size, ++ bool *high); + + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index efe87d501c8c..1e952d2e451b 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -184,11 +184,13 @@ static int __init parse_crashkernel_simple(char *cmdline, + + #define SUFFIX_HIGH 0 + #define SUFFIX_LOW 1 +-#define SUFFIX_NULL 2 ++#define SUFFIX_CMA 2 ++#define SUFFIX_NULL 3 + static __initdata char *suffix_tbl[] = { +- [SUFFIX_HIGH] = ",high", +- [SUFFIX_LOW] = ",low", +- [SUFFIX_NULL] = NULL, ++ [SUFFIX_HIGH] = ",high", ++ [SUFFIX_LOW] = ",low", ++ [SUFFIX_CMA] = ",cma", ++ [SUFFIX_NULL] = NULL, + }; + + /* +@@ -310,9 +312,11 @@ int __init parse_crashkernel(char *cmdline, + unsigned long long *crash_size, + unsigned long long *crash_base, + unsigned long long *low_size, ++ unsigned long long *cma_size, + bool *high) + { + int ret; ++ unsigned long long cma_base; + + /* crashkernel=X[@offset] */ + ret = __parse_crashkernel(cmdline, system_ram, crash_size, +@@ -343,6 +347,14 @@ int __init parse_crashkernel(char *cmdline, + + *high = true; + } ++ ++ /* ++ * optional CMA reservation ++ * cma_base is ignored ++ */ ++ if (cma_size) ++ __parse_crashkernel(cmdline, 0, cma_size, ++ &cma_base, suffix_tbl[SUFFIX_CMA]); + #endif + if (!*crash_size) + ret = -EINVAL; +-- +2.42.0 + diff --git a/patches.suse/kdump-crashkernel-cma-update-Documentation.patch b/patches.suse/kdump-crashkernel-cma-update-Documentation.patch new file mode 100644 index 0000000..45986ee --- /dev/null +++ b/patches.suse/kdump-crashkernel-cma-update-Documentation.patch @@ -0,0 +1,55 @@ +From: Jiri Bohac +Subject: kdump: describe crashkernel ,cma in Documentaion +References: jsc#PED-7249 +Patch-mainline: Submitted, 2023-11-24 https://lore.kernel.org/lkml/ZWD_fAPqEWkFlEkM@dwarf.suse.cz/ + +Describe the new crashkernel ",cma" suffix in Documentation/ + +--- + Documentation/admin-guide/kdump/kdump.rst | 10 ++++++++++ + Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ + 2 files changed, 17 insertions(+) + +diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst +index 5762e7477a0c..4ec08e5843dc 100644 +--- a/Documentation/admin-guide/kdump/kdump.rst ++++ b/Documentation/admin-guide/kdump/kdump.rst +@@ -317,6 +317,16 @@ crashkernel syntax + + crashkernel=0,low + ++4) crashkernel=size,cma ++ ++ Reserves additional memory from CMA. A standard crashkernel reservation, as ++ described above, is still needed, but can be just small enough to hold the ++ kernel and initrd. All the memory the crash kernel needs for its runtime and ++ for running the kdump userspace processes can be provided by this CMA ++ reservation, re-using memory available to the production system's userspace. ++ Because of this re-using, the CMA reservation should not be used if it's ++ intended to dump userspce memory. ++ + Boot into System Kernel + ----------------------- + 1) Update the boot loader (such as grub, yaboot, or lilo) configuration +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt +index 65731b060e3f..ee9fc40a97fd 100644 +--- a/Documentation/admin-guide/kernel-parameters.txt ++++ b/Documentation/admin-guide/kernel-parameters.txt +@@ -914,6 +914,13 @@ + 0: to disable low allocation. + It will be ignored when crashkernel=X,high is not used + or memory reserved is below 4G. ++ crashkernel=size[KMG],cma ++ [KNL, X86] Reserve additional crash kernel memory from CMA. ++ This reservation is usable by the 1st system's userspace, ++ so this should not be used if dumping of userspace ++ memory is intended. A standard crashkernel reservation, ++ as described above, is still needed to hold the crash ++ kernel and initrd. + + cryptomgr.notests + [KNL] Disable crypto self-tests + +-- +2.42.0 + diff --git a/patches.suse/kdump-defer-the-insertion-of-crashkernel-resources.patch b/patches.suse/kdump-defer-the-insertion-of-crashkernel-resources.patch new file mode 100644 index 0000000..f3e8717 --- /dev/null +++ b/patches.suse/kdump-defer-the-insertion-of-crashkernel-resources.patch @@ -0,0 +1,121 @@ +From: Huacai Chen +Date: Fri, 29 Dec 2023 16:02:13 +0800 +Subject: kdump: defer the insertion of crashkernel resources +Git-commit: 4a693ce65b186fddc1a73621bd6f941e6e3eca21 +Patch-mainline: v6.8-rc1 +References: jsc#PED-7249 + +In /proc/iomem, sub-regions should be inserted after their parent, +otherwise the insertion of parent resource fails. But after generic +crashkernel reservation applied, in both RISC-V and ARM64 (LoongArch will +also use generic reservation later on), crashkernel resources are inserted +before their parent, which causes the parent disappear in /proc/iomem. So +we defer the insertion of crashkernel resources to an early_initcall(). + +1, Without 'crashkernel' parameter: + + 100d0100-100d01ff : LOON0001:00 + 100d0100-100d01ff : LOON0001:00 LOON0001:00 + 100e0000-100e0bff : LOON0002:00 + 100e0000-100e0bff : LOON0002:00 LOON0002:00 + 1fe001e0-1fe001e7 : serial + 90400000-fa17ffff : System RAM + f6220000-f622ffff : Reserved + f9ee0000-f9ee3fff : Reserved + fa120000-fa17ffff : Reserved + fa190000-fe0bffff : System RAM + fa190000-fa1bffff : Reserved + fe4e0000-47fffffff : System RAM + 43c000000-441ffffff : Reserved + 47ff98000-47ffa3fff : Reserved + 47ffa4000-47ffa7fff : Reserved + 47ffa8000-47ffabfff : Reserved + 47ffac000-47ffaffff : Reserved + 47ffb0000-47ffb3fff : Reserved + +2, With 'crashkernel' parameter, before this patch: + + 100d0100-100d01ff : LOON0001:00 + 100d0100-100d01ff : LOON0001:00 LOON0001:00 + 100e0000-100e0bff : LOON0002:00 + 100e0000-100e0bff : LOON0002:00 LOON0002:00 + 1fe001e0-1fe001e7 : serial + e6200000-f61fffff : Crash kernel + fa190000-fe0bffff : System RAM + fa190000-fa1bffff : Reserved + fe4e0000-47fffffff : System RAM + 43c000000-441ffffff : Reserved + 47ff98000-47ffa3fff : Reserved + 47ffa4000-47ffa7fff : Reserved + 47ffa8000-47ffabfff : Reserved + 47ffac000-47ffaffff : Reserved + 47ffb0000-47ffb3fff : Reserved + +3, With 'crashkernel' parameter, after this patch: + + 100d0100-100d01ff : LOON0001:00 + 100d0100-100d01ff : LOON0001:00 LOON0001:00 + 100e0000-100e0bff : LOON0002:00 + 100e0000-100e0bff : LOON0002:00 LOON0002:00 + 1fe001e0-1fe001e7 : serial + 90400000-fa17ffff : System RAM + e6200000-f61fffff : Crash kernel + f6220000-f622ffff : Reserved + f9ee0000-f9ee3fff : Reserved + fa120000-fa17ffff : Reserved + fa190000-fe0bffff : System RAM + fa190000-fa1bffff : Reserved + fe4e0000-47fffffff : System RAM + 43c000000-441ffffff : Reserved + 47ff98000-47ffa3fff : Reserved + 47ffa4000-47ffa7fff : Reserved + 47ffa8000-47ffabfff : Reserved + 47ffac000-47ffaffff : Reserved + 47ffb0000-47ffb3fff : Reserved + +Link: https://lkml.kernel.org/r/20231229080213.2622204-1-chenhuacai@loongson.cn +Signed-off-by: Huacai Chen +Fixes: 0ab97169aa05 ("crash_core: add generic function to do reservation") +Cc: Baoquan He +Cc: Zhen Lei +Cc: [6.6+] +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + kernel/crash_core.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index d48315667752..4e2cac71b84f 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -376,7 +376,6 @@ static int __init reserve_crashkernel_low(unsigned long long low_size) + + crashk_low_res.start = low_base; + crashk_low_res.end = low_base + low_size - 1; +- insert_resource(&iomem_resource, &crashk_low_res); + #endif + return 0; + } +@@ -458,8 +457,19 @@ void __init reserve_crashkernel_generic(char *cmdline, + + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +- insert_resource(&iomem_resource, &crashk_res); + } ++ ++static __init int insert_crashkernel_resources(void) ++{ ++ if (crashk_res.start < crashk_res.end) ++ insert_resource(&iomem_resource, &crashk_res); ++ ++ if (crashk_low_res.start < crashk_low_res.end) ++ insert_resource(&iomem_resource, &crashk_low_res); ++ ++ return 0; ++} ++early_initcall(insert_crashkernel_resources); + #endif + + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + diff --git a/patches.suse/kdump-implement-reserve_crashkernel_cma.patch b/patches.suse/kdump-implement-reserve_crashkernel_cma.patch new file mode 100644 index 0000000..3e31ab5 --- /dev/null +++ b/patches.suse/kdump-implement-reserve_crashkernel_cma.patch @@ -0,0 +1,112 @@ +From: Jiri Bohac +Subject: kdump: implement reserve_crashkernel_cma +References: jsc#PED-7249 +Patch-mainline: Submitted, 2023-11-24 https://lore.kernel.org/lkml/ZWD_fAPqEWkFlEkM@dwarf.suse.cz/ + +reserve_crashkernel_cma() reserves CMA ranges for the +crash kernel. If allocating the requested size fails, +try to reserve in smaller pieces. + +Store the reserved ranges in the crashk_cma_ranges array +and the number of ranges in crashk_cma_cnt. + +Signed-off-by: Jiri Bohac + +--- + include/linux/crash_core.h | 9 +++++++ + kernel/crash_core.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 61 insertions(+) + +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -14,6 +14,13 @@ + extern struct resource crashk_res; + extern struct resource crashk_low_res; + ++extern struct range crashk_cma_ranges[]; ++#ifdef CONFIG_CMA ++extern int crashk_cma_cnt; ++#else ++#define crashk_cma_cnt 0 ++#endif ++ + #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) +@@ -98,6 +105,8 @@ int __init parse_crashkernel(char *cmdli + unsigned long long *low_size, unsigned long long *cma_size, + bool *high); + ++void __init reserve_crashkernel_cma(unsigned long long cma_size); ++ + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE + #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -485,6 +486,57 @@ static __init int insert_crashkernel_res + early_initcall(insert_crashkernel_resources); + #endif + ++#ifdef CONFIG_CMA ++#define CRASHKERNEL_CMA_RANGES_MAX 4 ++ ++struct range crashk_cma_ranges[CRASHKERNEL_CMA_RANGES_MAX]; ++int crashk_cma_cnt = 0; ++ ++void __init reserve_crashkernel_cma(unsigned long long cma_size) ++{ ++ unsigned long long request_size = roundup(cma_size, PAGE_SIZE); ++ unsigned long long reserved_size = 0; ++ ++ while (cma_size > reserved_size && ++ crashk_cma_cnt < CRASHKERNEL_CMA_RANGES_MAX) { ++ ++ struct cma *res; ++ ++ if (cma_declare_contiguous(0, request_size, 0, 0, 0, false, ++ "crashkernel", &res)) { ++ /* reservation failed, try half-sized blocks */ ++ if (request_size <= PAGE_SIZE) ++ break; ++ ++ request_size = roundup(request_size / 2, PAGE_SIZE); ++ continue; ++ } ++ ++ crashk_cma_ranges[crashk_cma_cnt].start = cma_get_base(res); ++ crashk_cma_ranges[crashk_cma_cnt].end = ++ crashk_cma_ranges[crashk_cma_cnt].start + ++ cma_get_size(res) - 1; ++ ++crashk_cma_cnt; ++ reserved_size += request_size; ++ } ++ ++ if (cma_size > reserved_size) ++ pr_warn("crashkernel CMA reservation failed: %lld MB requested, %lld MB reserved in %d ranges\n", ++ cma_size >> 20, reserved_size >> 20, crashk_cma_cnt); ++ else ++ pr_info("crashkernel CMA reserved: %lld MB in %d ranges\n", ++ reserved_size >> 20, crashk_cma_cnt); ++} ++ ++#else /* CONFIG_CMA */ ++struct range crashk_cma_ranges[0]; ++void __init reserve_crashkernel_cma(unsigned long long cma_size) ++{ ++ if (cma_size) ++ pr_warn("crashkernel CMA reservation failed: CMA disabled\n"); ++} ++#endif ++ + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) + { diff --git a/patches.suse/kdump-wait-for-dma-to-time-out-when-using-cma.patch b/patches.suse/kdump-wait-for-dma-to-time-out-when-using-cma.patch new file mode 100644 index 0000000..0511e21 --- /dev/null +++ b/patches.suse/kdump-wait-for-dma-to-time-out-when-using-cma.patch @@ -0,0 +1,81 @@ +From: Jiri Bohac +Subject: kdump: wait for DMA to time out when using CMA +Patch-mainline: Submitted, 2023-11-24 https://lore.kernel.org/lkml/ZWD_fAPqEWkFlEkM@dwarf.suse.cz/ +References: jsc#PED-7249 + +When re-using the CMA area for kdump there is a risk +of pending DMA into pinned user pages in the CMA area. + +Pages that are pinned long-term are migrated away from CMA, so these are not a +concern. Only pages pinned without the FOLL_LONGTERM. + +I believe waiting for 1 second before reusing them should be safe enough. + +Acked-by: Jiri Bohac +--- + include/linux/crash_core.h | 1 + + kernel/crash_core.c | 11 +++++++++++ + kernel/kexec_core.c | 1 + + 3 files changed, 13 insertions(+) + +diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h +index 97db2374b493..f0cef9ce95b0 100644 +--- a/include/linux/crash_core.h ++++ b/include/linux/crash_core.h +@@ -20,6 +20,7 @@ extern int crashk_cma_cnt; + #else + #define crashk_cma_cnt 0 + #endif ++void crash_cma_clear_pending_dma(void); + + #define CRASH_CORE_NOTE_NAME "CORE" + #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index d71ecd59f16b..d85f370c1e5d 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -16,6 +16,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -25,6 +26,8 @@ + #include "kallsyms_internal.h" + #include "kexec_internal.h" + ++#define CMA_DMA_TIMEOUT_MSEC 1000 ++ + /* Per cpu memory for storing cpu states in case of system crash. */ + note_buf_t __percpu *crash_notes; + +@@ -527,6 +530,14 @@ void __init reserve_crashkernel_cma(unsigned long long cma_size) + } + #endif + ++void crash_cma_clear_pending_dma(void) ++{ ++ if (!crashk_cma_cnt) ++ return; ++ ++ mdelay(CMA_DMA_TIMEOUT_MSEC); ++} ++ + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) + { +diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c +index be5642a4ec49..5d26b49e7cee 100644 +--- a/kernel/kexec_core.c ++++ b/kernel/kexec_core.c +@@ -1044,6 +1044,7 @@ void __noclone __crash_kexec(struct pt_regs *regs) + if (kexec_crash_image) { + struct pt_regs fixed_regs; + ++ crash_cma_clear_pending_dma(); + crash_setup_regs(&fixed_regs, regs); + crash_save_vmcoreinfo(); + machine_crash_shutdown(&fixed_regs); + diff --git a/patches.suse/kdump-x86-implement-crashkernel-cma-reservation.patch b/patches.suse/kdump-x86-implement-crashkernel-cma-reservation.patch new file mode 100644 index 0000000..1cb9bb8 --- /dev/null +++ b/patches.suse/kdump-x86-implement-crashkernel-cma-reservation.patch @@ -0,0 +1,111 @@ +From: Jiri Bohac +Subject: kdump, x86: implement crashkernel cma reservation +References: jsc#PED-7249 +Patch-mainline: Submitted, 2023-11-24 https://lore.kernel.org/lkml/ZWD_fAPqEWkFlEkM@dwarf.suse.cz/ + +Implement the crashkernel CMA reservation for x86: +- enable parsing of the cma suffix by parse_crashkernel() +- reserve memory with reserve_crashkernel_cma() +- add the CMA-reserved ranges to the e820 map for the crash kernel +- exclude the CMA-reserved ranges from vmcore + +Signed-off-by: Jiri Bohac + +--- + arch/x86/kernel/crash.c | 26 ++++++++++++++++++++++---- + arch/x86/kernel/setup.c | 5 +++-- + 2 files changed, 25 insertions(+), 6 deletions(-) + +diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c +index c92d88680dbf..f27d09386157 100644 +--- a/arch/x86/kernel/crash.c ++++ b/arch/x86/kernel/crash.c +@@ -147,10 +147,10 @@ static struct crash_mem *fill_up_crash_elf_data(void) + return NULL; + + /* +- * Exclusion of crash region and/or crashk_low_res may cause +- * another range split. So add extra two slots here. ++ * Exclusion of crash region, crashk_low_res and/or crashk_cma_ranges ++ * may cause range splits. So add extra slots here. + */ +- nr_ranges += 2; ++ nr_ranges += 2 + crashk_cma_cnt; + cmem = vzalloc(struct_size(cmem, ranges, nr_ranges)); + if (!cmem) + return NULL; +@@ -168,6 +168,7 @@ static struct crash_mem *fill_up_crash_elf_data(void) + static int elf_header_exclude_ranges(struct crash_mem *cmem) + { + int ret = 0; ++ int i; + + /* Exclude the low 1M because it is always reserved */ + ret = crash_exclude_mem_range(cmem, 0, (1<<20)-1); +@@ -182,8 +183,17 @@ static int elf_header_exclude_ranges(struct crash_mem *cmem) + if (crashk_low_res.end) + ret = crash_exclude_mem_range(cmem, crashk_low_res.start, + crashk_low_res.end); ++ if (ret) ++ return ret; + +- return ret; ++ for (i = 0; i < crashk_cma_cnt; ++i) { ++ ret = crash_exclude_mem_range(cmem, crashk_cma_ranges[i].start, ++ crashk_cma_ranges[i].end); ++ if (ret) ++ return ret; ++ } ++ ++ return 0; + } + + static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) +@@ -336,6 +346,14 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) + add_e820_entry(params, &ei); + } + ++ for (i = 0; i < crashk_cma_cnt; ++i) { ++ ei.addr = crashk_cma_ranges[i].start; ++ ei.size = crashk_cma_ranges[i].end - ++ crashk_cma_ranges[i].start + 1; ++ ei.type = E820_TYPE_RAM; ++ add_e820_entry(params, &ei); ++ } ++ + out: + vfree(cmem); + return ret; +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c +index f271b2cc3054..5994d18fd2a0 100644 +--- a/arch/x86/kernel/setup.c ++++ b/arch/x86/kernel/setup.c +@@ -468,7 +468,7 @@ static void __init memblock_x86_reserve_range_setup_data(void) + + static void __init arch_reserve_crashkernel(void) + { +- unsigned long long crash_base, crash_size, low_size = 0; ++ unsigned long long crash_base, crash_size, low_size = 0, cma_size = 0; + char *cmdline = boot_command_line; + bool high = false; + int ret; +@@ -478,7 +478,7 @@ static void __init arch_reserve_crashkernel(void) + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), + &crash_size, &crash_base, +- &low_size, NULL, &high); ++ &low_size, &cma_size, &high); + if (ret) + return; + +@@ -489,6 +489,7 @@ static void __init arch_reserve_crashkernel(void) + + reserve_crashkernel_generic(cmdline, crash_size, crash_base, + low_size, high); ++ reserve_crashkernel_cma(cma_size); + } + + static struct resource standard_io_resources[] = { +-- +2.42.0 + diff --git a/patches.suse/riscv-kdump-Implement-crashkernel-X-high-low.patch b/patches.suse/riscv-kdump-Implement-crashkernel-X-high-low.patch new file mode 100644 index 0000000..eef4430 --- /dev/null +++ b/patches.suse/riscv-kdump-Implement-crashkernel-X-high-low.patch @@ -0,0 +1,189 @@ +From: Chen Jiahao +Date: Wed, 26 Jul 2023 17:49:59 +0000 +Subject: riscv: kdump: Implement crashkernel=X,[high,low] +Git-commit: 5882e5acf18d79d586282acfd07a8c88550e2cee +Patch-mainline: v6.6-rc1 +References: jsc#PED-7249 + +On riscv, the current crash kernel allocation logic is trying to +allocate within 32bit addressible memory region by default, if +failed, try to allocate without 4G restriction. + +In need of saving DMA zone memory while allocating a relatively large +crash kernel region, allocating the reserved memory top down in +high memory, without overlapping the DMA zone, is a mature solution. +Here introduce the parameter option crashkernel=X,[high,low]. + +One can reserve the crash kernel from high memory above DMA zone range +by explicitly passing "crashkernel=X,high"; or reserve a memory range +below 4G with "crashkernel=X,low". + +Signed-off-by: Chen Jiahao +Acked-by: Guo Ren +Acked-by: Baoquan He +Link: https://lore.kernel.org/r/20230726175000.2536220-2-chenjiahao16@huawei.com +Signed-off-by: Palmer Dabbelt +Acked-by: Jiri Bohac +--- + arch/riscv/kernel/setup.c | 5 +++ + arch/riscv/mm/init.c | 93 +++++++++++++++++++++++++++++++++++++++++++---- + 2 files changed, 91 insertions(+), 7 deletions(-) + +diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c +index 971fe776e2f8..376f5d49ce85 100644 +--- a/arch/riscv/kernel/setup.c ++++ b/arch/riscv/kernel/setup.c +@@ -178,6 +178,11 @@ static void __init init_resources(void) + if (ret < 0) + goto error; + } ++ if (crashk_low_res.start != crashk_low_res.end) { ++ ret = add_resource(&iomem_resource, &crashk_low_res); ++ if (ret < 0) ++ goto error; ++ } + #endif + + #ifdef CONFIG_CRASH_DUMP +diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c +index 70fb31960b63..156e09a1ceee 100644 +--- a/arch/riscv/mm/init.c ++++ b/arch/riscv/mm/init.c +@@ -1297,6 +1297,28 @@ static inline void setup_vm_final(void) + } + #endif /* CONFIG_MMU */ + ++/* Reserve 128M low memory by default for swiotlb buffer */ ++#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) ++ ++static int __init reserve_crashkernel_low(unsigned long long low_size) ++{ ++ unsigned long long low_base; ++ ++ low_base = memblock_phys_alloc_range(low_size, PMD_SIZE, 0, dma32_phys_limit); ++ if (!low_base) { ++ pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); ++ return -ENOMEM; ++ } ++ ++ pr_info("crashkernel low memory reserved: 0x%016llx - 0x%016llx (%lld MB)\n", ++ low_base, low_base + low_size, low_size >> 20); ++ ++ crashk_low_res.start = low_base; ++ crashk_low_res.end = low_base + low_size - 1; ++ ++ return 0; ++} ++ + /* + * reserve_crashkernel() - reserves memory for crash kernel + * +@@ -1308,8 +1330,12 @@ static void __init reserve_crashkernel(void) + { + unsigned long long crash_base = 0; + unsigned long long crash_size = 0; ++ unsigned long long crash_low_size = 0; + unsigned long search_start = memblock_start_of_DRAM(); +- unsigned long search_end = memblock_end_of_DRAM(); ++ unsigned long search_end = (unsigned long)dma32_phys_limit; ++ char *cmdline = boot_command_line; ++ bool fixed_base = false; ++ bool high = false; + + int ret = 0; + +@@ -1325,14 +1351,36 @@ static void __init reserve_crashkernel(void) + return; + } + +- ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), ++ ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), + &crash_size, &crash_base); +- if (ret || !crash_size) ++ if (ret == -ENOENT) { ++ /* Fallback to crashkernel=X,[high,low] */ ++ ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); ++ if (ret || !crash_size) ++ return; ++ ++ /* ++ * crashkernel=Y,low is valid only when crashkernel=X,high ++ * is passed. ++ */ ++ ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base); ++ if (ret == -ENOENT) ++ crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; ++ else if (ret) ++ return; ++ ++ search_start = (unsigned long)dma32_phys_limit; ++ search_end = memblock_end_of_DRAM(); ++ high = true; ++ } else if (ret || !crash_size) { ++ /* Invalid argument value specified */ + return; ++ } + + crash_size = PAGE_ALIGN(crash_size); + + if (crash_base) { ++ fixed_base = true; + search_start = crash_base; + search_end = crash_base + crash_size; + } +@@ -1345,12 +1393,37 @@ static void __init reserve_crashkernel(void) + * swiotlb can work on the crash kernel. + */ + crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, +- search_start, +- min(search_end, (unsigned long)(SZ_4G - 1))); ++ search_start, search_end); + if (crash_base == 0) { +- /* Try again without restricting region to 32bit addressible memory */ ++ /* ++ * For crashkernel=size[KMG]@offset[KMG], print out failure ++ * message if can't reserve the specified region. ++ */ ++ if (fixed_base) { ++ pr_warn("crashkernel: allocating failed with given size@offset\n"); ++ return; ++ } ++ ++ if (high) { ++ /* ++ * For crashkernel=size[KMG],high, if the first attempt was ++ * for high memory, fall back to low memory. ++ */ ++ search_start = memblock_start_of_DRAM(); ++ search_end = (unsigned long)dma32_phys_limit; ++ } else { ++ /* ++ * For crashkernel=size[KMG], if the first attempt was for ++ * low memory, fall back to high memory, the minimum required ++ * low memory will be reserved later. ++ */ ++ search_start = (unsigned long)dma32_phys_limit; ++ search_end = memblock_end_of_DRAM(); ++ crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; ++ } ++ + crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, +- search_start, search_end); ++ search_start, search_end); + if (crash_base == 0) { + pr_warn("crashkernel: couldn't allocate %lldKB\n", + crash_size >> 10); +@@ -1358,6 +1431,12 @@ static void __init reserve_crashkernel(void) + } + } + ++ if ((crash_base >= dma32_phys_limit) && crash_low_size && ++ reserve_crashkernel_low(crash_low_size)) { ++ memblock_phys_free(crash_base, crash_size); ++ return; ++ } ++ + pr_info("crashkernel: reserved 0x%016llx - 0x%016llx (%lld MB)\n", + crash_base, crash_base + crash_size, crash_size >> 20); + + diff --git a/patches.suse/riscv-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch b/patches.suse/riscv-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch new file mode 100644 index 0000000..d4bd9ba --- /dev/null +++ b/patches.suse/riscv-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch @@ -0,0 +1,283 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:41 +0800 +Subject: riscv: kdump: use generic interface to simplify crashkernel + reservation +Git-commit: 39365395046fe74bebf6f70e86439f48ba56a75e +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +With the help of newly changed function parse_crashkernel() and generic +reserve_crashkernel_generic(), crashkernel reservation can be simplified +by steps: + +1) Add a new header file , and define CRASH_ALIGN, + CRASH_ADDR_LOW_MAX, CRASH_ADDR_HIGH_MAX and + DEFAULT_CRASH_KERNEL_LOW_SIZE in ; + +2) Add arch_reserve_crashkernel() to call parse_crashkernel() and + reserve_crashkernel_generic(); + +3) Add ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION Kconfig in + arch/riscv/Kconfig. + +The old reserve_crashkernel_low() and reserve_crashkernel() can be +removed. + +[chenjiahao16@huawei.com: fix crashkernel reserving problem on RISC-V] + Link: https://lkml.kernel.org/r/20230925024333.730964-1-chenjiahao16@huawei.com +Link: https://lkml.kernel.org/r/20230914033142.676708-9-bhe@redhat.com +Signed-off-by: Baoquan He +Signed-off-by: Chen Jiahao +Cc: Catalin Marinas +Cc: Chen Jiahao +Cc: Zhen Lei +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + arch/riscv/Kconfig | 3 + arch/riscv/include/asm/crash_core.h | 11 ++ + arch/riscv/include/asm/processor.h | 2 + arch/riscv/kernel/setup.c | 13 --- + arch/riscv/mm/init.c | 141 ++---------------------------------- + 5 files changed, 27 insertions(+), 143 deletions(-) + +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -617,6 +617,9 @@ config ARCH_SUPPORTS_KEXEC_PURGATORY + config ARCH_SUPPORTS_CRASH_DUMP + def_bool y + ++config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++ def_bool CRASH_CORE ++ + config COMPAT + bool "Kernel support for 32-bit U-mode" + default 64BIT +--- /dev/null ++++ b/arch/riscv/include/asm/crash_core.h +@@ -0,0 +1,11 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++#ifndef _RISCV_CRASH_CORE_H ++#define _RISCV_CRASH_CORE_H ++ ++#define CRASH_ALIGN PMD_SIZE ++ ++#define CRASH_ADDR_LOW_MAX dma32_phys_limit ++#define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM() ++ ++extern phys_addr_t memblock_end_of_DRAM(void); ++#endif +--- a/arch/riscv/include/asm/processor.h ++++ b/arch/riscv/include/asm/processor.h +@@ -73,6 +73,8 @@ static inline void wait_for_interrupt(vo + __asm__ __volatile__ ("wfi"); + } + ++extern phys_addr_t dma32_phys_limit; ++ + struct device_node; + int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); + int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid); +--- a/arch/riscv/kernel/setup.c ++++ b/arch/riscv/kernel/setup.c +@@ -170,19 +170,6 @@ static void __init init_resources(void) + if (ret < 0) + goto error; + +-#ifdef CONFIG_KEXEC_CORE +- if (crashk_res.start != crashk_res.end) { +- ret = add_resource(&iomem_resource, &crashk_res); +- if (ret < 0) +- goto error; +- } +- if (crashk_low_res.start != crashk_low_res.end) { +- ret = add_resource(&iomem_resource, &crashk_low_res); +- if (ret < 0) +- goto error; +- } +-#endif +- + #ifdef CONFIG_CRASH_DUMP + if (elfcorehdr_size > 0) { + elfcorehdr_res.start = elfcorehdr_addr; +--- a/arch/riscv/mm/init.c ++++ b/arch/riscv/mm/init.c +@@ -65,7 +65,7 @@ extern char _start[]; + void *_dtb_early_va __initdata; + uintptr_t _dtb_early_pa __initdata; + +-static phys_addr_t dma32_phys_limit __initdata; ++phys_addr_t dma32_phys_limit __initdata; + + static void __init zone_sizes_init(void) + { +@@ -1303,28 +1303,6 @@ static inline void setup_vm_final(void) + } + #endif /* CONFIG_MMU */ + +-/* Reserve 128M low memory by default for swiotlb buffer */ +-#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) +- +-static int __init reserve_crashkernel_low(unsigned long long low_size) +-{ +- unsigned long long low_base; +- +- low_base = memblock_phys_alloc_range(low_size, PMD_SIZE, 0, dma32_phys_limit); +- if (!low_base) { +- pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); +- return -ENOMEM; +- } +- +- pr_info("crashkernel low memory reserved: 0x%016llx - 0x%016llx (%lld MB)\n", +- low_base, low_base + low_size, low_size >> 20); +- +- crashk_low_res.start = low_base; +- crashk_low_res.end = low_base + low_size - 1; +- +- return 0; +-} +- + /* + * reserve_crashkernel() - reserves memory for crash kernel + * +@@ -1332,122 +1310,25 @@ static int __init reserve_crashkernel_lo + * line parameter. The memory reserved is used by dump capture kernel when + * primary kernel is crashing. + */ +-static void __init reserve_crashkernel(void) ++static void __init arch_reserve_crashkernel(void) + { +- unsigned long long crash_base = 0; +- unsigned long long crash_size = 0; +- unsigned long long crash_low_size = 0; +- unsigned long search_start = memblock_start_of_DRAM(); +- unsigned long search_end = (unsigned long)dma32_phys_limit; ++ unsigned long long low_size = 0; ++ unsigned long long crash_base, crash_size; + char *cmdline = boot_command_line; +- bool fixed_base = false; + bool high = false; +- +- int ret = 0; ++ int ret; + + if (!IS_ENABLED(CONFIG_KEXEC_CORE)) + return; +- /* +- * Don't reserve a region for a crash kernel on a crash kernel +- * since it doesn't make much sense and we have limited memory +- * resources. +- */ +- if (is_kdump_kernel()) { +- pr_info("crashkernel: ignoring reservation request\n"); +- return; +- } + + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), +- &crash_size, &crash_base, NULL, NULL); +- if (ret == -ENOENT) { +- /* Fallback to crashkernel=X,[high,low] */ +- ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); +- if (ret || !crash_size) +- return; +- +- /* +- * crashkernel=Y,low is valid only when crashkernel=X,high +- * is passed. +- */ +- ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base); +- if (ret == -ENOENT) +- crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; +- else if (ret) +- return; +- +- search_start = (unsigned long)dma32_phys_limit; +- search_end = memblock_end_of_DRAM(); +- high = true; +- } else if (ret || !crash_size) { +- /* Invalid argument value specified */ ++ &crash_size, &crash_base, ++ &low_size, &high); ++ if (ret) + return; +- } +- +- crash_size = PAGE_ALIGN(crash_size); +- +- if (crash_base) { +- fixed_base = true; +- search_start = crash_base; +- search_end = crash_base + crash_size; +- } +- +- /* +- * Current riscv boot protocol requires 2MB alignment for +- * RV64 and 4MB alignment for RV32 (hugepage size) +- * +- * Try to alloc from 32bit addressible physical memory so that +- * swiotlb can work on the crash kernel. +- */ +- crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, +- search_start, search_end); +- if (crash_base == 0) { +- /* +- * For crashkernel=size[KMG]@offset[KMG], print out failure +- * message if can't reserve the specified region. +- */ +- if (fixed_base) { +- pr_warn("crashkernel: allocating failed with given size@offset\n"); +- return; +- } +- +- if (high) { +- /* +- * For crashkernel=size[KMG],high, if the first attempt was +- * for high memory, fall back to low memory. +- */ +- search_start = memblock_start_of_DRAM(); +- search_end = (unsigned long)dma32_phys_limit; +- } else { +- /* +- * For crashkernel=size[KMG], if the first attempt was for +- * low memory, fall back to high memory, the minimum required +- * low memory will be reserved later. +- */ +- search_start = (unsigned long)dma32_phys_limit; +- search_end = memblock_end_of_DRAM(); +- crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; +- } +- +- crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, +- search_start, search_end); +- if (crash_base == 0) { +- pr_warn("crashkernel: couldn't allocate %lldKB\n", +- crash_size >> 10); +- return; +- } +- } +- +- if ((crash_base >= dma32_phys_limit) && crash_low_size && +- reserve_crashkernel_low(crash_low_size)) { +- memblock_phys_free(crash_base, crash_size); +- return; +- } +- +- pr_info("crashkernel: reserved 0x%016llx - 0x%016llx (%lld MB)\n", +- crash_base, crash_base + crash_size, crash_size >> 20); + +- crashk_res.start = crash_base; +- crashk_res.end = crash_base + crash_size - 1; ++ reserve_crashkernel_generic(cmdline, crash_size, crash_base, ++ low_size, high); + } + + void __init paging_init(void) +@@ -1465,7 +1346,7 @@ void __init misc_mem_init(void) + arch_numa_init(); + sparse_init(); + zone_sizes_init(); +- reserve_crashkernel(); ++ arch_reserve_crashkernel(); + memblock_dump_all(); + } + diff --git a/patches.suse/x86-kdump-use-generic-interface-to-simplify-crashkernel-reservation-code.patch b/patches.suse/x86-kdump-use-generic-interface-to-simplify-crashkernel-reservation-code.patch new file mode 100644 index 0000000..40f2e39 --- /dev/null +++ b/patches.suse/x86-kdump-use-generic-interface-to-simplify-crashkernel-reservation-code.patch @@ -0,0 +1,286 @@ +From: Baoquan He +Date: Thu, 14 Sep 2023 11:31:39 +0800 +Subject: x86: kdump: use generic interface to simplify crashkernel reservation + code +Git-commit: 9c08a2a139fe83f217625ee0352ce531b9a666ea +Patch-mainline: v6.7-rc1 +References: jsc#PED-7249 + +With the help of newly changed function parse_crashkernel() and generic +reserve_crashkernel_generic(), crashkernel reservation can be simplified +by steps: + +1) Add a new header file , and define CRASH_ALIGN, + CRASH_ADDR_LOW_MAX, CRASH_ADDR_HIGH_MAX and + DEFAULT_CRASH_KERNEL_LOW_SIZE in ; + +2) Add arch_reserve_crashkernel() to call parse_crashkernel() and + reserve_crashkernel_generic(), and do the ARCH specific work if + needed. + +3) Add ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION Kconfig in + arch/x86/Kconfig. + +When adding DEFAULT_CRASH_KERNEL_LOW_SIZE, add crash_low_size_default() to +calculate crashkernel low memory because x86_64 has special requirement. + +The old reserve_crashkernel_low() and reserve_crashkernel() can be +removed. + +[bhe@redhat.com: move crash_low_size_default() code into ] + Link: https://lkml.kernel.org/r/ZQpeAjOmuMJBFw1/@MiWiFi-R3L-srv +Link: https://lkml.kernel.org/r/20230914033142.676708-7-bhe@redhat.com +Signed-off-by: Baoquan He +Cc: Catalin Marinas +Cc: Chen Jiahao +Cc: Zhen Lei +Signed-off-by: Andrew Morton +Acked-by: Jiri Bohac +--- + arch/x86/Kconfig | 3 + + arch/x86/include/asm/crash_core.h | 42 +++++++++++ + arch/x86/kernel/setup.c | 148 +++----------------------------------- + 3 files changed, 56 insertions(+), 137 deletions(-) + +diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig +index 66bfabae8814..36b2f12f31c3 100644 +--- a/arch/x86/Kconfig ++++ b/arch/x86/Kconfig +@@ -2062,6 +2062,9 @@ config ARCH_SUPPORTS_CRASH_DUMP + config ARCH_SUPPORTS_CRASH_HOTPLUG + def_bool y + ++config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ++ def_bool CRASH_CORE ++ + config PHYSICAL_START + hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) + default "0x1000000" +diff --git a/arch/x86/include/asm/crash_core.h b/arch/x86/include/asm/crash_core.h +new file mode 100644 +index 000000000000..76af98f4e801 +--- /dev/null ++++ b/arch/x86/include/asm/crash_core.h +@@ -0,0 +1,42 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef _X86_CRASH_CORE_H ++#define _X86_CRASH_CORE_H ++ ++/* 16M alignment for crash kernel regions */ ++#define CRASH_ALIGN SZ_16M ++ ++/* ++ * Keep the crash kernel below this limit. ++ * ++ * Earlier 32-bits kernels would limit the kernel to the low 512 MB range ++ * due to mapping restrictions. ++ * ++ * 64-bit kdump kernels need to be restricted to be under 64 TB, which is ++ * the upper limit of system RAM in 4-level paging mode. Since the kdump ++ * jump could be from 5-level paging to 4-level paging, the jump will fail if ++ * the kernel is put above 64 TB, and during the 1st kernel bootup there's ++ * no good way to detect the paging mode of the target kernel which will be ++ * loaded for dumping. ++ */ ++extern unsigned long swiotlb_size_or_default(void); ++ ++#ifdef CONFIG_X86_32 ++# define CRASH_ADDR_LOW_MAX SZ_512M ++# define CRASH_ADDR_HIGH_MAX SZ_512M ++#else ++# define CRASH_ADDR_LOW_MAX SZ_4G ++# define CRASH_ADDR_HIGH_MAX SZ_64T ++#endif ++ ++# define DEFAULT_CRASH_KERNEL_LOW_SIZE crash_low_size_default() ++ ++static inline unsigned long crash_low_size_default(void) ++{ ++#ifdef CONFIG_X86_64 ++ return max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20); ++#else ++ return 0; ++#endif ++} ++ ++#endif /* _X86_CRASH_CORE_H */ +diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c +index 655c04812905..25a3f9a100f6 100644 +--- a/arch/x86/kernel/setup.c ++++ b/arch/x86/kernel/setup.c +@@ -466,155 +466,29 @@ static void __init memblock_x86_reserve_range_setup_data(void) + } + } + +-/* +- * --------- Crashkernel reservation ------------------------------ +- */ +- +-/* 16M alignment for crash kernel regions */ +-#define CRASH_ALIGN SZ_16M +- +-/* +- * Keep the crash kernel below this limit. +- * +- * Earlier 32-bits kernels would limit the kernel to the low 512 MB range +- * due to mapping restrictions. +- * +- * 64-bit kdump kernels need to be restricted to be under 64 TB, which is +- * the upper limit of system RAM in 4-level paging mode. Since the kdump +- * jump could be from 5-level paging to 4-level paging, the jump will fail if +- * the kernel is put above 64 TB, and during the 1st kernel bootup there's +- * no good way to detect the paging mode of the target kernel which will be +- * loaded for dumping. +- */ +-#ifdef CONFIG_X86_32 +-# define CRASH_ADDR_LOW_MAX SZ_512M +-# define CRASH_ADDR_HIGH_MAX SZ_512M +-#else +-# define CRASH_ADDR_LOW_MAX SZ_4G +-# define CRASH_ADDR_HIGH_MAX SZ_64T +-#endif +- +-static int __init reserve_crashkernel_low(void) ++static void __init arch_reserve_crashkernel(void) + { +-#ifdef CONFIG_X86_64 +- unsigned long long base, low_base = 0, low_size = 0; +- unsigned long low_mem_limit; +- int ret; +- +- low_mem_limit = min(memblock_phys_mem_size(), CRASH_ADDR_LOW_MAX); +- +- /* crashkernel=Y,low */ +- ret = parse_crashkernel_low(boot_command_line, low_mem_limit, &low_size, &base); +- if (ret) { +- /* +- * two parts from kernel/dma/swiotlb.c: +- * -swiotlb size: user-specified with swiotlb= or default. +- * +- * -swiotlb overflow buffer: now hardcoded to 32k. We round it +- * to 8M for other buffers that may need to stay low too. Also +- * make sure we allocate enough extra low memory so that we +- * don't run out of DMA buffers for 32-bit devices. +- */ +- low_size = max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20); +- } else { +- /* passed with crashkernel=0,low ? */ +- if (!low_size) +- return 0; +- } +- +- low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); +- if (!low_base) { +- pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n", +- (unsigned long)(low_size >> 20)); +- return -ENOMEM; +- } +- +- pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (low RAM limit: %ldMB)\n", +- (unsigned long)(low_size >> 20), +- (unsigned long)(low_base >> 20), +- (unsigned long)(low_mem_limit >> 20)); +- +- crashk_low_res.start = low_base; +- crashk_low_res.end = low_base + low_size - 1; +- insert_resource(&iomem_resource, &crashk_low_res); +-#endif +- return 0; +-} +- +-static void __init reserve_crashkernel(void) +-{ +- unsigned long long crash_size, crash_base, total_mem; ++ unsigned long long crash_base, crash_size, low_size = 0; ++ char *cmdline = boot_command_line; + bool high = false; + int ret; + + if (!IS_ENABLED(CONFIG_KEXEC_CORE)) + return; + +- total_mem = memblock_phys_mem_size(); +- +- /* crashkernel=XM */ +- ret = parse_crashkernel(boot_command_line, total_mem, +- &crash_size, &crash_base, NULL, NULL); +- if (ret != 0 || crash_size <= 0) { +- /* crashkernel=X,high */ +- ret = parse_crashkernel_high(boot_command_line, total_mem, +- &crash_size, &crash_base); +- if (ret != 0 || crash_size <= 0) +- return; +- high = true; +- } ++ ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), ++ &crash_size, &crash_base, ++ &low_size, &high); ++ if (ret) ++ return; + + if (xen_pv_domain()) { + pr_info("Ignoring crashkernel for a Xen PV domain\n"); + return; + } + +- /* 0 means: find the address automatically */ +- if (!crash_base) { +- /* +- * Set CRASH_ADDR_LOW_MAX upper bound for crash memory, +- * crashkernel=x,high reserves memory over 4G, also allocates +- * 256M extra low memory for DMA buffers and swiotlb. +- * But the extra memory is not required for all machines. +- * So try low memory first and fall back to high memory +- * unless "crashkernel=size[KMG],high" is specified. +- */ +- if (!high) +- crash_base = memblock_phys_alloc_range(crash_size, +- CRASH_ALIGN, CRASH_ALIGN, +- CRASH_ADDR_LOW_MAX); +- if (!crash_base) +- crash_base = memblock_phys_alloc_range(crash_size, +- CRASH_ALIGN, CRASH_ALIGN, +- CRASH_ADDR_HIGH_MAX); +- if (!crash_base) { +- pr_info("crashkernel reservation failed - No suitable area found.\n"); +- return; +- } +- } else { +- unsigned long long start; +- +- start = memblock_phys_alloc_range(crash_size, SZ_1M, crash_base, +- crash_base + crash_size); +- if (start != crash_base) { +- pr_info("crashkernel reservation failed - memory is in use.\n"); +- return; +- } +- } +- +- if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) { +- memblock_phys_free(crash_base, crash_size); +- return; +- } +- +- pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n", +- (unsigned long)(crash_size >> 20), +- (unsigned long)(crash_base >> 20), +- (unsigned long)(total_mem >> 20)); +- +- crashk_res.start = crash_base; +- crashk_res.end = crash_base + crash_size - 1; +- insert_resource(&iomem_resource, &crashk_res); ++ reserve_crashkernel_generic(cmdline, crash_size, crash_base, ++ low_size, high); + } + + static struct resource standard_io_resources[] = { +@@ -1228,7 +1102,7 @@ void __init setup_arch(char **cmdline_p) + * Reserve memory for crash kernel after SRAT is parsed so that it + * won't consume hotpluggable memory. + */ +- reserve_crashkernel(); ++ arch_reserve_crashkernel(); + + memblock_find_dma_reserve(); + + diff --git a/scripts/patch-tag b/scripts/patch-tag index 7db3cfd..b0db0c5 100755 --- a/scripts/patch-tag +++ b/scripts/patch-tag @@ -89,9 +89,6 @@ my $VERSION = "0.11"; my $default_comment = "from:subject:patch-mainline:Git-commit:references:signed-off-by:acked-by:reviewed-by:"; my $post_comment_tags = "signed-off-by acked-by reviewed-by"; -# when these are in the bk comment, and non-bk section, use the non-bk one -my $non_dup_tags = "from subject"; - # command line options my %tags; # hash of tags to be replaced my %print_tags; # hash of tags for printing to stdout @@ -109,7 +106,6 @@ my $replace_empty_comment; # new value for empty non-tag comment # globals my @output_array; # the finished comment as printed my @all_tags; # array used to do final tag output -my @bk_footer_tags; # holds signed-off-by and acked-by from bk my %replaced_tags; # copy of %tags so we can detect which ones are found my $replace = 0; # should we overwrite the patch file? my $outfh; # current output file handle (could be a temp file) @@ -197,40 +193,15 @@ sub process_tag($$) { delete $replaced_tags{$t}; } -# tags that get pulled from bk comments get special treatment -sub process_bk_tag($$) { - my ($tag, $value) = @_; - my $always_tags = "signed-off-by acked-by reviewed-by"; - - if ($always_tags =~ m/$tag/) { - push @bk_footer_tags, [$tag, $value]; - return; - } - # don't pull the bk tag out if it already exists - foreach my $v (@all_tags) { - $v =~ m/$tag_re/; - my $t = $1; - if (lc($t) eq $tag) { - return; - } - } - $replaced_tags{$tag} = $value; -} - # look for any tags that we were asked to print or replace from # the command line. Build the array of tags found in the comment sub check_tags($$$) { my ($infh, $buf, $line) = @_; - my $filespec = ""; - my $bk_comment = 0; my $orig_line; - my $bkold_style = 0; again: $orig_line = $line; - if ($bk_comment) { - $line =~ s/^#\s*//; - } + # Preserve git From line if ($line =~ m/$git_re/) { push @output_array, $orig_line; @@ -246,77 +217,9 @@ again: $line =~ m/(^[^:\s#]*):\s*(.*)/s; my $lc_tag = lc($1); my $value = $2; - if ($bk_comment) { - # only pull out specific tags from the bk comment stream - if ($post_comment_tags =~ m/$lc_tag/) { - process_bk_tag($lc_tag, $value); - } - if (!%print_tags) { - push @output_array, $orig_line; - } - } else { - process_tag($lc_tag, $value); - } + process_tag($lc_tag, $value); } elsif (!%print_tags) { push @output_array, $orig_line; - } - # did we find a bitkeeper style patch header? - # if so, just parse the whole thing here - if ($line =~ m/^# The following is the BitKeeper ChangeSet Log/ || - $line =~ m/^# This is a BitKeeper generated diff -Nru style patch/) { - # there are two bk patch styles - # old: - # # ------------------- - # # date author changset - # # subject - # new: - # # - # # Changeset - # # date time author - # # subject - - $bk_comment = 1; - my $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - if ($next =~ m/^# ---------/) { - $bkold_style = 1; - } else { - # read empty line - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - } - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - my @words = split /\s+/, $next; - if ($bkold_style) { - process_bk_tag('from', $words[2]); - } else { - process_bk_tag('from', $words[3]); - } - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - chomp($next); - $next =~ s/^#\s*//; - # sometimes the bk comment is empty and there is just a filename - # there's no good way to tell. - if (!($next =~ m/(.*\/)+?.*?\.(c|h|s)$/)) { - process_bk_tag('subject', $next); - } - - # we've read the from tag and subject tag, the goto again - # will loop through the ChangeSet Log section looking - # for other tags - } - if ($bk_comment) { - $line = read_next_line($infh, $buf); - # old style bk comments end with a line full of dashes - # new style bk comments end with a # filename or no # at all - if (($bkold_style && $line =~ m/^# --------/) || - (!$bkold_style && $line =~ m/^# \S|^[^#]/)) { - push @$buf, $line; - return; - } - goto again; } } @@ -645,7 +548,6 @@ foreach my $guarded_input (@files) { %replaced_tags = (%tags, %add_tags); @all_tags = (); @output_array = (); - @bk_footer_tags = (); my %tmp_always_add = %always_add_tags; if ($replace) { @@ -679,9 +581,6 @@ foreach my $guarded_input (@files) { while($output_array[scalar(@output_array)-1] =~ m/^\s*\n$/) { pop @output_array; } - foreach my $h (@bk_footer_tags) { - process_tag($h->[0], $h->[1]); - } # add any new tags left over, but do From and Subject first add_output_tag('from', \%replaced_tags); add_output_tag('subject', \%replaced_tags); diff --git a/scripts/sequence-patch.sh b/scripts/sequence-patch.sh index bdfac19..8e6bc7c 100755 --- a/scripts/sequence-patch.sh +++ b/scripts/sequence-patch.sh @@ -499,7 +499,7 @@ fi # Create fresh $SCRATCH_AREA/linux-$SRCVERSION. if ! [ -d $ORIG_DIR ]; then unpack_tarball "$SRCVERSION" "$ORIG_DIR" "$URL" - find $ORIG_DIR -type f | xargs chmod a-w,a+r + find $ORIG_DIR -type f -exec chmod a-w,a+r {} + fi if $VANILLA; then diff --git a/series.conf b/series.conf index d1901f8..2e70a4c 100644 --- a/series.conf +++ b/series.conf @@ -545,6 +545,7 @@ patches.suse/arm64-module-mandate-MODULE_PLTS.patch patches.suse/arm64-module-rework-module-VA-range-selection.patch patches.suse/ACPI-bus-Consolidate-all-arm-specific-initialisation.patch + patches.suse/arm64-kdump-simplify-the-reservation-behaviour-of-crashkernel-high.patch patches.suse/arm64-signal-Restore-TPIDR2-register-rather-tha.patch patches.suse/ACPI-scan-Reduce-overhead-related-to-devices-with-de.patch patches.suse/ACPI-PM-s2idle-fix-section-mismatch-warning.patch @@ -10305,6 +10306,7 @@ patches.suse/NFSv4.2-fix-handling-of-COPY-ERR_OFFLOAD_NO_REQ.patch patches.suse/pNFS-Fix-assignment-of-xprtdata.cred.patch patches.suse/perf-tests-Adapt-mmap-basic.c-for-riscv.patch + patches.suse/riscv-kdump-Implement-crashkernel-X-high-low.patch patches.suse/platform-x86-intel-tpmi-Read-feature-control-status.patch patches.suse/platform-x86-intel-tpmi-Add-debugfs-interface.patch patches.suse/platform-x86-dell-sysman-Fix-reference-leak.patch @@ -15380,6 +15382,15 @@ patches.suse/mm-migrate-record-the-mlocked-page-status-to-remove-unnecessary-lru-drain.patch patches.suse/minmax-deduplicate-__unconst_integer_typeof.patch patches.suse/minmax-fix-header-inclusions.patch + patches.suse/crash_core.c-remove-unnecessary-parameter-of-function.patch + patches.suse/crash_core-change-the-prototype-of-function-parse_crashkernel.patch + patches.suse/crash_core-change-parse_crashkernel-to-support-crashkernel-high-low-parsing.patch + patches.suse/crash_core-add-generic-function-to-do-reservation.patch + patches.suse/crash_core-move-crashk_-res-definition-into-crash_core.c.patch + patches.suse/x86-kdump-use-generic-interface-to-simplify-crashkernel-reservation-code.patch + patches.suse/arm64-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch + patches.suse/riscv-kdump-use-generic-interface-to-simplify-crashkernel-reservation.patch + patches.suse/crash_core.c-remove-unneeded-functions.patch patches.suse/minmax-add-umin-a-b-and-umax-a-b.patch patches.suse/minmax-allow-min-max-clamp-if-the-arguments-have-the.patch patches.suse/minmax-fix-indentation-of-__cmp_once-and-__clamp_onc.patch @@ -17081,6 +17092,7 @@ patches.suse/ALSA-hda-tas2781-call-cleanup-functions-only-once.patch patches.suse/ALSA-hda-tas2781-reset-the-amp-before-component_add.patch patches.suse/kexec-drop-dependency-on-ARCH_SUPPORTS_KEXEC-from-CR.patch + patches.suse/crash_core-fix-the-check-for-whether-crashkernel-is-from-high-memory.patch patches.suse/mm-shmem-fix-race-in-shmem_undo_range-w-THP.patch patches.suse/io_uring-poll-don-t-enable-lazy-wake-for-POLLEXCLUSI.patch patches.suse/PCI-loongson-Limit-MRRS-to-256.patch @@ -18467,6 +18479,7 @@ patches.suse/locktorture-Increase-Hamming-distance-between-call_r.patch patches.suse/rcutorture-Add-fqs_holdoff-check-before-fqs_task-is-.patch patches.suse/srcu-Use-try-lock-lockdep-annotation-for-NMI-safe-access.patch + patches.suse/kdump-defer-the-insertion-of-crashkernel-resources.patch patches.suse/scripts-decode_stacktrace.sh-optionally-use-LLVM-uti.patch patches.suse/kernel-crash_core.c-make-__crash_hotplug_lock-static.patch patches.suse/selftests-mm-hugepage-vmemmap-fails-on-64K-page-size.patch @@ -20041,6 +20054,13 @@ # masahiroy/linux-kbuild for-next patches.suse/kbuild-Use-fmin-function-alignment-when-available.patch + # out-of-tree patches + patches.suse/kdump-add-crashkernel-cma-suffix.patch + patches.suse/kdump-implement-reserve_crashkernel_cma.patch + patches.suse/kdump-x86-implement-crashkernel-cma-reservation.patch + patches.suse/kdump-crashkernel-cma-update-Documentation.patch + patches.suse/kdump-wait-for-dma-to-time-out-when-using-cma.patch + ######################################################## # end of sorted patches ########################################################