[1/3] libstb: export CVC/securerom code memory range
diff mbox series

Message ID 20190729014430.30937-2-stewart@linux.ibm.com
State New
Headers show
Series
  • Use real Container Verification Code in Mambo
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (1b638f899525da0f3185449114426b1eeb6ef4de)

Commit Message

Stewart Smith July 29, 2019, 1:44 a.m. UTC
This is useful to capture a real in-memory image for use in a simulator
(such as Mambo) without having to go through the complexity of setting
up the in-memory image yourself.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 libstb/cvc.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/libstb/cvc.c b/libstb/cvc.c
index d46617b29070..37ba29f6273b 100644
--- a/libstb/cvc.c
+++ b/libstb/cvc.c
@@ -140,6 +140,7 @@  static void cvc_service_register(uint32_t id, uint32_t offset, uint32_t version)
 static int cvc_reserved_mem_init(struct dt_node *parent) {
 	struct dt_node *node, *service;
 	struct dt_node *reserved_mem;
+	struct dt_node *exports;
 	uint32_t phandle;
 	uint64_t addr, size;
 
@@ -169,6 +170,13 @@  static int cvc_reserved_mem_init(struct dt_node *parent) {
 	addr = dt_get_address(cvc_resv_mem, 0, &size);
 	cvc_register(addr, addr + size-1);
 
+	exports = dt_find_by_path(dt_root, "/ibm,opal/firmware/exports");
+	if (!exports) {
+		prerror("OCC: dt node /ibm,opal/firmware/exports not found\n");
+		return false;
+	}
+	dt_add_property_u64s(exports, "CVC", addr, size-1);
+
 	/*
 	 *  Each child of the CVC node describes a CVC service
 	 */
@@ -197,8 +205,9 @@  static int cvc_reserved_mem_init(struct dt_node *parent) {
 
 static int cvc_secure_rom_init(void) {
 	const uint32_t reg_addr = SECURE_ROM_XSCOM_ADDRESS;
-	uint64_t reg_data;
+	struct dt_node *exports;
 	struct proc_chip *chip;
+	uint64_t reg_data;
 
 	if (!secure_rom_mem) {
 		secure_rom_mem = malloc(SECURE_ROM_MEMORY_SIZE);
@@ -216,6 +225,16 @@  static int cvc_secure_rom_init(void) {
 		       SECURE_ROM_MEMORY_SIZE);
 	cvc_register((uint64_t)secure_rom_mem,
 		     (uint64_t)secure_rom_mem + SECURE_ROM_MEMORY_SIZE-1);
+
+	exports = dt_find_by_path(dt_root, "/ibm,opal/firmware/exports");
+	if (!exports) {
+		prerror("OCC: dt node /ibm,opal/firmware/exports not found\n");
+		return false;
+	}
+
+	dt_add_property_u64s(exports, "securerom", (uint64_t)secure_rom_mem,
+			     SECURE_ROM_MEMORY_SIZE-1);
+
 	cvc_service_register(CVC_SHA512_SERVICE, SECURE_ROM_SHA512_OFFSET, 1);
 	cvc_service_register(CVC_VERIFY_SERVICE, SECURE_ROM_VERIFY_OFFSET, 1);
 	return 0;