Skip to contentSkip to conversation

N1SDP: Bump TF-A version, add optee support

PATCH Applied [email protected] 2 participants 4 messages Aug 16, 2022 – Aug 17, 2022

lore
Share & tools
lore
#0 lore raw

cover N1SDP: Bump TF-A version, add optee support

From: Vishnu Banavath <[email protected]>

These changes are to bump TF-A version for N1SDP and also to add optee-os support for N1SDP platform.

Vishnu Banavath (2):
arm-bsp/trusted-firmware-a: Bump TF-A version for N1SDP arm-bsp/optee: add optee-os support for N1SDP target

 meta-arm-bsp/conf/machine/n1sdp.conf          |   3 +
 .../files/n1sdp/bl_size.patch                 |  40 ---
 .../trusted-firmware-a-n1sdp.inc              |  28 ++-
 ...DR-affinity-shift-and-mask-for-32-bi.patch |  29 +++
 ...lat-n1sdp-add-N1SDP-platform-support.patch | 233 ++++++++++++++++++
 ...ble-instruction-cache-and-data-cache.patch |  46 ++++
 .../n1sdp/0004-Handle-logging-syscall.patch   |  33 +++
 .../recipes-security/optee/optee-os-n1sdp.inc |  22 ++
 .../optee/optee-os_3.18.0.bbappend            |   6 +
 meta-arm/recipes-security/optee/optee-os.inc  |   6 +-
 10 files changed, 396 insertions(+), 50 deletions(-)
 delete mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/bl_size.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0001-core-arm-add-MPIDR-affinity-shift-and-mask-for-32-bi.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0002-plat-n1sdp-add-N1SDP-platform-support.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/optee-os-n1sdp.inc
 create mode 100644 meta-arm-bsp/recipes-security/optee/optee-os_3.18.0.bbappend
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 arm-bsp/trusted-firmware-a: Bump TF-A version for N1SDP

From: Vishnu Banavath <[email protected]>

This change is to bump the TF-A hash which has changes required for optee-os to boot. Also, drop patch related to bl size as the changes are already merged to upstream TF-A.

---
 .../files/n1sdp/bl_size.patch                 | 40 -------------------
 .../trusted-firmware-a-n1sdp.inc              |  5 ++-
 2 files changed, 3 insertions(+), 42 deletions(-)
 delete mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/bl_size.patch
meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/bl_size.patch deleted +0 -40
deleted file mode 100644
index a5b30195..00000000
@@ -1,40 +0,0 @@
-From 80b1efa92486a87f9e82dbf665ef612291148de8 Mon Sep 17 00:00:00 2001
-From: Adam Johnston <[email protected]>
-Date: Tue, 14 Jun 2022 11:19:30 +0000
-Subject: [PATCH] arm-bsp/trusted-firmware-a: N1SDP trusted boot
-
-Increase max size of BL2 on N1SDP by 4KB to enable trusted boot
-Decrease max size of BL1 on N1SDP by 8KB so BL1/BL2 fits above BL31 progbits
-
-Signed-off-by: Adam Johnston <[email protected]>
-Upstream-Status: Pending [Flagged to upstream]
-
----
- plat/arm/board/n1sdp/include/platform_def.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/plat/arm/board/n1sdp/include/platform_def.h b/plat/arm/board/n1sdp/include/platform_def.h
-index c9b81bafa..7468a31ed 100644
---- a/plat/arm/board/n1sdp/include/platform_def.h
-+++ b/plat/arm/board/n1sdp/include/platform_def.h
-@@ -91,7 +91,7 @@
-  * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
-  * plus a little space for growth.
-  */
--#define PLAT_ARM_MAX_BL1_RW_SIZE	0xE000
-+#define PLAT_ARM_MAX_BL1_RW_SIZE	0xC000
- 
- /*
-  * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
-@@ -110,7 +110,7 @@
-  * little space for growth.
-  */
- #if TRUSTED_BOARD_BOOT
--# define PLAT_ARM_MAX_BL2_SIZE		0x20000
-+# define PLAT_ARM_MAX_BL2_SIZE		0x21000
- #else
- # define PLAT_ARM_MAX_BL2_SIZE		0x14000
- #endif
--- 
-2.35.1
-
meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc +3 -2
index f8a0b8d5..9e106055 100644
@@ -1,5 +1,8 @@
 # N1SDP specific TFA support
 
