diff mbox series

[RFC,v3,3/3] kernel/kexec_file: Mark pmem region with new flag PF_DEV

Message ID 20230602102656.131654-4-lizhijian@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Zhijian Li (Fujitsu) June 2, 2023, 10:26 a.m. UTC
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@xmission.com>
CC: Baoquan He <bhe@redhat.com>
CC: kexec@lists.infradead.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
 kernel/kexec_file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series


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)
 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,
 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;