Re: [PATCH v11 06/10] arm_ffa: introduce sandbox FF-A support
Hi Simon, > Hi Abdellatif, > > On Wed, 12 Apr 2023 at 03:43, 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: > > === > > > > 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 > > This is close, but not quite what I expected. > > I suspect the emulator should be the child of the FF-A device, not the > parent? You should update the devicetree to show that. You should not > need to reparent anything. > > Then you put this in your FFA uclass so it binds the emulator: > > .post_bind = dm_scan_fdt_dev, > Thanks. Sorry for the late reply, I was in holidays. I made few tweaks based on your suggestion and this will be in v12 patchset (work in progress). In v12, reparenting will be removed and DT will be used to reflect the relationship between the emulator and the FF-A device. Also, dm_scan_fdt_dev() is used to bind the child. However, in case of FF-A the emulator should be the parent. Please refer to the explanation below for more details. DT nodes: (tested and works) arm-ffa-emul { compatible = "sandbox,arm-ffa-emul"; sandbox-arm-ffa { compatible = "sandbox,arm-ffa"; }; }; In real HW, the secure side exists before the FF-A device is set up. The FF-A device needs the secure side up and running so it can query the FF-A framework version during FF-A discovery. The same concept is followed in sandbox mode: - The emulator device is the parent of the FF-A device. So, the emulator priv exists in memory before the FF-A device is bound. The emulator priv contains the secure side data (i.e: FF-A framework version) - The FF-A device is the child, when bound it discovers FF-A framework by querying the version from the emulator I hope this suggestion makes sense to you. Cheers, Abdellatif
Re: [PATCH v11 06/10] arm_ffa: introduce sandbox FF-A support
Hi Abdellatif, On Wed, 12 Apr 2023 at 03:43, 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: > === > > 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 This is close, but not quite what I expected. I suspect the emulator should be the child of the FF-A device, not the parent? You should update the devicetree to show that. You should not need to reparent anything. Then you put this in your FFA uclass so it binds the emulator: .post_bind = dm_scan_fdt_dev, Finding the emulator is probably then just a case of calling device_find_first_child(). I notice that you are sometimes breaking lines very short, e.g. the memset() lines. Please try to use all 80cols if you can. Regards, Simon
[PATCH v11 06/10] arm_ffa: introduce sandbox FF-A support
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: === 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 | 8 + arch/sandbox/dts/test.dts | 8 + arch/sandbox/include/asm/sandbox_arm_ffa.h| 72 ++ .../include/asm/sandbox_arm_ffa_priv.h| 133 configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + doc/arch/arm64.ffa.rst| 21 +- 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| 738 ++ .../firmware/arm-ffa/sandbox_arm_ffa_priv.h | 14 - drivers/firmware/arm-ffa/sandbox_ffa.c| 119 +++ include/dm/uclass-id.h| 1 + 15 files changed, 1120 insertions(+), 23 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 c64804ca2d..d7caad3bd4 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..ac713800d1 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -445,6 +445,14 @@ thermal { compatible = "sandbox,thermal"; }; + + arm-ffa-emul { + compatible = "sandbox,arm-ffa-emul"; + }; + + sandbox-arm-ffa { + compatible = "sandbox,arm-ffa"; + }; }; &cros_ec { diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index d72d7a567a..bd42906159 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1802,6 +1802,14 @@ compatible = "u-boot,fwu-mdata-gpt"; fwu-mdata-store = <&mmc0>; }; + + 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 "ed32d533-4209-99e6-2d72-cdd998a79cc0" +#define SANDBOX_SERVICE2_UUID "ed32d544-4209-99e6-2d72-cdd998a79cc0" + +/* IDs of the emulated secure partitions (SPs) */ +#define SANDBOX