From: Li Zhijian <lizhijian@fujitsu.com>
To: x86@kernel.org, nvdimm@lists.linux.dev, kexec@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, y-goto@fujitsu.com,
yangx.jy@fujitsu.com, ruansy.fnst@fujitsu.com,
Li Zhijian <lizhijian@fujitsu.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Eric Biederman <ebiederm@xmission.com>,
Takashi Iwai <tiwai@suse.de>, Baoquan He <bhe@redhat.com>,
Vlastimil Babka <vbabka@suse.cz>,
Sean Christopherson <seanjc@google.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Ira Weiny <ira.weiny@intel.com>,
Raul E Rangel <rrangel@chromium.org>,
Colin Foster <colin.foster@in-advantage.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [RFC PATCH v2 3/3] resource, crash: Make kexec_file_load support pmem
Date: Thu, 27 Apr 2023 18:18:34 +0800 [thread overview]
Message-ID: <20230427101838.12267-4-lizhijian@fujitsu.com> (raw)
In-Reply-To: <20230427101838.12267-1-lizhijian@fujitsu.com>
It does:
1. Add pmem region into PT_LOADs of vmcore
2. Mark pmem region's p_flags as PF_DEV
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: Borislav Petkov <bp@alien8.de>
CC: Dave Hansen <dave.hansen@linux.intel.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Eric Biederman <ebiederm@xmission.com>
CC: Takashi Iwai <tiwai@suse.de>
CC: Baoquan He <bhe@redhat.com>
CC: Vlastimil Babka <vbabka@suse.cz>
CC: Sean Christopherson <seanjc@google.com>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: "Rafael J. Wysocki" <rafael@kernel.org>
CC: Ira Weiny <ira.weiny@intel.com>
CC: Raul E Rangel <rrangel@chromium.org>
CC: Colin Foster <colin.foster@in-advantage.com>
CC: Vishal Verma <vishal.l.verma@intel.com>
CC: x86@kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
arch/x86/kernel/crash.c | 2 ++
include/linux/ioport.h | 3 +++
kernel/kexec_file.c | 10 ++++++++++
kernel/resource.c | 11 +++++++++++
4 files changed, 26 insertions(+)
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index cdd92ab43cda..dc9d03083565 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -178,6 +178,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 +244,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);
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 25d768d48970..bde88a47cc1a 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -331,6 +331,9 @@ extern int
walk_system_ram_res(u64 start, u64 end, void *arg,
int (*func)(struct resource *, void *));
extern int
+walk_pmem_res(u64 start, u64 end, void *arg,
+ int (*func)(struct resource *, void *));
+extern int
walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end,
void *arg, int (*func)(struct resource *, void *));
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index f1a0e4e3fb5c..e79ceaee2926 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -29,6 +29,8 @@
#include <linux/vmalloc.h>
#include "kexec_internal.h"
+#define PF_DEV (1 << 4)
+
#ifdef CONFIG_KEXEC_SIG
static bool sig_enforce = IS_ENABLED(CONFIG_KEXEC_SIG_FORCE);
@@ -1221,6 +1223,12 @@ int crash_exclude_mem_range(struct crash_mem *mem,
return 0;
}
+static bool is_pmem_range(u64 start, u64 size)
+{
+ return REGION_INTERSECTS == region_intersects(start, size,
+ IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY);
+}
+
int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
void **addr, unsigned long *sz)
{
@@ -1302,6 +1310,8 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
phdr->p_type = PT_LOAD;
phdr->p_flags = PF_R|PF_W|PF_X;
+ if (is_pmem_range(mstart, mend - mstart))
+ phdr->p_flags |= PF_DEV;
phdr->p_offset = mstart;
phdr->p_paddr = mstart;
diff --git a/kernel/resource.c b/kernel/resource.c
index b1763b2fd7ef..f3f1ce6fc384 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -431,6 +431,17 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,
func);
}
+/*
+ * This function calls the @func callback against all memory ranges, which
+ * are ranges marked as IORESOURCE_MEM and IORES_DESC_PERSISTENT_MEMORY.
+ */
+int walk_pmem_res(u64 start, u64 end, void *arg,
+ int (*func)(struct resource *, void *))
+{
+ return __walk_iomem_res_desc(start, end, IORESOURCE_MEM,
+ IORES_DESC_PERSISTENT_MEMORY, arg, func);
+}
+
/*
* This function calls the @func callback against all memory ranges, which
* are ranges marked as IORESOURCE_MEM and IORESOUCE_BUSY.
--
2.29.2
next prev parent reply other threads:[~2023-04-27 10:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 10:18 [RFC PATCH v2 0/3] pmem memmap dump support Li Zhijian
2023-04-27 10:18 ` [RFC PATCH v2 1/3] crash: export dev memmap header to vmcoreinfo Li Zhijian
2023-04-27 10:18 ` [RFC PATCH v2 2/3] drivers/nvdimm: export memmap of namespace " Li Zhijian
2023-04-27 22:50 ` Ira Weiny
2023-04-28 7:01 ` Zhijian Li (Fujitsu)
2023-04-27 10:18 ` Li Zhijian [this message]
2023-04-27 11:39 ` [RFC PATCH v2 3/3] resource, crash: Make kexec_file_load support pmem Greg Kroah-Hartman
2023-04-28 7:36 ` Zhijian Li (Fujitsu)
2023-04-27 20:41 ` Jane Chu
2023-04-28 7:10 ` Zhijian Li (Fujitsu)
2023-04-27 10:18 ` [RFC PATCH v2 kexec-tools] kexec: Add and mark pmem region into PT_LOADs Li Zhijian
2023-04-27 10:18 ` [RFC PATCH v2 makedumpfile 1/3] elf_info.c: Introduce is_pmem_pt_load_range Li Zhijian
2023-04-27 10:18 ` [RFC PATCH v2 makedumpfile 2/3] makedumpfile.c: Exclude all pmem pages Li Zhijian
2023-04-27 10:18 ` [RFC PATCH v2 makedumpfile 3/3] makedumpfile.c: Allow excluding metadata of pmem region Li Zhijian
2023-04-28 18:59 ` [RFC PATCH v2 0/3] pmem memmap dump support Dan Williams
2023-05-08 9:45 ` Zhijian Li (Fujitsu)
2023-05-10 10:41 ` Zhijian Li (Fujitsu)
2023-05-25 5:36 ` Li, Zhijian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230427101838.12267-4-lizhijian@fujitsu.com \
--to=lizhijian@fujitsu.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=colin.foster@in-advantage.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=ira.weiny@intel.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nvdimm@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=rrangel@chromium.org \
--cc=ruansy.fnst@fujitsu.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=tiwai@suse.de \
--cc=vbabka@suse.cz \
--cc=vishal.l.verma@intel.com \
--cc=x86@kernel.org \
--cc=y-goto@fujitsu.com \
--cc=yangx.jy@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).