arm64, crash: wrap crash dumping code into crash related ifdefs
authorBaoquan He <bhe@redhat.com>
Wed, 24 Jan 2024 05:12:47 +0000 (13:12 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 24 Feb 2024 01:48:23 +0000 (17:48 -0800)
Now crash codes under kernel/ folder has been split out from kexec
code, crash dumping can be separated from kexec reboot in config
items on arm64 with some adjustments.

Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery.

[bhe@redhat.com: fix building error in generic codes]
Link: https://lkml.kernel.org/r/20240129135033.157195-2-bhe@redhat.com
Link: https://lkml.kernel.org/r/20240124051254.67105-8-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Pingfan Liu <piliu@redhat.com>
Cc: Klara Modin <klarasmodin@gmail.com>
Cc: Michael Kelley <mhklinux@outlook.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/arm64/include/asm/kexec.h
arch/arm64/kernel/machine_kexec.c
arch/arm64/kernel/machine_kexec_file.c
arch/arm64/mm/init.c
drivers/of/kexec.c
kernel/kexec_file.c

index 9ac9572a3bbee2caec02b6d5797e84bfd5194f6b..4d9cc7a76d9ca16c78bc38ab06d68fb9ba08bd79 100644 (file)
@@ -80,7 +80,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
        }
 }
 
-#if defined(CONFIG_KEXEC_CORE) && defined(CONFIG_HIBERNATION)
+#if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_HIBERNATION)
 extern bool crash_is_nosave(unsigned long pfn);
 extern void crash_prepare_suspend(void);
 extern void crash_post_resume(void);
index b38aae5b488d074dc6e4d36f44d741ea200acaf9..82e2203d86a31f830435f0d6b0bd31414ddda31f 100644 (file)
@@ -255,7 +255,7 @@ void machine_crash_shutdown(struct pt_regs *regs)
        pr_info("Starting crashdump kernel...\n");
 }
 
-#ifdef CONFIG_HIBERNATION
+#if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_HIBERNATION)
 /*
  * To preserve the crash dump kernel image, the relevant memory segments
  * should be mapped again around the hibernation.
index 0e017358f4ba64ed07fb2d0626725b680810c681..af1ca875c52ce2c7c1044cc021fbbd7f987848e2 100644 (file)
@@ -39,6 +39,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)
        return kexec_image_post_load_cleanup_default(image);
 }
 
+#ifdef CONFIG_CRASH_DUMP
 static int prepare_elf_headers(void **addr, unsigned long *sz)
 {
        struct crash_mem *cmem;
@@ -80,6 +81,7 @@ out:
        kfree(cmem);
        return ret;
 }
+#endif
 
 /*
  * Tries to add the initrd and DTB to the image. If it is not possible to find
@@ -93,8 +95,8 @@ int load_other_segments(struct kimage *image,
                        char *cmdline)
 {
        struct kexec_buf kbuf;
-       void *headers, *dtb = NULL;
-       unsigned long headers_sz, initrd_load_addr = 0, dtb_len,
+       void *dtb = NULL;
+       unsigned long initrd_load_addr = 0, dtb_len,
                      orig_segments = image->nr_segments;
        int ret = 0;
 
@@ -102,7 +104,10 @@ int load_other_segments(struct kimage *image,
        /* not allocate anything below the kernel */
        kbuf.buf_min = kernel_load_addr + kernel_size;
 
+#ifdef CONFIG_CRASH_DUMP
        /* load elf core header */
+       void *headers;
+       unsigned long headers_sz;
        if (image->type == KEXEC_TYPE_CRASH) {
                ret = prepare_elf_headers(&headers, &headers_sz);
                if (ret) {
@@ -130,6 +135,7 @@ int load_other_segments(struct kimage *image,
                kexec_dprintk("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
                              image->elf_load_addr, kbuf.bufsz, kbuf.memsz);
        }
+#endif
 
        /* load initrd */
        if (initrd) {
index 74c1db8ce271d8c5b0ea19dda0dbf7d3fa5f5230..c1f6213e77f32862743bf15cf0085b81ebc62d92 100644 (file)
@@ -100,7 +100,7 @@ static void __init arch_reserve_crashkernel(void)
        bool high = false;
        int ret;
 
-       if (!IS_ENABLED(CONFIG_KEXEC_CORE))
+       if (!IS_ENABLED(CONFIG_CRASH_RESERVE))
                return;
 
        ret = parse_crashkernel(cmdline, memblock_phys_mem_size(),
index 68278340cecfe5c8a20805c4ef85633b257c5d4b..9ccde2fd77cbf5117b70af2c815b317e87f2c363 100644 (file)
@@ -395,6 +395,7 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
                if (ret)
                        goto out;
 
+#ifdef CONFIG_CRASH_DUMP
                /* add linux,usable-memory-range */
                ret = fdt_appendprop_addrrange(fdt, 0, chosen_node,
                                "linux,usable-memory-range", crashk_res.start,
@@ -410,6 +411,7 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
                        if (ret)
                                goto out;
                }
+#endif
        }
 
        /* add bootargs */
index ce7ce2ae27cdfee2d369c2c80560ee2ae2e0e211..2d1db05fbf04f35d20bf941314ea9b591e0c220d 100644 (file)
@@ -540,8 +540,10 @@ static int kexec_walk_memblock(struct kexec_buf *kbuf,
        phys_addr_t mstart, mend;
        struct resource res = { };
 
+#ifdef CONFIG_CRASH_DUMP
        if (kbuf->image->type == KEXEC_TYPE_CRASH)
                return func(&crashk_res, kbuf);
+#endif
 
        /*
         * Using MEMBLOCK_NONE will properly skip MEMBLOCK_DRIVER_MANAGED. See