[PATCH 15/18] powernv/fadump: consider f/w load area

Hari Bathini hbathini at linux.ibm.com
Fri Feb 22 04:37:07 AEDT 2019


OPAL loads kernel & initrd at 512MB offset (256MB size), also exported
as ibm,opal/dump/fw-load-area. So, if boot memory size of FADump is
less than 768MB, kernel memory to be exported as '/proc/vmcore' would
be overwritten by f/w while loading kernel & initrd. To avoid such a
scenario, enforce a minimum boot memory size of 768MB on OPAL platform.

Also, skip using FADump if a newer F/W version loads kernel & initrd
above 768MB.

Signed-off-by: Hari Bathini <hbathini at linux.ibm.com>
---
 arch/powerpc/kernel/fadump.c                 |    8 ++++++++
 arch/powerpc/kernel/fadump_internal.h        |   15 +++++++++++++--
 arch/powerpc/platforms/powernv/opal-fadump.c |   23 +++++++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index d343c4b..c8eb166 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -582,6 +582,14 @@ int __init fadump_reserve_mem(void)
 				ALIGN(fw_dump.boot_memory_size,
 							FADUMP_CMA_ALIGNMENT);
 #endif
+
+		if ((fw_dump.fadump_platform == FADUMP_PLATFORM_POWERNV) &&
+		    (fw_dump.boot_memory_size < OPAL_MIN_BOOT_MEM)) {
+			pr_err("Can't enable fadump with boot memory size (0x%lx) less than 0x%lx\n",
+			       fw_dump.boot_memory_size, OPAL_MIN_BOOT_MEM);
+			goto error_out;
+		}
+
 		fw_dump.rmr_source_len = fw_dump.boot_memory_size;
 		if (!fadump_get_rmr_regions()) {
 			pr_err("Too many holes in boot memory area to enable fadump\n");
diff --git a/arch/powerpc/kernel/fadump_internal.h b/arch/powerpc/kernel/fadump_internal.h
index 1bd3aeb..f59fdc7 100644
--- a/arch/powerpc/kernel/fadump_internal.h
+++ b/arch/powerpc/kernel/fadump_internal.h
@@ -24,14 +24,25 @@
 #define RMA_END		(ppc64_rma_size)
 
 /*
+ * With kernel & initrd loaded at 512MB (with 256MB size), enforce a minimum
+ * boot memory size of 768MB to ensure f/w loading kernel and initrd doesn't
+ * mess with crash'ed kernel's memory during MPIPL.
+ */
+#define OPAL_MIN_BOOT_MEM	(0x30000000UL)
+
+/*
  * On some Power systems where RMO is 128MB, it still requires minimum of
  * 256MB for kernel to boot successfully. When kdump infrastructure is
  * configured to save vmcore over network, we run into OOM issue while
  * loading modules related to network setup. Hence we need additional 64M
  * of memory to avoid OOM issue.
  */
-#define MIN_BOOT_MEM	(((RMA_END < (0x1UL << 28)) ? (0x1UL << 28) : RMA_END) \
-			+ (0x1UL << 26))
+#define PSERIES_MIN_BOOT_MEM	(((RMA_END < (0x1UL << 28)) ? (0x1UL << 28) : \
+				 RMA_END) + (0x1UL << 26))
+
+#define MIN_BOOT_MEM	((fw_dump.fadump_platform ==			\
+			 FADUMP_PLATFORM_POWERNV) ? OPAL_MIN_BOOT_MEM :	\
+			 PSERIES_MIN_BOOT_MEM)
 
 /* The upper limit percentage for user specified boot memory size (25%) */
 #define MAX_BOOT_MEM_RATIO			4
diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
index 36077bd..06053fd 100644
--- a/arch/powerpc/platforms/powernv/opal-fadump.c
+++ b/arch/powerpc/platforms/powernv/opal-fadump.c
@@ -528,6 +528,29 @@ int __init opal_dt_scan_fadump(struct fw_dump *fadump_conf, ulong node)
 			fadump_conf->cpu_state_entry_size =
 						of_read_number(prop, 1);
 		}
+	} else {
+		int i, len;
+
+		prop = of_get_flat_dt_prop(dn, "fw-load-area", &len);
+		if (prop) {
+			/*
+			 * Each f/w load area is an (address,size) pair,
+			 * 2 cells each, totalling 4 cells per range.
+			 */
+			for (i = 0; i < len / (sizeof(*prop) * 4); i++) {
+				u64 base, end;
+
+				base = of_read_number(prop + (i * 4) + 0, 2);
+				end = base;
+				end += of_read_number(prop + (i * 4) + 2, 2);
+				if (end > OPAL_MIN_BOOT_MEM) {
+					pr_err("F/W load area: 0x%llx-0x%llx\n",
+					       base, end);
+					pr_err("F/W version not supported!\n");
+					return 1;
+				}
+			}
+		}
 	}
 
 	fadump_conf->ops		= &opal_fadump_ops;



More information about the Linuxppc-dev mailing list