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

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