+SRCREV_tfa  = "1d867c14cb41c1171d16fa7e395a4eaed3d572b2"
+PV .= "+git${SRCPV}"
+
 COMPATIBLE_MACHINE = "n1sdp"
 TFA_PLATFORM       = "n1sdp"
 TFA_BUILD_TARGET   = "all fip"
@@ -9,8 +12,6 @@ TFA_MBEDTLS        = "1"
 TFA_UBOOT          = "0"
 TFA_UEFI           = "1"
 
-SRC_URI:append = " file://bl_size.patch"
-
 TFA_ROT_KEY= "plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem"
 
 EXTRA_OEMAKE:append = "\
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 arm-bsp/optee: add optee-os support for N1SDP target

In reply to [email protected]

From: Vishnu Banavath <[email protected]>

These changes are to add support to build optee-os for N1SDP target.

---
 meta-arm-bsp/conf/machine/n1sdp.conf          |   3 +
 .../trusted-firmware-a-n1sdp.inc              |  23 +-
 ...DR-affinity-shift-and-mask-for-32-bi.patch |  29 +++
 ...lat-n1sdp-add-N1SDP-platform-support.patch | 233 ++++++++++++++++++
 ...ble-instruction-cache-and-data-cache.patch |  46 ++++
 .../n1sdp/0004-Handle-logging-syscall.patch   |  33 +++
 .../recipes-security/optee/optee-os-n1sdp.inc |  22 ++
 .../optee/optee-os_3.18.0.bbappend            |   6 +
 meta-arm/recipes-security/optee/optee-os.inc  |   6 +-
 9 files changed, 393 insertions(+), 8 deletions(-)
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0001-core-arm-add-MPIDR-affinity-shift-and-mask-for-32-bi.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0002-plat-n1sdp-add-N1SDP-platform-support.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch
 create mode 100644 meta-arm-bsp/recipes-security/optee/optee-os-n1sdp.inc
 create mode 100644 meta-arm-bsp/recipes-security/optee/optee-os_3.18.0.bbappend
meta-arm-bsp/conf/machine/n1sdp.conf +3 -0
index 5e87e61d..5d1be823 100644
@@ -30,6 +30,9 @@ EXTRA_IMAGEDEPENDS += "virtual/control-processor-firmware"
 #UEFI EDK2 firmware
 EXTRA_IMAGEDEPENDS += "edk2-firmware"
 
+#optee
+PREFERRED_VERSION_optee-os ?= "3.18.%"
+
 #grub-efi
 EFI_PROVIDER ?= "grub-efi"
 MACHINE_FEATURES += "efi"
meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc +16 -7
index 9e106055..034dac30 100644
@@ -14,12 +14,21 @@ TFA_UEFI           = "1"
 
 TFA_ROT_KEY= "plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem"
 
