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

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