From 035c9119b2f40db991e29ab69ce4842a907cb91c Mon Sep 17 00:00:00 2001 From: Bjorn Engstrom Date: Fri, 26 Aug 2022 09:45:45 +0200 Subject: [PATCH] build(ethos-n): add TZMP1 build flag For the Arm(R) Ethos(TM)-N NPU Driver to support running inference with protected memory the TZC must be configured with appropriate regions. This is controlled in build time by the now added build flag. The new build flag is only supported with the Arm Juno platform and the TZC is configured with default memory regions as if TZMP1 wasn't enabled to facilitate adding the new memory regions later. Signed-off-by: Bjorn Engstrom Signed-off-by: Rob Hughes Signed-off-by: Mikael Olsson Change-Id: I9dc49ac5d091cfbc8c20d7c3ab394a2836438b0f --- docs/plat/arm/arm-build-options.rst | 5 ++++- plat/arm/board/juno/juno_security.c | 17 ++++++++++++++++- plat/arm/board/juno/platform.mk | 8 ++++++-- plat/arm/common/arm_common.mk | 15 +++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/plat/arm/arm-build-options.rst b/docs/plat/arm/arm-build-options.rst index 68eb3ecd6..dda2aa0a9 100644 --- a/docs/plat/arm/arm-build-options.rst +++ b/docs/plat/arm/arm-build-options.rst @@ -101,6 +101,9 @@ Arm Platform Build Options the Arm Juno platform has this included in its ``HW_CONFIG`` and the platform only loads the ``HW_CONFIG`` in AArch64 builds. Default is 0. +- ``ARM_ETHOSN_NPU_TZMP1``: boolean option to enable TZMP1 support for the + Arm® Ethos™-N NPU. Requires ``ARM_ETHOSN_NPU_DRIVER`` to be enabled. + - ``ARM_SPMC_MANIFEST_DTS`` : path to an alternate manifest file used as the SPMC Core manifest. Valid when ``SPD=spmd`` is selected. @@ -165,4 +168,4 @@ Arm CSS Platform-Specific Build Options .. |FIP in a GPT image| image:: ../../resources/diagrams/FIP_in_a_GPT_image.png -*Copyright (c) 2019-2021, Arm Limited. All rights reserved.* +*Copyright (c) 2019-2023, Arm Limited. All rights reserved.* diff --git a/plat/arm/board/juno/juno_security.c b/plat/arm/board/juno/juno_security.c index 654a7f165..a0fd36ce7 100644 --- a/plat/arm/board/juno/juno_security.c +++ b/plat/arm/board/juno/juno_security.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2023, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -78,6 +78,18 @@ static void init_v550(void) #endif /* JUNO_TZMP1 */ +#ifdef JUNO_ETHOSN_TZMP1 +/* + * Currently use the default regions defined in ARM_TZC_REGIONS_DEF. + * See the definition in /include/plat/arm/common/plat_arm.h + */ +static const arm_tzc_regions_info_t juno_ethosn_tzmp1_tzc_regions[] = { + ARM_TZC_REGIONS_DEF, /* See define in /include/plat/arm/common/plat_arm.h */ + {}, +}; + +#endif /* JUNO_ETHOSN_TZMP1 */ + /******************************************************************************* * Set up the MMU-401 SSD tables. The power-on configuration has all stream IDs * assigned to Non-Secure except some for the DMA-330. Assign those back to the @@ -140,6 +152,9 @@ void plat_arm_security_setup(void) (void *)JUNO_AP_TZC_SHARE_DRAM1_BASE); INFO("TZC protected shared memory end address for TZMP usecase: %p\n", (void *)JUNO_AP_TZC_SHARE_DRAM1_END); +#elif defined(JUNO_ETHOSN_TZMP1) + arm_tzc400_setup(PLAT_ARM_TZC_BASE, juno_ethosn_tzmp1_tzc_regions); + INFO("TZC set up with default settings for NPU TZMP usecase\n"); #else arm_tzc400_setup(PLAT_ARM_TZC_BASE, NULL); #endif diff --git a/plat/arm/board/juno/platform.mk b/plat/arm/board/juno/platform.mk index 2c84eb34d..d99b16c82 100644 --- a/plat/arm/board/juno/platform.mk +++ b/plat/arm/board/juno/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2013-2023, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -43,7 +43,11 @@ $(eval $(call add_define,JUNO_AARCH32_EL3_RUNTIME)) JUNO_TZMP1 := 0 $(eval $(call assert_boolean,JUNO_TZMP1)) ifeq (${JUNO_TZMP1}, 1) -$(eval $(call add_define,JUNO_TZMP1)) + ifeq (${ARM_ETHOSN_NPU_TZMP1},1) + $(error JUNO_TZMP1 cannot be used together with ARM_ETHOSN_NPU_TZMP1) + else + $(eval $(call add_define,JUNO_TZMP1)) + endif endif TRNG_SUPPORT := 1 diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk index de2c4f830..dc875e526 100644 --- a/plat/arm/common/arm_common.mk +++ b/plat/arm/common/arm_common.mk @@ -119,6 +119,21 @@ ARM_ETHOSN_NPU_DRIVER := 0 $(eval $(call assert_boolean,ARM_ETHOSN_NPU_DRIVER)) $(eval $(call add_define,ARM_ETHOSN_NPU_DRIVER)) +# Arm(R) Ethos(TM)-N NPU TZMP1 +ARM_ETHOSN_NPU_TZMP1 := 0 +$(eval $(call assert_boolean,ARM_ETHOSN_NPU_TZMP1)) +$(eval $(call add_define,ARM_ETHOSN_NPU_TZMP1)) +ifeq (${ARM_ETHOSN_NPU_TZMP1},1) + ifeq (${ARM_ETHOSN_NPU_DRIVER},0) + $(error ARM_ETHOSN_NPU_TZMP1 is only available if ARM_ETHOSN_NPU_DRIVER=1) + endif + ifeq (${PLAT},juno) + $(eval $(call add_define,JUNO_ETHOSN_TZMP1)) + else + $(error ARM_ETHOSN_NPU_TZMP1 only supported on Juno platform, not ${PLAT}) + endif +endif + # Use an implementation of SHA-256 with a smaller memory footprint but reduced # speed. $(eval $(call add_define,MBEDTLS_SHA256_SMALLER))