Blame SOURCES/kexec-tools-2.0.15-makedumpfile-Prepare-paddr_to_vaddr-for-arch-specific-p2v-c.patch

8215ad
From 9eb5a31bc2d7f6af88459b89c414fe144e7491f8 Mon Sep 17 00:00:00 2001
8215ad
From: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
8215ad
Date: Thu, 8 Nov 2018 14:26:43 -0500
8215ad
Subject: [PATCH] [PATCH] Prepare paddr_to_vaddr() for arch-specific p2v conversion
8215ad
8215ad
Currently, conversion from physical address to virtual address in
8215ad
--mem-usage option is "paddr + PAGE_OFFSET", which was written for
8215ad
x86_64, but it's not suitable especially for arm64.
8215ad
8215ad
This patch introduces paddr_to_vaddr() macro to get prepared for
8215ad
arch-specific physical to virtual conversion.
8215ad
8215ad
Tested-by: Bhupesh Sharma <bhsharma@redhat.com>
8215ad
Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
8215ad
---
8215ad
 elf_info.c     |  7 ++++---
8215ad
 makedumpfile.h | 11 +++++++++++
8215ad
 2 files changed, 15 insertions(+), 3 deletions(-)
8215ad
8215ad
diff --git a/makedumpfile-1.6.2/elf_info.c b/makedumpfile-1.6.2/elf_info.c
8215ad
index 711601a170c7..1d33e96684b6 100644
8215ad
--- a/makedumpfile-1.6.2/elf_info.c
8215ad
+++ b/makedumpfile-1.6.2/elf_info.c
8215ad
@@ -372,7 +372,7 @@ int set_kcore_vmcoreinfo(uint64_t vmcoreinfo_addr, uint64_t vmcoreinfo_len)
8215ad
	off_t offset_desc;
8215ad
8215ad
	offset = UNINITIALIZED;
8215ad
-	kvaddr = (ulong)vmcoreinfo_addr + PAGE_OFFSET;
8215ad
+	kvaddr = paddr_to_vaddr(vmcoreinfo_addr);
8215ad
8215ad
	for (i = 0; i < num_pt_loads; ++i) {
8215ad
		struct pt_load_segment *p = &pt_loads[i];
8215ad
@@ -810,10 +810,11 @@ static int exclude_segment(struct pt_load_segment **pt_loads,
8215ad
	int i, j, tidx = -1;
8215ad
	unsigned long long	vstart, vend, kvstart, kvend;
8215ad
	struct pt_load_segment temp_seg = {0};
8215ad
-	kvstart = (ulong)start + PAGE_OFFSET;
8215ad
-	kvend = (ulong)end + PAGE_OFFSET;
8215ad
	unsigned long size;
8215ad
8215ad
+	kvstart = paddr_to_vaddr(start);
8215ad
+	kvend = paddr_to_vaddr(end);
8215ad
+
8215ad
	for (i = 0; i < (*num_pt_loads); i++) {
8215ad
		vstart = (*pt_loads)[i].virt_start;
8215ad
		vend = (*pt_loads)[i].virt_end;
8215ad
diff --git a/makedumpfile-1.6.2/makedumpfile.h b/makedumpfile-1.6.2/makedumpfile.h
8215ad
index 5f7a1dcf3b2f..010a9ce302bd 100644
8215ad
--- a/makedumpfile-1.6.2/makedumpfile.h
8215ad
+++ b/makedumpfile-1.6.2/makedumpfile.h
8215ad
@@ -929,6 +929,8 @@ typedef unsigned long pgd_t;
8215ad
 static inline int stub_true() { return TRUE; }
8215ad
 static inline int stub_true_ul(unsigned long x) { return TRUE; }
8215ad
 static inline int stub_false() { return FALSE; }
8215ad
+#define paddr_to_vaddr_general(X) ((X) + PAGE_OFFSET)
8215ad
+
8215ad
 #ifdef __aarch64__
8215ad
 int get_phys_base_arm64(void);
8215ad
 int get_machdep_info_arm64(void);
8215ad
@@ -938,6 +940,7 @@ int get_xen_basic_info_arm64(void);
8215ad
 int get_xen_info_arm64(void);
8215ad
 #define find_vmemmap()		stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_arm64(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define get_phys_base()		get_phys_base_arm64()
8215ad
 #define get_machdep_info()	get_machdep_info_arm64()
8215ad
 #define get_versiondep_info()	get_versiondep_info_arm64()
8215ad
@@ -958,6 +961,7 @@ unsigned long long vaddr_to_paddr_arm(unsigned long vaddr);
8215ad
 #define get_versiondep_info()	stub_true()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_arm(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif /* arm */
8215ad
@@ -972,6 +976,7 @@ unsigned long long vaddr_to_paddr_x86(unsigned long vaddr);
8215ad
 #define get_versiondep_info()	get_versiondep_info_x86()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_x86(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif /* x86 */
8215ad
@@ -989,6 +994,7 @@ unsigned long long vtop4_x86_64_pagetable(unsigned long vaddr, unsigned long pag
8215ad
 #define get_versiondep_info()	get_versiondep_info_x86_64()
8215ad
 #define get_kaslr_offset(X)	get_kaslr_offset_x86_64(X)
8215ad
 #define vaddr_to_paddr(X)	vtop4_x86_64(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif /* x86_64 */
8215ad
@@ -1004,6 +1010,7 @@ int arch_crashkernel_mem_size_ppc64(void);
8215ad
 #define get_versiondep_info()	get_versiondep_info_ppc64()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ppc64(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	arch_crashkernel_mem_size_ppc64()
8215ad
 #endif          /* powerpc64 */
8215ad
@@ -1017,6 +1024,7 @@ unsigned long long vaddr_to_paddr_ppc(unsigned long vaddr);
8215ad
 #define get_versiondep_info()	stub_true()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ppc(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif          /* powerpc32 */
8215ad
@@ -1031,6 +1039,7 @@ int is_iomem_phys_addr_s390x(unsigned long addr);
8215ad
 #define get_versiondep_info()	stub_true()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_s390x(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		is_iomem_phys_addr_s390x(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif          /* s390x */
8215ad
@@ -1045,6 +1054,7 @@ unsigned long long vaddr_to_paddr_ia64(unsigned long vaddr);
8215ad
 #define get_versiondep_info()	stub_true()
8215ad
 #define get_kaslr_offset(X)	stub_false()
8215ad
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ia64(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define VADDR_REGION(X)		(((unsigned long)(X)) >> REGION_SHIFT)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
@@ -1059,6 +1069,7 @@ unsigned long long vaddr_to_paddr_sparc64(unsigned long vaddr);
8215ad
 #define get_phys_base()         get_phys_base_sparc64()
8215ad
 #define get_versiondep_info()   get_versiondep_info_sparc64()
8215ad
 #define vaddr_to_paddr(X)       vaddr_to_paddr_sparc64(X)
8215ad
+#define paddr_to_vaddr(X)	paddr_to_vaddr_general(X)
8215ad
 #define is_phys_addr(X)		stub_true_ul(X)
8215ad
 #define arch_crashkernel_mem_size()	stub_false()
8215ad
 #endif		/* sparc64 */
8215ad
--
8215ad
2.7.4