[Skiboot] [RFC PATCH v7 08/12] hdata/spira.c: Create ibm, ultravisor dt node

Ryan Grimm grimm at linux.ibm.com
Tue Jul 7 02:14:35 AEST 2020


Create ibm,ultravisor node if secure memory exists.  See
doc/opal-uv-abi.rst for details.

Signed-off-by: Ryan Grimm <grimm at us.ibm.com>
---
 hdata/spira.c        | 30 ++++++++++++++++++++++++++++++
 include/ultravisor.h |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/hdata/spira.c b/hdata/spira.c
index 35d6109d..9d0ea6d6 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -17,6 +17,7 @@
 #include "hostservices.h"
 #include "naca.h"
 #include "spira.h"
+#include <ultravisor.h>
 
 /* Processor Initialization structure, contains
  * the initial NIA and MSR values for the entry
@@ -1650,6 +1651,32 @@ static void add_npus(void)
 	}
 }
 
+static void add_uv(void)
+{
+	struct dt_node *uv_node, *secure_mem_node, *uv_fw_node;
+	uint64_t uv_fw_start;
+	char fw_name[64];
+
+	secure_mem_node = dt_find_compatible_node_on_chip(dt_root, NULL,
+						"ibm,secure-memory", 0);
+	if (!secure_mem_node) {
+		prlog(PR_DEBUG, "HDAT: No ibm,secure-memory found\n");
+		return;
+	}
+
+	uv_node = dt_new_check(dt_root, "ibm,ultravisor");
+	dt_add_property_string(uv_node, "compatible", "ibm,ultravisor");
+	dt_add_property_cells(uv_node, "#address-cells", 2);
+	dt_add_property_cells(uv_node, "#size-cells", 2);
+
+	uv_fw_start = dt_get_address(secure_mem_node, 0, NULL);
+
+	snprintf(fw_name, 64, "firmware@%llx", (unsigned long long)uv_fw_start);
+	uv_fw_node = dt_new_check(uv_node, fw_name);
+	dt_add_property_string(uv_fw_node, "compatible", "ibm,uv-firmware");
+	dt_add_property_u64s(uv_fw_node, "reg", uv_fw_start, UV_LOAD_MAX_SIZE);
+}
+
 /*
  * Legacy SPIRA is being deprecated and we have new SPIRA-H/S structures.
  * But on older system (p7?) we will continue to get legacy SPIRA.
@@ -1754,6 +1781,9 @@ int parse_hdat(bool is_opal)
 	/* Parse MS VPD */
 	memory_parse();
 
+	/* Add UV node if secure memory exists */
+	add_uv();
+
 	/* Add any FSPs */
 	fsp_parse();
 
diff --git a/include/ultravisor.h b/include/ultravisor.h
index 84217d66..d2fbb2f9 100644
--- a/include/ultravisor.h
+++ b/include/ultravisor.h
@@ -64,4 +64,6 @@ static inline int uv_xscom_write(u64 partid, u64 pcb_addr, u64 val)
 	return ucall(UV_WRITE_SCOM, retbuf, partid, pcb_addr, val);
 }
 
+#define UV_LOAD_MAX_SIZE 0x200000
+
 #endif /* __ULTRAVISOR_H */
-- 
2.21.0



More information about the Skiboot mailing list