Blame SOURCES/kexec-tools-2.0.15-makedumpfile-ppc64-get-the-info-of-mem-reserved-for-.patch

06c2a2
From 0300f611541ad8ec654898eebf03c8345f0263ca Mon Sep 17 00:00:00 2001
06c2a2
From: Pingfan Liu <piliu@redhat.com>
06c2a2
Date: Mon, 21 Aug 2017 12:24:14 +0900
06c2a2
Subject: [PATCH 2/2] [PATCH v2 2/2] ppc64: get the info of mem reserved for
06c2a2
 crashkernel
06c2a2
06c2a2
In kernel, ppc64 does not export the mem layout by ioresource. So we
06c2a2
need to get the mem info for crashkernel from device tree.
06c2a2
06c2a2
Signed-off-by: Pingfan Liu <piliu@redhat.com>
06c2a2
---
06c2a2
 arch/ppc64.c   | 36 ++++++++++++++++++++++++++++++++++++
06c2a2
 makedumpfile.c |  3 +++
06c2a2
 makedumpfile.h | 11 +++++++++++
06c2a2
 3 files changed, 50 insertions(+)
06c2a2
06c2a2
diff --git a/makedumpfile-1.6.2/arch/ppc64.c b/makedumpfile-1.6.2/arch/ppc64.c
06c2a2
index 3fd6002..bacac77 100644
06c2a2
--- a/makedumpfile-1.6.2/arch/ppc64.c
06c2a2
+++ b/makedumpfile-1.6.2/arch/ppc64.c
06c2a2
@@ -617,4 +617,40 @@ vaddr_to_paddr_ppc64(unsigned long vaddr)
06c2a2
 	return ppc64_vtop_level4(vaddr);
06c2a2
 }
06c2a2
 
06c2a2
+int arch_crashkernel_mem_size_ppc64()
06c2a2
+{
06c2a2
+	const char f_crashsize[] = "/proc/device-tree/chosen/linux,crashkernel-size";
06c2a2
+	const char f_crashbase[] = "/proc/device-tree/chosen/linux,crashkernel-base";
06c2a2
+	unsigned long crashk_sz_be, crashk_sz;
06c2a2
+	unsigned long crashk_base_be, crashk_base;
06c2a2
+	uint swap;
06c2a2
+	FILE *fp, *fpb;
06c2a2
+
06c2a2
+	fp = fopen(f_crashsize, "r");
06c2a2
+	if (!fp) {
06c2a2
+		ERRMSG("Cannot open %s\n", f_crashsize);
06c2a2
+		return FALSE;
06c2a2
+	}
06c2a2
+	fpb = fopen(f_crashbase, "r");
06c2a2
+	if (!fp) {
06c2a2
+		ERRMSG("Cannot open %s\n", f_crashbase);
06c2a2
+		fclose(fp);
06c2a2
+		return FALSE;
06c2a2
+	}
06c2a2
+
06c2a2
+	fread(&crashk_sz_be, sizeof(crashk_sz_be), 1, fp);
06c2a2
+	fread(&crashk_base_be, sizeof(crashk_base_be), 1, fpb);
06c2a2
+	fclose(fp);
06c2a2
+	fclose(fpb);
06c2a2
+	/* dev tree is always big endian */
06c2a2
+	swap = !is_bigendian();
06c2a2
+	crashk_sz = swap64(crashk_sz_be, swap);
06c2a2
+	crashk_base = swap64(crashk_base_be, swap);
06c2a2
+	crash_reserved_mem_nr = 1;
06c2a2
+	crash_reserved_mem[0].start = crashk_base;
06c2a2
+	crash_reserved_mem[0].end   = crashk_base + crashk_sz - 1;
06c2a2
+
06c2a2
+	return TRUE;
06c2a2
+}
06c2a2
+
06c2a2
 #endif /* powerpc64 */
