[Skiboot] [PATCH v7 22/22] fadump: Save crashing cpu data

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Sat Apr 13 19:15:48 AEST 2019


Crashing CPU detail is required to get proper backtrace from core file.
Save crashing CPU data before triggering MPIPL. During MPIPL boot
pass this detail to Host Linux via device tree.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 core/opal-dump.c    | 9 +++++++++
 hdata/spira.c       | 8 ++++++++
 hw/sbe-p9.c         | 4 ++++
 include/mem-map.h   | 9 ++++++++-
 include/opal-dump.h | 8 ++++++++
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/core/opal-dump.c b/core/opal-dump.c
index f06739937..9d3e56b7e 100644
--- a/core/opal-dump.c
+++ b/core/opal-dump.c
@@ -16,6 +16,7 @@
 
 #define pr_fmt(fmt)	"DUMP: " fmt
 
+#include <cpu.h>
 #include <device.h>
 #include <mem-map.h>
 #include <mem_region.h>
@@ -349,6 +350,14 @@ static void adjust_opal_dump_size(struct dt_node *dump_node)
 	add_dump_reserve_node(dump_node);
 }
 
+void opal_dump_save_metadata(void)
+{
+	struct dump_metadata *m = (struct dump_metadata *)(DUMP_METADATA_AREA_BASE);
+
+	m->crashing_cpu = this_cpu()->pir;
+	prlog(PR_NOTICE, "Crashing CPU = 0x%x\n", m->crashing_cpu);
+}
+
 void opal_dump_init(void)
 {
 	struct dt_node *dump_node;
diff --git a/hdata/spira.c b/hdata/spira.c
index 84a0094f1..e1b544da0 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -1118,6 +1118,10 @@ static void opal_dump_add_result_table(const struct iplparams_iplparams *p)
 	struct fadump_section *fadump_section;
 	struct fadump *result_table;
 	struct dt_node *dump_node;
+	struct dump_metadata *m;
+
+	m = (struct dump_metadata *)(DUMP_METADATA_AREA_BASE -
+				     SKIBOOT_BASE + DUMP_DEST_SKIBOOT_BASE);
 
 	dump_node = dt_find_by_path(opal_node, "dump");
 	if (!dump_node)
@@ -1192,6 +1196,10 @@ static void opal_dump_add_result_table(const struct iplparams_iplparams *p)
 	/* Add architected register data to result-table */
 	opal_dump_add_arch_regs(dump_node, result_table, &j);
 
+	/* Fill crashing CPU details */
+	result_table->crashing_cpu = cpu_to_be32(m->crashing_cpu);
+	prlog(PR_NOTICE, "DUMP: Crashed cpu = 0x%x\n", m->crashing_cpu);
+
 	result_table->section_count = cpu_to_be16(j);
 	/* Actual property size */
 	prop_size = sizeof(struct fadump) + (j * sizeof(struct fadump_section));
diff --git a/hw/sbe-p9.c b/hw/sbe-p9.c
index bf3ca9e68..ac890a2d9 100644
--- a/hw/sbe-p9.c
+++ b/hw/sbe-p9.c
@@ -50,6 +50,7 @@
 #include <errorlog.h>
 #include <lock.h>
 #include <opal.h>
+#include <opal-dump.h>
 #include <sbe-p9.h>
 #include <skiboot.h>
 #include <timebase.h>
@@ -971,6 +972,9 @@ void p9_sbe_terminate(void)
 		return;
 	}
 
+	/* Save crashing CPU details */
+	opal_dump_save_metadata();
+
 	dt_for_each_compatible(dt_root, xn, "ibm,xscom") {
 		chip_id = dt_get_chip_id(xn);
 
diff --git a/include/mem-map.h b/include/mem-map.h
index 0cb4d5da4..a4b74f9d9 100644
--- a/include/mem-map.h
+++ b/include/mem-map.h
@@ -119,7 +119,14 @@
  * memory after moving memory content from source to destination memory.
  */
 #define MDRT_TABLE_BASE		(SKIBOOT_BASE + 0x01c00000)
-#define MDRT_TABLE_SIZE		0x00010000
+#define MDRT_TABLE_SIZE		0x0000f000
+
+/*
+ * This is our dump meta data area. We will use this memory to save
+ * crashing CPU details before triggering MPIPL.
+ */
+#define DUMP_METADATA_AREA_BASE	(SKIBOOT_BASE + 0x01c0f000)
+#define DUMP_METADATA_AREA_SIZE	0x1000
 
 /* Total size of the above area
  *
diff --git a/include/opal-dump.h b/include/opal-dump.h
index d71691e13..a12b4c5c2 100644
--- a/include/opal-dump.h
+++ b/include/opal-dump.h
@@ -124,7 +124,15 @@ struct proc_reg_data {
 } __packed;
 
 
+/* Meta data to capture before triggering MPIPL */
+struct dump_metadata {
+	uint32_t crashing_cpu;
+};
+
 /* init opal dump */
 extern void opal_dump_init(void);
 
+/* Save metadata before triggering MPIPL */
+extern void opal_dump_save_metadata(void);
+
 #endif	/* __OPAL_DUMP_H */
-- 
2.14.3



More information about the Skiboot mailing list