Skip to contentSkip to conversation

add optee dts entry for secure machine

PATCH In review Maxim Uvarov 1 participant 2 messages Apr 22, 2020 – Apr 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add optee dts entry for secure machine

Add optee compatible string for dtb to force linux to boot optee module.

---
v2: added method.

 hw/arm/virt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
hw/arm/virt.c +18 -0
index 656b008..c937a82 100644
@@ -1335,6 +1335,23 @@ static void create_platform_bus(VirtMachineState *vms)
                                 sysbus_mmio_get_region(s, 0));
 }
 
+static void create_secure_tee(VirtMachineState *vms)
+{
+    char *firmware;
+    char *optee;
+
+    firmware = g_strdup_printf("/firmware");
+    qemu_fdt_add_subnode(vms->fdt, firmware);
+
+    optee = g_strdup_printf("/firmware/optee");
+    qemu_fdt_add_subnode(vms->fdt, optee);
+    qemu_fdt_setprop_string(vms->fdt, optee, "compatible", "linaro,optee-tz");
+    qemu_fdt_setprop_string(vms->fdt, optee, "method", "smc");
+
+    g_free(optee);
+    g_free(firmware);
+}
+
 static void create_secure_ram(VirtMachineState *vms,
                               MemoryRegion *secure_sysmem)
 {
@@ -1720,6 +1737,7 @@ static void machvirt_init(MachineState *machine)
     if (vms->secure) {
         create_secure_ram(vms, secure_sysmem);
         create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1));
+        create_secure_tee(vms);
     }
 
     vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
Signature · 1 line
2.17.1
#1 lore raw

Kindly ping to merge this patch.
For more detail. This patch creates a dtb entry to load the optee driver which is needed for secure boot (atf+optee+uboot+linux). Kernel part is already there:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tee/optee/core.c?h=v5.7-rc3#n705
.compatible = "linaro,optee-tz"

Thank you,
Maxim.

Quoted 49 lines · Maxim Uvarov

Add optee compatible string for dtb to force linux to boot optee module.

---
v2: added method.

 hw/arm/virt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
hw/arm/virt.c +18 -1
index 656b008..c937a82 100644
@@ -1335,6 +1335,23 @@ static void create_platform_bus(VirtMachineState *vms)
                                 sysbus_mmio_get_region(s, 0));
 }
 
+static void create_secure_tee(VirtMachineState *vms)
+{
+    char *firmware;
+    char *optee;
+
+    firmware = g_strdup_printf("/firmware");
+    qemu_fdt_add_subnode(vms->fdt, firmware);
+
+    optee = g_strdup_printf("/firmware/optee");
+    qemu_fdt_add_subnode(vms->fdt, optee);
+    qemu_fdt_setprop_string(vms->fdt, optee, "compatible", "linaro,optee-tz");
+    qemu_fdt_setprop_string(vms->fdt, optee, "method", "smc");
+
+    g_free(optee);
+    g_free(firmware);
+}
+
 static void create_secure_ram(VirtMachineState *vms,
                               MemoryRegion *secure_sysmem)
 {
@@ -1720,6 +1737,7 @@ static void machvirt_init(MachineState *machine)
     if (vms->secure) {
         create_secure_ram(vms, secure_sysmem);
         create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1));
+        create_secure_tee(vms);
     }
 
     vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
--

2.17.1