06c2a2
diff --git a/makedumpfile-1.6.2/makedumpfile.c b/makedumpfile-1.6.2/makedumpfile.c
06c2a2
index 5096319..567ac5d 100644
06c2a2
--- a/makedumpfile-1.6.2/makedumpfile.c
06c2a2
+++ b/makedumpfile-1.6.2/makedumpfile.c
06c2a2
@@ -10945,6 +10945,9 @@ int is_crashkernel_mem_reserved(void)
06c2a2
 {
06c2a2
 	int ret;
06c2a2
 
06c2a2
+	if (arch_crashkernel_mem_size())
06c2a2
+		return TRUE;
06c2a2
+
06c2a2
 	ret = iomem_for_each_line("Crash kernel\n",
06c2a2
 					crashkernel_mem_callback, NULL);
06c2a2
 	crash_reserved_mem_nr = ret;
06c2a2
diff --git a/makedumpfile-1.6.2/makedumpfile.h b/makedumpfile-1.6.2/makedumpfile.h
06c2a2
index 6f188e4..7d81bbc 100644
06c2a2
--- a/makedumpfile-1.6.2/makedumpfile.h
06c2a2
+++ b/makedumpfile-1.6.2/makedumpfile.h
06c2a2
@@ -936,6 +936,7 @@ int get_xen_info_arm64(void);
06c2a2
 #define get_xen_basic_info_arch(X) get_xen_basic_info_arm64(X)
06c2a2
 #define get_xen_info_arch(X) get_xen_info_arm64(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif /* aarch64 */
06c2a2
 
06c2a2
 #ifdef __arm__
06c2a2
@@ -949,6 +950,7 @@ unsigned long long vaddr_to_paddr_arm(unsigned long vaddr);
06c2a2
 #define get_kaslr_offset(X)	stub_false()
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_arm(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif /* arm */
06c2a2
 
06c2a2
 #ifdef __x86__
06c2a2
@@ -962,6 +964,7 @@ unsigned long long vaddr_to_paddr_x86(unsigned long vaddr);
06c2a2
 #define get_kaslr_offset(X)	stub_false()
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_x86(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif /* x86 */
06c2a2
 
06c2a2
 #ifdef __x86_64__
06c2a2
@@ -977,12 +980,14 @@ unsigned long long vtop4_x86_64(unsigned long vaddr);
06c2a2
 #define get_kaslr_offset(X)	get_kaslr_offset_x86_64(X)
06c2a2
 #define vaddr_to_paddr(X)	vtop4_x86_64(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif /* x86_64 */
06c2a2
 
06c2a2
 #ifdef __powerpc64__ /* powerpc64 */
06c2a2
 int get_machdep_info_ppc64(void);
06c2a2
 int get_versiondep_info_ppc64(void);
06c2a2
 unsigned long long vaddr_to_paddr_ppc64(unsigned long vaddr);
06c2a2
+int arch_crashkernel_mem_size_ppc64(void);
06c2a2
 #define find_vmemmap()		stub_false()
06c2a2
 #define get_phys_base()		stub_true()
06c2a2
 #define get_machdep_info()	get_machdep_info_ppc64()
06c2a2
@@ -990,6 +995,7 @@ unsigned long long vaddr_to_paddr_ppc64(unsigned long vaddr);
06c2a2
 #define get_kaslr_offset(X)	stub_false()
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ppc64(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	arch_crashkernel_mem_size_ppc64()
06c2a2
 #endif          /* powerpc64 */
06c2a2
 
06c2a2
 #ifdef __powerpc32__ /* powerpc32 */
06c2a2
@@ -1002,6 +1008,7 @@ unsigned long long vaddr_to_paddr_ppc(unsigned long vaddr);
06c2a2
 #define get_kaslr_offset(X)	stub_false()
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ppc(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif          /* powerpc32 */
06c2a2
 
06c2a2
 #ifdef __s390x__ /* s390x */
06c2a2
@@ -1015,6 +1022,7 @@ int is_iomem_phys_addr_s390x(unsigned long addr);
06c2a2
 #define get_kaslr_offset(X)	stub_false()
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_s390x(X)
06c2a2
 #define is_phys_addr(X)		is_iomem_phys_addr_s390x(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif          /* s390x */
06c2a2
 
06c2a2
 #ifdef __ia64__ /* ia64 */
06c2a2
@@ -1029,6 +1037,7 @@ unsigned long long vaddr_to_paddr_ia64(unsigned long vaddr);
06c2a2
 #define vaddr_to_paddr(X)	vaddr_to_paddr_ia64(X)
06c2a2
 #define VADDR_REGION(X)		(((unsigned long)(X)) >> REGION_SHIFT)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif          /* ia64 */
06c2a2
 
06c2a2
 #ifdef __sparc64__ /* sparc64 */
06c2a2
@@ -1041,6 +1050,7 @@ unsigned long long vaddr_to_paddr_sparc64(unsigned long vaddr);
06c2a2
 #define get_versiondep_info()   get_versiondep_info_sparc64()
06c2a2
 #define vaddr_to_paddr(X)       vaddr_to_paddr_sparc64(X)
06c2a2
 #define is_phys_addr(X)		stub_true_ul(X)
06c2a2
+#define arch_crashkernel_mem_size()	stub_false()
06c2a2
 #endif		/* sparc64 */
06c2a2
 
06c2a2
 typedef unsigned long long mdf_pfn_t;
06c2a2
@@ -1942,6 +1952,7 @@ int iomem_for_each_line(char *match, int (*callback)(void *data, int nr,
06c2a2
 						     unsigned long base,
06c2a2
 						     unsigned long length),
06c2a2
 			void *data);
06c2a2
+int is_bigendian(void);
06c2a2
 
06c2a2
 
06c2a2
 /*
06c2a2
-- 
06c2a2
2.7.4
06c2a2