+# Enabling Secure-EL1 Payload Dispatcher (SPD)
+TFA_SPD = "spmd"
+# Cortex-A35 supports Armv8.0-A (no S-EL2 execution state).
+# So, the SPD SPMC component should run at the S-EL1 execution state
+TFA_SPMD_SPM_AT_SEL2 = "0"
+
+# BL2 loads BL32 (optee). So, optee needs to be built first:
+DEPENDS += "optee-os"
+
 EXTRA_OEMAKE:append = "\
                     TRUSTED_BOARD_BOOT=1 \
-                    GENERATE_COT=1 \
-                    CREATE_KEYS=1 \
-                    ENABLE_PIE=0 \
-                    ARM_ROTPK_LOCATION="devel_rsa" \
-                    ROT_KEY="${TFA_ROT_KEY}" \
-                    BL33=${RECIPE_SYSROOT}/firmware/uefi.bin \
-                    "
+		    GENERATE_COT=1 \
+		    CREATE_KEYS=1 \
+		    ARM_ROTPK_LOCATION="devel_rsa" \
+		    ROT_KEY="${TFA_ROT_KEY}" \
+		    BL32=${RECIPE_SYSROOT}/lib/firmware/tee-pager_v2.bin \
+		    BL33=${RECIPE_SYSROOT}/firmware/uefi.bin \
+		    "
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0001-core-arm-add-MPIDR-affinity-shift-and-mask-for-32-bi.patch new file +29 -0
new file mode 100644
index 00000000..f249e526
@@ -0,0 +1,29 @@
+Upstream-Status: Pending [Not submitted to upstream yet]
+Signed-off-by: Vishnu Banavath <[email protected]>
+
+From cf84c933bb7b8a95742d1e723950cb2cde2d5320 Mon Sep 17 00:00:00 2001
+From: Vishnu Banavath <[email protected]>
+Date: Wed, 20 Jul 2022 16:37:10 +0100
+Subject: [PATCH] core: arm: add MPIDR affinity shift and mask for 32-bit
+
+This change is to add MPIDR affinity shift and mask for
+32-bit
+
+Signed-off-by: Vishnu Banavath <[email protected]>
+
+diff --git a/core/arch/arm/include/arm.h b/core/arch/arm/include/arm.h
+index f59478af..2f6f82e7 100644
+--- a/core/arch/arm/include/arm.h
++++ b/core/arch/arm/include/arm.h
+@@ -63,6 +63,8 @@
+ #define MPIDR_AFF1_MASK		(MPIDR_AFFLVL_MASK << MPIDR_AFF1_SHIFT)
+ #define MPIDR_AFF2_SHIFT	U(16)
+ #define MPIDR_AFF2_MASK		(MPIDR_AFFLVL_MASK << MPIDR_AFF2_SHIFT)
++#define MPIDR_AFF3_SHIFT	U(32)
++#define MPIDR_AFF3_MASK		(MPIDR_AFFLVL_MASK << MPIDR_AFF3_SHIFT)
+ 
+ #define MPIDR_MT_SHIFT		U(24)
+ #define MPIDR_MT_MASK		BIT(MPIDR_MT_SHIFT)
+-- 
+2.17.1
+
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0002-plat-n1sdp-add-N1SDP-platform-support.patch new file +233 -0

233 lines not on this page · raw message

meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch new file +46 -0

46 lines not on this page · raw message

meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch new file +33 -0
new file mode 100644
index 00000000..356be9e0
@@ -0,0 +1,33 @@
+Upstream-Status: Pending [Not submitted to upstream yet]
+Signed-off-by: Vishnu Banavath <[email protected]>
+
+From b3fde6c2e1a950214f760ab9f194f3a6572292a8 Mon Sep 17 00:00:00 2001
+From: Balint Dobszay <[email protected]>
+Date: Fri, 15 Jul 2022 13:45:54 +0200
+Subject: [PATCH] Handle logging syscall
+
+Signed-off-by: Balint Dobszay <[email protected]>
+Change-Id: Ib8151cc9c66aea8bcc8fe8b1ecdc3f9f9c5f14e4
+
+%% original patch: 0004-Handle-logging-syscall.patch
+
+diff --git a/core/arch/arm/kernel/spmc_sp_handler.c b/core/arch/arm/kernel/spmc_sp_handler.c
+index e0fa0aa6..c7a45387 100644
+--- a/core/arch/arm/kernel/spmc_sp_handler.c
++++ b/core/arch/arm/kernel/spmc_sp_handler.c
+@@ -1004,6 +1004,12 @@ void spmc_sp_msg_handler(struct thread_smc_args *args,
+ 			ffa_mem_reclaim(args, caller_sp);
+ 			sp_enter(args, caller_sp);
+ 			break;
++		case 0xdeadbeef:
++			ts_push_current_session(&caller_sp->ts_sess);
++			IMSG("%s", (char *)args->a1);
++			ts_pop_current_session();
++			sp_enter(args, caller_sp);
++			break;
+ 		default:
+ 			EMSG("Unhandled FFA function ID %#"PRIx32,
+ 			     (uint32_t)args->a0);
+-- 
+2.17.1
+
meta-arm-bsp/recipes-security/optee/optee-os-n1sdp.inc new file +22 -0
new file mode 100644
index 00000000..219f08bf
@@ -0,0 +1,22 @@
+# N1 SDP specific configuration for optee-os
+
+COMPATIBLE_MACHINE:n1sdp = "n1sdp"
+OPTEEMACHINE:n1sdp = "n1sdp"
+
+TS_INSTALL_PREFIX_PATH = "${RECIPE_SYSROOT}/firmware/sp/opteesp"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/files/optee-os/n1sdp:"
+SRC_URI:append = " \
+    file://0001-core-arm-add-MPIDR-affinity-shift-and-mask-for-32-bi.patch \
+    file://0002-plat-n1sdp-add-N1SDP-platform-support.patch \
+    file://0003-HACK-disable-instruction-cache-and-data-cache.patch \
+    file://0004-Handle-logging-syscall.patch \
+    "
+
+EXTRA_OEMAKE += " CFG_TEE_CORE_LOG_LEVEL=4"
+
+EXTRA_OEMAKE += " CFG_TEE_BENCHMARK=n"
+
+EXTRA_OEMAKE += " CFG_CORE_SEL1_SPMC=y CFG_CORE_FFA=y"
+
+EXTRA_OEMAKE += " CFG_WITH_SP=y"
meta-arm-bsp/recipes-security/optee/optee-os_3.18.0.bbappend new file +6 -0
new file mode 100644
index 00000000..f80e09f8
@@ -0,0 +1,6 @@
+# Machine specific configurations
+
+MACHINE_OPTEE_OS_REQUIRE ?= ""
+MACHINE_OPTEE_OS_REQUIRE:n1sdp = "optee-os-n1sdp.inc"
+
+require ${MACHINE_OPTEE_OS_REQUIRE}
meta-arm/recipes-security/optee/optee-os.inc +5 -1
index 11193dcf..fe0f8b0a 100644
@@ -33,6 +33,8 @@ EXTRA_OEMAKE += " \
     ta-targets=ta_${OPTEE_ARCH} \
     O=${B} \
 "
+EXTRA_OEMAKE += " HOST_PREFIX=${HOST_PREFIX}"
+EXTRA_OEMAKE += " CROSS_COMPILE64=${HOST_PREFIX}"
 
 CFLAGS[unexport] = "1"
 LDFLAGS[unexport] = "1"
@@ -40,7 +42,9 @@ CPPFLAGS[unexport] = "1"
 AS[unexport] = "1"
 LD[unexport] = "1"
 
-do_configure[noexec] = "1"
+do_compile:prepend() {
+	PLAT_LIBGCC_PATH=$(${CC} -print-libgcc-file-name)
+}
 
 do_compile() {
     oe_runmake -C ${S} all
Signature · 1 line
2.17.1
Applied
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Tue, 16 Aug 2022 14:19:31 +0100, [email protected] wrote:

These changes are to bump TF-A version for N1SDP and also to add optee-os support for N1SDP platform.

Vishnu Banavath (2):
arm-bsp/trusted-firmware-a: Bump TF-A version for N1SDP arm-bsp/optee: add optee-os support for N1SDP target

[...]

Applied, thanks!

[1/2] arm-bsp/trusted-firmware-a: Bump TF-A version for N1SDP

      commit: 1badf7877fdcd7d7632f8ddbbde0c726ef501625
[2/2] arm-bsp/optee: add optee-os support for N1SDP target
      commit: 5496260af77a18c26174b99be39986f605d9f615

Best regards,

Signature · 1 line
Jon Mason <[email protected]>