[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230602102656.131654-4-lizhijian@fujitsu.com>
Date: Fri, 2 Jun 2023 18:26:52 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: kexec@...ts.infradead.org, nvdimm@...ts.linux.dev
Cc: linux-kernel@...r.kernel.org, dan.j.williams@...el.com,
bhe@...hat.com, ruansy.fnst@...itsu.com, y-goto@...itsu.com,
yangx.jy@...itsu.com, Li Zhijian <lizhijian@...itsu.com>,
Eric Biederman <ebiederm@...ssion.com>
Subject: [RFC PATCH v3 3/3] kernel/kexec_file: Mark pmem region with new flag PF_DEV
For pmem, metadata is specific to the namespace rather than the entire
pmem region. Therefore, ranges that have not yet created a namespace or
are unusable due to alignment reasons will not be associated with metadata.
When an application attempts to access regions that do not have
corresponding metadata, it will encounter an access error. With this flag,
the dumping applications are able to know this access error, and then
take special actions correspondingly.
This is kexec_file_load() specific, for the traditional kexec_load(),
kexec-tools will have a similar change.
CC: Eric Biederman <ebiederm@...ssion.com>
CC: Baoquan He <bhe@...hat.com>
CC: kexec@...ts.infradead.org
Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
---
kernel/kexec_file.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index f989f5f1933b..0d5b516b96ee 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;
--
2.29.2
Powered by blists - more mailing lists