[Skiboot] [PATCH v8 19/24] MPIPL: Prepare OPAL data tag

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Mon Jun 17 03:10:19 AEST 2019


Post MPIPL kernel needs OPAL metadata to create opalcore. This patch
sets up OPAL metadata tag. Next patch will add API to pass metadata
pointer to kernel.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 core/opal-dump.c   | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/opal-api.h | 26 +++++++++++++++++++++++++
 2 files changed, 83 insertions(+)

diff --git a/core/opal-dump.c b/core/opal-dump.c
index 7036a424a..7b8823d84 100644
--- a/core/opal-dump.c
+++ b/core/opal-dump.c
@@ -41,6 +41,10 @@ static struct spira_ntuple *ntuple_mdrt;
 
 static struct mpipl_metadata    *mpipl_metadata;
 
+/* Dump metadata area */
+static struct mpipl_fadump *mpipl_opal_data;
+
+
 static int opal_mpipl_add_entry(u8 region, u64 src, u64 dest, u64 size)
 {
 	int i, max_cnt;
@@ -304,6 +308,56 @@ static int64_t opal_mpipl_update(enum mpipl_ops ops,
 	return rc;
 }
 
+static void post_mpipl_get_opal_data(void)
+{
+	struct mdrt_table *mdrt = (void *)(MDRT_TABLE_BASE);
+	int i, j = 0, count = 0;
+	u32 mdrt_cnt = ntuple_mdrt->act_cnt;
+	struct fadump_region *region;
+
+	/* Count OPAL dump regions */
+	for (i = 0; i < mdrt_cnt; i++) {
+		if (mdrt->data_region == DUMP_REGION_OPAL_MEMORY)
+			count++;
+		mdrt++;
+	}
+
+	mpipl_opal_data = zalloc(sizeof(struct mpipl_fadump) +
+				 count * sizeof(struct fadump_region));
+	if (!mpipl_opal_data) {
+		prlog(PR_ERR, "Failed to allocate memory\n");
+		return;
+	}
+
+	/* Fill OPAL dump details */
+	mpipl_opal_data->version = MPIPL_FADUMP_VERSION;
+	mpipl_opal_data->type    = MPIPL_FADUMP_TYPE_OPAL;
+	mpipl_opal_data->crashing_pir = mpipl_metadata->crashing_pir;
+	mpipl_opal_data->fadump_region_cnt = count;
+	region = mpipl_opal_data->region;
+
+	mdrt = (void *)(MDRT_TABLE_BASE);
+	for (i = 0; i < mdrt_cnt; i++) {
+		if (mdrt->data_region != DUMP_REGION_OPAL_MEMORY) {
+			mdrt++;
+			continue;
+		}
+
+		region[j].src  = mdrt->src_addr  & ~(HRMOR_BIT);
+		region[j].dest = mdrt->dest_addr & ~(HRMOR_BIT);
+		region[j].size = mdrt->size;
+
+		prlog(PR_NOTICE, "OPAL reserved region %d - src : 0x%llx, "
+		      "dest : 0x%llx, size : 0x%llx\n", j, region[j].src,
+		      region[j].dest, region[j].size);
+
+		mdrt++;
+		j++;
+		if (j == count)
+			break;
+	}
+}
+
 void opal_mpipl_save_crashing_pir(void)
 {
 	mpipl_metadata->crashing_pir = this_cpu()->pir;
@@ -328,6 +382,9 @@ void opal_mpipl_init(void)
 	/* Get metadata area pointer */
 	mpipl_metadata = (void *)(DUMP_METADATA_AREA_BASE);
 
+	if (dt_find_property(dump_node, "mpipl-boot"))
+		post_mpipl_get_opal_data();
+
 	/* Clear OPAL metadata area */
 	if (sizeof(struct mpipl_metadata) > DUMP_METADATA_AREA_SIZE) {
 		prlog(PR_ERR, "INSUFFICIENT OPAL METADATA AREA\n");
diff --git a/include/opal-api.h b/include/opal-api.h
index 5747019f8..5af1a6d0f 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -1226,6 +1226,32 @@ enum mpipl_ops {
 	OPAL_MPIPL_FREE_PRESERVED_MEMORY= 4,
 };
 
+/* Preserved memory details */
+struct fadump_region {
+	u64	src;
+	u64	dest;
+	u64	size;
+};
+
+/* Structure version */
+#define MPIPL_FADUMP_VERSION		0x01
+
+/* Metadata type. Kernel will use this field to identify the type of data */
+#define MPIPL_FADUMP_TYPE_HOST_START	0x80
+#define MPIPL_FADUMP_TYPE_HOST_END	0xff
+#define MPIPL_FADUMP_TYPE_CPU		0x00
+#define MPIPL_FADUMP_TYPE_OPAL		0x01
+struct mpipl_fadump {
+	u8	type;		/* MPIPL_FADUMP_TYPE_* */
+	u8	version;
+	u8	reserved[6];
+	u32	crashing_pir;	/* OPAL crashing CPU PIR */
+	u32	cpu_data_version;
+	u32	cpu_data_size;
+	u32	fadump_region_cnt;
+	struct	fadump_region region[];
+} __packed;
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __OPAL_API_H */
-- 
2.14.3



More information about the Skiboot mailing list