[U-Boot] [PATCH 0/4] Tidy up some dangling OP-TEE gotchas

Rober P Day rightly pointed out that some odd OP-TEE specific defines were appearing in his defconfig, despite not having CONFIG_OPTEE=y set in his defconfig.
Looking into this with a small bit of restructure we can fix this corner case.
- Make sure OP-TEE CONFIG options only appear when you are compiling for OPTEE - Fix WaRP7 BL33 so that the low-level init skipping routines can tolerate the afore mentioned change. - Update MAINTAINERS with my own details so that questions pertaining to lib/optee comes my way.
Bryan O'Donoghue (4): optee: Make TZDRAM config options contingent on CONFIG_OPTEE warp7: include: configs: Skip low-level init if BOOTM_OPTEE false warp7: configs: bl33: Tidy up OPTEE defines MAINTAINERS: Update lib/optee with my details
MAINTAINERS | 5 +++++ configs/warp7_bl33_defconfig | 4 +++- include/configs/warp7.h | 4 +--- lib/optee/Kconfig | 2 ++ 4 files changed, 11 insertions(+), 4 deletions(-)

Commit c7b3a7ee5351 ("optee: adjust dependencies and default values for dram") makes the TZDRAM defines for OPTEE show up for all configs as a side-effect. While not harmful its not what we really want.
This patch makes the following defines contingent on CONFIG_OPTEE=y
CONFIG_OPTEE_TZDRAM_BASE CONFIG_OPTEE_TZDRAM_SIZE
Rightly, if you don't have CONFIG_OPTEE=y you don't care about the above two defines.
Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Rui Miguel Silva rui.silva@linaro.org --- lib/optee/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig index 3773d89c31..c398f9b953 100644 --- a/lib/optee/Kconfig +++ b/lib/optee/Kconfig @@ -17,6 +17,7 @@ config OPTEE_LOAD_ADDR config OPTEE_TZDRAM_SIZE hex "Amount of Trust-Zone RAM for the OPTEE image" default 0x0000000 + depends on OPTEE help The size of pre-allocated Trust Zone DRAM to allocate for the OPTEE runtime. @@ -24,6 +25,7 @@ config OPTEE_TZDRAM_SIZE config OPTEE_TZDRAM_BASE hex "Base address of Trust-Zone RAM for the OPTEE image" default 0x00000000 + depends on OPTEE help The base address of pre-allocated Trust Zone DRAM for the OPTEE runtime.

Commit c7b3a7ee5351 ("optee: adjust dependencies and default values for dram") wants to skip low-level init of i.MX7 hardware in the case where OP-TEE has already run and u-boot is being run as BL33 in normal world.
Currently we check for both #ifdef CONFIG_OPTEE_TZDRAM_SIZE and #ifndef CONFIG_OPTEE to determine if lowlevel init should be skipped, however, in order to ensure non-OPTEE users never see OPTEE related defines we cannot rely on this method.
Fortunately we can use CONFIG_BOOTM_OPTEE for the same purpose. CONFIG_BOOTM_OPTEE is only relevant if you want u-boot to load OP-TEE not if u-boot has already been loaded by OP-TEE.
Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Fabio Estevam fabio.estevam@nxp.com Cc: Breno Lima breno.lima@nxp.com Cc: Rui Miguel Silva rui.silva@linaro.org --- include/configs/warp7.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 043f2861b6..458cb8fe10 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -18,11 +18,9 @@ * launched by OPTEE, because of that we shall skip all the low level * initialization since it was already done by ATF or OPTEE */ -#ifdef CONFIG_OPTEE_TZDRAM_SIZE -#ifndef CONFIG_OPTEE +#ifndef CONFIG_BOOTM_OPTEE #define CONFIG_SKIP_LOWLEVEL_INIT #endif -#endif
#define CONFIG_MXC_UART_BASE UART1_IPS_BASE_ADDR

When booting in BL33 mode i.e. with u-boot loaded by OP-TEE we get the following print-out.
Board: WARP7 in secure mode OPTEE DRAM 0xa0000000-0xa0000000
This is incorrect the right range is 0x9e000000-0xa0000000. This patch fixes the defines on the warp7_bl33_defconfig file to tidy up the output.
Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Fabio Estevam fabio.estevam@nxp.com --- configs/warp7_bl33_defconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/configs/warp7_bl33_defconfig b/configs/warp7_bl33_defconfig index 6eaf152bac..8cc622fe47 100644 --- a/configs/warp7_bl33_defconfig +++ b/configs/warp7_bl33_defconfig @@ -50,4 +50,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_ETHER=y CONFIG_USB_ETH_CDC=y CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00" -CONFIG_OPTEE_TZDRAM_SIZE=0x2000000 +CONFIG_OPTEE=y +CONFIG_OPTEE_TZDRAM_BASE=0x9e000000 +CONFIG_OPTEE_TZDRAM_SIZE=0x02000000

Commit 32ce6179fb99 ("optee: Add lib entries for sharing OPTEE code across ports") adds code into lib/optee but neglects to update MAINTAINERS to make me buggable for questions and maintenance.
Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Suggested-by: Jens Wiklander jens.wiklander@linaro.org --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS index aa4b3bc650..16ea180fe2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -754,6 +754,11 @@ F: drivers/tee/ F: include/tee.h F: include/tee/
+TEE-lib +M: Bryan O'Donoghue bryan.odonoghue@linaro.org +S: Maintained +F: lib/optee + UBI M: Kyungmin Park kmpark@infradead.org M: Heiko Schocher hs@denx.de

On 24/04/2019 01:43, Bryan O'Donoghue wrote:
Rober P Day rightly pointed out that some odd OP-TEE specific defines were appearing in his defconfig, despite not having CONFIG_OPTEE=y set in his defconfig.
Ping,
Robert, Rui, Fabio - do you guys want changes here ?
--- bod

Hi Bryan, On Tue 30 Apr 2019 at 02:30, Bryan O'Donoghue wrote:
On 24/04/2019 01:43, Bryan O'Donoghue wrote:
Rober P Day rightly pointed out that some odd OP-TEE specific defines were appearing in his defconfig, despite not having CONFIG_OPTEE=y set in his defconfig.
Ping,
Robert, Rui, Fabio - do you guys want changes here ?
Regarding OPTEE, patches 1/4 and 2/4: Acked-by: Rui Miguel Silva rui.silva@linaro.org
--- Cheers, Rui

On Mon, Apr 29, 2019 at 10:31 PM Bryan O'Donoghue bryan.odonoghue@linaro.org wrote:
On 24/04/2019 01:43, Bryan O'Donoghue wrote:
Rober P Day rightly pointed out that some odd OP-TEE specific defines were appearing in his defconfig, despite not having CONFIG_OPTEE=y set in his defconfig.
Ping,
Robert, Rui, Fabio - do you guys want changes here ?
Looks good to me.
participants (3)
-
Bryan O'Donoghue
-
Fabio Estevam
-
Rui Miguel Silva