crash_core: change the prototype of function parse_crashkernel()
authorBaoquan He <bhe@redhat.com>
Thu, 14 Sep 2023 03:31:35 +0000 (11:31 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:41:58 +0000 (10:41 -0700)
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 <bhe@redhat.com>
Reviewed-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chen Jiahao <chenjiahao16@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
14 files changed:
arch/arm/kernel/setup.c
arch/arm64/mm/init.c
arch/ia64/kernel/setup.c
arch/loongarch/kernel/setup.c
arch/mips/kernel/setup.c
arch/powerpc/kernel/fadump.c
arch/powerpc/kexec/core.c
arch/powerpc/mm/nohash/kaslr_booke.c
arch/riscv/mm/init.c
arch/s390/kernel/setup.c
arch/sh/kernel/machine_kexec.c
arch/x86/kernel/setup.c
include/linux/crash_core.h
kernel/crash_core.c

index c66b560..e2bb7af 100644 (file)
@@ -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;
index 8a0f860..801c59c 100644 (file)
@@ -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)
index 5a55ac8..4faea2d 100644 (file)
@@ -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);
index 7783f0a..4de32b0 100644 (file)
@@ -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;
 
index cb871eb..08321c9 100644 (file)
@@ -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;
 
index 3ff2da7..d14eda1 100644 (file)
@@ -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;
 
index de64c79..9346c96 100644 (file)
@@ -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;
index 2fb3eda..b4f2786 100644 (file)
@@ -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)
index 0798bd8..9fe4489 100644 (file)
@@ -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);
index de6ad0f..e555b57 100644 (file)
@@ -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);
index 223c14f..fa3a7b3 100644 (file)
@@ -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;
index b098b1f..655c048 100644 (file)
@@ -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,
index 0c06561..6156355 100644 (file)
@@ -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,
index 5071139..33ced5b 100644 (file)
@@ -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,