Re: [PATCH v14 07/11] arm_ffa: introduce sandbox FF-A support

2023-07-07 Thread Simon Glass
Hi Abdellatif,

On Fri, 7 Jul 2023 at 15:44, Abdellatif El Khlifi
 wrote:
>
> Emulate Secure World's FF-A ABIs and allow testing U-Boot FF-A support
>
> Features of the sandbox FF-A support:
>
> - Introduce an FF-A emulator
> - Introduce an FF-A device driver for FF-A comms with emulated Secure World
> - Provides test methods allowing to read the status of the inspected ABIs
>
> The sandbox FF-A emulator supports only 64-bit direct messaging.
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
>
> Changelog:
> ===
>
> v12:
>
> * remove reparenting by making the emulator parent of the FF-A device in the 
> DT
> * add invoke_ffa_fn()
> * address nits
>
> v11:
>
> * rename ffa_try_discovery() to sandbox_ffa_discover()
> * rename sandbox_ffa_query_core_state() to sandbox_query_ffa_emul_state()
> * store the sandbox emulator pointer in the FF-A device uc_priv (struct 
> ffa_priv)
> * set the emulator as parent of the sandbox FF-A device
>
> v10:
>
> * split the FF-A sandbox support into an emulator and a driver
> * read FFA_VERSION and FFA_PARTITION_INFO_GET state using
>sandbox_ffa_query_core_state()
> * drop CONFIG_SANDBOX_FFA config
> * address nits
>
> v9: align FF-A sandbox driver with FF-A discovery through DM
>
> v8: update ffa_bus_prvdata_get() to return a pointer rather than
> a pointer address
>
> v7: state that sandbox driver supports only 64-bit direct messaging
>
> v4: align sandbox driver with the new FF-A driver interfaces
> and new way of error handling
>
> v1: introduce the sandbox driver
>
>  MAINTAINERS   |   3 +-
>  arch/sandbox/dts/sandbox.dtsi |   9 +
>  arch/sandbox/dts/test.dts |   8 +
>  arch/sandbox/include/asm/sandbox_arm_ffa.h|  72 ++
>  .../include/asm/sandbox_arm_ffa_priv.h| 121 +++
>  configs/sandbox64_defconfig   |   1 +
>  configs/sandbox_defconfig |   1 +
>  doc/arch/arm64.ffa.rst|  19 +-
>  doc/arch/sandbox/sandbox.rst  |   1 +
>  drivers/firmware/arm-ffa/Kconfig  |  13 +-
>  drivers/firmware/arm-ffa/Makefile |  10 +-
>  drivers/firmware/arm-ffa/ffa-emul-uclass.c| 720 ++
>  .../firmware/arm-ffa/sandbox_arm_ffa_priv.h   |  14 -
>  drivers/firmware/arm-ffa/sandbox_ffa.c| 110 +++
>  include/dm/uclass-id.h|   1 +
>  15 files changed, 1081 insertions(+), 22 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa.h
>  create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa_priv.h
>  create mode 100644 drivers/firmware/arm-ffa/ffa-emul-uclass.c
>  delete mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h
>  create mode 100644 drivers/firmware/arm-ffa/sandbox_ffa.c

Reviewed-by: Simon Glass 


[PATCH v14 07/11] arm_ffa: introduce sandbox FF-A support

2023-07-07 Thread Abdellatif El Khlifi
Emulate Secure World's FF-A ABIs and allow testing U-Boot FF-A support

Features of the sandbox FF-A support:

- Introduce an FF-A emulator
- Introduce an FF-A device driver for FF-A comms with emulated Secure World
- Provides test methods allowing to read the status of the inspected ABIs

The sandbox FF-A emulator supports only 64-bit direct messaging.

Signed-off-by: Abdellatif El Khlifi 
Cc: Tom Rini 
Cc: Simon Glass 
Cc: Ilias Apalodimas 
Cc: Jens Wiklander 
Cc: Heinrich Schuchardt 

---

Changelog:
===

v12:

* remove reparenting by making the emulator parent of the FF-A device in the DT
* add invoke_ffa_fn()
* address nits

v11:

* rename ffa_try_discovery() to sandbox_ffa_discover()
* rename sandbox_ffa_query_core_state() to sandbox_query_ffa_emul_state()
* store the sandbox emulator pointer in the FF-A device uc_priv (struct 
ffa_priv)
* set the emulator as parent of the sandbox FF-A device

