diff mbox series

[v5,10/10] tools/arm: optee: create optee firmware node in DT if tee=optee

Message ID 20190521212530.12706-11-volodymyr_babchuk@epam.com (mailing list archive)
State Superseded
Headers show
Series TEE mediator (and OP-TEE) support in XEN | expand

Commit Message

Volodymyr Babchuk May 21, 2019, 9:26 p.m. UTC
If TEE support is enabled with "tee=optee" option in xl.cfg,
then we need to inform guest about available TEE, by creating
corresponding node in the guest's device tree.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>

---
 This patch depends on patches to optee.c.

 Changes from v4:
  - "native" option replaced with "optee"

 Changes from v3:
  - "smc" method replaced with "hvc"
  - Coding style fixes
---
 tools/libxl/libxl_arm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Ian Jackson June 3, 2019, 2:50 p.m. UTC | #1
Volodymyr Babchuk writes ("[Xen-devel] [PATCH v5 10/10] tools/arm: optee: create optee firmware node in DT if tee=optee"):
> If TEE support is enabled with "tee=optee" option in xl.cfg,
> then we need to inform guest about available TEE, by creating
> corresponding node in the guest's device tree.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> Reviewed-by: Julien Grall <julien.grall@arm.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

(relying on Julien's review for the actual DT details).


Looking at this, it is not clear to me why the fdt parameter to all
these functions is a void*.  Why does libfdt not introduce a
struct or something ?  (This is by no means a blocker for this patch.)

Thanks,
Ian.
diff mbox series

Patch

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 6b72c00960..bf31b9b3ca 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -420,6 +420,32 @@  static int make_psci_node(libxl__gc *gc, void *fdt)
     return 0;
 }
 
+static int make_optee_node(libxl__gc *gc, void *fdt)
+{
+    int res;
+    LOG(DEBUG, "Creating OP-TEE node in dtb");
+
+    res = fdt_begin_node(fdt, "firmware");
+    if (res) return res;
+
+    res = fdt_begin_node(fdt, "optee");
+    if (res) return res;
+
+    res = fdt_property_compat(gc, fdt, 1, "linaro,optee-tz");
+    if (res) return res;
+
+    res = fdt_property_string(fdt, "method", "hvc");
+    if (res) return res;
+
+    res = fdt_end_node(fdt);
+    if (res) return res;
+
+    res = fdt_end_node(fdt);
+    if (res) return res;
+
+    return 0;
+}
+
 static int make_memory_nodes(libxl__gc *gc, void *fdt,
                              const struct xc_dom_image *dom)
 {
@@ -933,6 +959,9 @@  next_resize:
         if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART)
             FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) );
 
+        if (info->tee == LIBXL_TEE_TYPE_OPTEE)
+            FDT( make_optee_node(gc, fdt) );
+
         if (pfdt)
             FDT( copy_partial_fdt(gc, fdt, pfdt) );