Only the region described by PT_LOADs of /proc/vmcore are dumpable/readble
by dumping applications. Previously, on x86/x86_64 only system ram resources
will be injected into PT_LOADs.
So in order to make the entire pmem resource is dumpable/readable, we need
to add pmem region into the PT_LOADs of /proc/vmcore.

Here we introduce a new API walk_pmem_res() to sort out the pmem region. Note
that, unlike other walk_xxx_res() API in resource.c, we walk through
pmem resources without IORESOUCE_BUSY flag.

This is kexec_file_load() specific, for kexec_load(), kexec-tools will have a
similar change.

CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: "H. Peter Anvin" <[email protected]>
CC: Baoquan He <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
 arch/x86/kernel/crash.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index cdd92ab43cda..97763ea804c6 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -168,6 +168,17 @@ static int get_nr_ram_ranges_callback(struct resource 
*res, void *arg)
        return 0;
 }
 
+/*
+ * This function calls the @func callback against all memory ranges, which
+ * are ranges marked as IORESOURCE_MEM and IORES_DESC_PERSISTENT_MEMORY.
+ */
+static int walk_pmem_res(u64 start, u64 end, void *arg,
+                        int (*func)(struct resource *, void *))
+{
+       return walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY, IORESOURCE_MEM,
+                                  start, end, arg, func);
+}
+
 /* Gather all the required information to prepare elf headers for ram regions 
*/
 static struct crash_mem *fill_up_crash_elf_data(void)
 {
@@ -178,6 +189,7 @@ static struct crash_mem *fill_up_crash_elf_data(void)
        if (!nr_ranges)
                return NULL;
 
+       walk_pmem_res(0, -1, &nr_ranges, get_nr_ram_ranges_callback);
        /*
         * Exclusion of crash region and/or crashk_low_res may cause
         * another range split. So add extra two slots here.
@@ -243,6 +255,7 @@ static int prepare_elf_headers(struct kimage *image, void 
**addr,
        ret = walk_system_ram_res(0, -1, cmem, 
prepare_elf64_ram_headers_callback);
        if (ret)
                goto out;
+       walk_pmem_res(0, -1, cmem, prepare_elf64_ram_headers_callback);
 
        /* Exclude unwanted mem ranges */
        ret = elf_header_exclude_ranges(cmem);
-- 
2.29.2


Reply via email to