v10:

* split the FF-A sandbox support into an emulator and a driver
* read FFA_VERSION and FFA_PARTITION_INFO_GET state using
   sandbox_ffa_query_core_state()
* drop CONFIG_SANDBOX_FFA config
* address nits

v9: align FF-A sandbox driver with FF-A discovery through DM

v8: update ffa_bus_prvdata_get() to return a pointer rather than
a pointer address

v7: state that sandbox driver supports only 64-bit direct messaging

v4: align sandbox driver with the new FF-A driver interfaces
and new way of error handling

v1: introduce the sandbox driver

 MAINTAINERS   |   3 +-
 arch/sandbox/dts/sandbox.dtsi |   9 +
 arch/sandbox/dts/test.dts |   8 +
 arch/sandbox/include/asm/sandbox_arm_ffa.h|  72 ++
 .../include/asm/sandbox_arm_ffa_priv.h| 121 +++
 configs/sandbox64_defconfig   |   1 +
 configs/sandbox_defconfig |   1 +
 doc/arch/arm64.ffa.rst|  19 +-
 doc/arch/sandbox/sandbox.rst  |   1 +
 drivers/firmware/arm-ffa/Kconfig  |  13 +-
 drivers/firmware/arm-ffa/Makefile |  10 +-
 drivers/firmware/arm-ffa/ffa-emul-uclass.c| 720 ++
 .../firmware/arm-ffa/sandbox_arm_ffa_priv.h   |  14 -
 drivers/firmware/arm-ffa/sandbox_ffa.c| 110 +++
 include/dm/uclass-id.h|   1 +
 15 files changed, 1081 insertions(+), 22 deletions(-)
 create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa.h
 create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa_priv.h
 create mode 100644 drivers/firmware/arm-ffa/ffa-emul-uclass.c
 delete mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h
 create mode 100644 drivers/firmware/arm-ffa/sandbox_ffa.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ff6a222960..f8948b7635 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -269,12 +269,13 @@ F:configs/cortina_presidio-asic-pnand_defconfig
 ARM FF-A
 M: Abdellatif El Khlifi 
 S: Maintained
+F: arch/sandbox/include/asm/sandbox_arm_ffa.h
+F: arch/sandbox/include/asm/sandbox_arm_ffa_priv.h
 F: cmd/armffa.c
 F: doc/arch/arm64.ffa.rst
 F: doc/usage/cmd/armffa.rst
 F: drivers/firmware/arm-ffa/
 F: include/arm_ffa.h
-F: include/sandbox_arm_ffa.h
 
 ARM FREESCALE IMX
 M: Stefano Babic 
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 30a305c4d2..94a08814b8 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -445,6 +445,15 @@
thermal {
compatible = "sandbox,thermal";
};
+
+   arm-ffa-emul {
+   compatible = "sandbox,arm-ffa-emul";
+
+   sandbox-arm-ffa {
+   compatible = "sandbox,arm-ffa";
+   };
+   };
+
 };
 
 _ec {
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index ff9f9222e6..96b5404991 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -1820,6 +1820,14 @@
extcon {
compatible = "sandbox,extcon";
};
+
+   arm-ffa-emul {
+   compatible = "sandbox,arm-ffa-emul";
+
+   sandbox-arm-ffa {
+   compatible = "sandbox,arm-ffa";
+   };
+   };
 };
 
 #include "sandbox_pmic.dtsi"
diff --git a/arch/sandbox/include/asm/sandbox_arm_ffa.h 
b/arch/sandbox/include/asm/sandbox_arm_ffa.h
new file mode 100644
index 00..be2790f496
--- /dev/null
+++ b/arch/sandbox/include/asm/sandbox_arm_ffa.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2022-2023 Arm Limited and/or its affiliates 

+ *
+ * Authors:
+ *   Abdellatif El Khlifi 
+ */
+
+#ifndef __SANDBOX_ARM_FFA_H
+#define __SANDBOX_ARM_FFA_H
+
+#include 
+
+/*
+ * This header provides public sandbox FF-A emulator declarations
+ * and declarations needed by FF-A sandbox clients
+ */
+
+/* UUIDs strings of the emulated services */
+#define SANDBOX_SERVICE1_UUID