diff mbox series

[v5,08/18] hdata: Adjust various structure offset after relocation

Message ID 20180816085721.11703-9-hegdevasant@linux.vnet.ibm.com
State Superseded
Headers show
Series MPIPL support | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Vasant Hegde Aug. 16, 2018, 8:57 a.m. UTC
ntuple addresses in SPIRAH are relative to payload base. Update various
addresses after relocation so that hostboot can access new address to
capture dump.

Note that we update relocated SPIRAH. So if we crash before sending
relocated skiboot base to SBE, hostboot can still collect early
crash using original skiboot base.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hdata/spira.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/hdata/spira.c b/hdata/spira.c
index 63bc85643..360cee379 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -25,6 +25,7 @@ 
 #include <opal-dump.h>
 #include <fsp-attn.h>
 #include <fsp-leds.h>
+#include <skiboot.h>
 
 #include "hdata.h"
 #include "hostservices.h"
@@ -1708,6 +1709,28 @@  static void fixup_spira(void)
 	spira.ntuples.node_stb_data = spiras->ntuples.node_stb_data;
 }
 
+/*
+ * All the data structure addresses are relative to payload base. Hence adjust
+ * structures that are needed to capture OPAL dump during memory preserving IPL.
+ */
+static void update_spirah_addr(void)
+{
+#if !defined(TEST)
+	/* NACA starts at 0x4000 (see asm/head.S) */
+	uint64_t *spirah_offset = (uint64_t *)((u64)SKIBOOT_BASE + 0x4000);
+	/* Legacy SPIRA */
+	uint64_t *spira_offset = (uint64_t *)((u64)SKIBOOT_BASE + 0x4000 + 0x30);
+
+	if (proc_gen < proc_gen_p9)
+		return;
+
+	*spirah_offset = SPIRAH_OFF;
+	*spira_offset = SPIRA_OFF;
+	spirah.ntuples.hs_data_area.addr = CPU_TO_BE64(SPIRA_HEAP_BASE - SKIBOOT_BASE);
+	spirah.ntuples.mdump_res.addr = CPU_TO_BE64(MDRT_TABLE_BASE - SKIBOOT_BASE);
+#endif
+}
+
 int parse_hdat(bool is_opal)
 {
 	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
@@ -1716,6 +1739,8 @@  int parse_hdat(bool is_opal)
 
 	fixup_spira();
 
+	update_spirah_addr();
+
 	/*
 	 * Basic DT root stuff
 	 */