[Skiboot] [RFC PATCH v4 10/16] hdata/spira.c: Create ibm, ultravisor dt node

Ryan Grimm grimm at linux.ibm.com
Thu Feb 27 23:20:36 AEDT 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 | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/hdata/spira.c b/hdata/spira.c
index 7c5918d2..1435d175 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -1712,6 +1712,36 @@ static void update_spirah_addr(void)
 #endif
 }
 
+#define UV_LOAD_MAX_SIZE        0x200000
+
+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_cells(uv_fw_node, "reg", uv_fw_start >> 32,
+			uv_fw_start & 0xffffffff, UV_LOAD_MAX_SIZE >> 23,
+			UV_LOAD_MAX_SIZE & 0xffffffff);
+}
+
 int parse_hdat(bool is_opal)
 {
 	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
@@ -1753,6 +1783,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();
 
-- 
2.21.0



More information about the Skiboot mailing list