arm-bsp/n1sdp: Enable OP-TEE Cache in N1SDP
cover arm-bsp/n1sdp: Enable OP-TEE Cache in N1SDP
From: Mariam Elshakfy <[email protected]>
These patches enable N1SDP cache to improve performance, change location of OP-TEE from DDR3 to DDR4, and reserve the used region in UEFI (EDK2) to protect against allocations by UEFI applications.
Mariam Elshakfy (2):
arm-bsp/n1sdp: Move OP-TEE to DDR4 arm-bsp/n1sdp: Enable OP-TEE cache in N1SDP
.../0001-Reserve-OP-TEE-memory-from-nwd.patch | 7 +-
.../0002-Modify-BL32-Location-to-DDR4.patch | 30 +++++++++
.../n1sdp/0003-Modify-SPMC-Base-to-DDR4.patch | 28 ++++++++
.../trusted-firmware-a-n1sdp.inc | 2 +
.../recipes-bsp/uefi/edk2-firmware-n1sdp.inc | 1 +
...1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch | 65 +++++++++++++++++++
...lat-n1sdp-add-N1SDP-platform-support.patch | 4 +-
...ble-instruction-cache-and-data-cache.patch | 46 -------------
...atch => 0003-Handle-logging-syscall.patch} | 0
...at-n1sdp-register-DRAM1-to-optee-os.patch} | 0
...-external-device-tree-base-and-size.patch} | 0
.../recipes-security/optee/optee-os-n1sdp.inc | 7 +-
12 files changed, 135 insertions(+), 55 deletions(-)
create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0002-Modify-BL32-Location-to-DDR4.patch
create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0003-Modify-SPMC-Base-to-DDR4.patch
create mode 100644 meta-arm-bsp/recipes-bsp/uefi/files/edk2-platforms/0010-Platform-ARM-N1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch
delete mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0004-Handle-logging-syscall.patch => 0003-Handle-logging-syscall.patch} (100%)
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0005-plat-n1sdp-register-DRAM1-to-optee-os.patch => 0004-plat-n1sdp-register-DRAM1-to-optee-os.patch} (100%)
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0006-plat-n1sdp-add-external-device-tree-base-and-size.patch => 0005-plat-n1sdp-add-external-device-tree-base-and-size.patch} (100%)Signature · 1 line
2.34.1
PATCH 1/2 arm-bsp/n1sdp: Move OP-TEE to DDR4
From: Mariam Elshakfy <[email protected]>
Since the original location of OP-TEE in DDR3 observes a HW issue when cache is enabled, this change moves OP-TEE to run from DDR4. Patches are added to TF-A to reflect that change and the used region is also reserved in UEFI (EDK2) to protect against allocations by UEFI applications. OP-TEE size is modified for consistency across all patches to be 32 MB (0x02000000) instead of (0x02008000).
--- .../0001-Reserve-OP-TEE-memory-from-nwd.patch | 7 +- .../0002-Modify-BL32-Location-to-DDR4.patch | 30 +++++++++ .../n1sdp/0003-Modify-SPMC-Base-to-DDR4.patch | 28 ++++++++ .../trusted-firmware-a-n1sdp.inc | 2 + .../recipes-bsp/uefi/edk2-firmware-n1sdp.inc | 1 + ...1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch | 65 +++++++++++++++++++ ...lat-n1sdp-add-N1SDP-platform-support.patch | 4 +- 7 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0002-Modify-BL32-Location-to-DDR4.patch create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0003-Modify-SPMC-Base-to-DDR4.patch create mode 100644 meta-arm-bsp/recipes-bsp/uefi/files/edk2-platforms/0010-Platform-ARM-N1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch
meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-Reserve-OP-TEE-memory-from-nwd.patch +4 -3
@@ -11,8 +11,9 @@ As a precaution, explicitly reserve this memory via NT_FW_CONFIG to prevent the normal world from using it. This is not required on most platforms as the Trusted OS is run from secure RAM. -Upstream-Status: Pending (not yet submited to upstream) +Upstream-Status: Pending (not yet submitted to upstream) Signed-off-by: Adam Johnston <[email protected]> +Signed-off-by: Mariam Elshakfy <[email protected]> --- plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+)
@@ -31,9 +32,9 @@ index da5e04ddb6..b7e2d4e86f 100644 + #size-cells = <2>; + ranges; + -+ optee@0x08000000 { ++ optee@0xDE000000 { + compatible = "removed-dma-pool"; -+ reg = <0x0 0x08000000 0x0 0x02000000>; ++ reg = <0x0 0xDE000000 0x0 0x02000000>; + no-map; + }; + };
meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0002-Modify-BL32-Location-to-DDR4.patch new file +30 -0
@@ -0,0 +1,30 @@ +From 15dab90c3cb8e7677c4f953c2269e8ee1afa01b0 Mon Oct 2 13:45:43 2023 +From: Mariam Elshakfy <[email protected]> +Date: Mon, 2 Oct 2023 13:45:43 +0000 +Subject: [PATCH] Modify BL32 Location to DDR4 + +Since OP-TEE start address is changed to run +from DDR4, this patch changes BL32 entrypoint +to the correct one. + +Upstream-Status: Pending (not yet submitted to upstream) +Signed-off-by: Mariam Elshakfy <[email protected]> +--- + plat/arm/board/n1sdp/fdts/n1sdp_optee_spmc_manifest.dts | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/plat/arm/board/n1sdp/fdts/n1sdp_optee_spmc_manifest.dts b/plat/arm/board/n1sdp/fdts/n1sdp_optee_spmc_manifest.dts +index ed870803c..797dfe3a4 100644 +--- a/plat/arm/board/n1sdp/fdts/n1sdp_optee_spmc_manifest.dts ++++ b/plat/arm/board/n1sdp/fdts/n1sdp_optee_spmc_manifest.dts +@@ -22,8 +22,8 @@ + maj_ver = <0x1>; + min_ver = <0x0>; + exec_state = <0x0>; +- load_address = <0x0 0x08000000>; +- entrypoint = <0x0 0x08000000>; ++ load_address = <0x0 0xDE000000>; ++ entrypoint = <0x0 0xDE000000>; + binary_size = <0x2000000>; + }; +
meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0003-Modify-SPMC-Base-to-DDR4.patch new file +28 -0
@@ -0,0 +1,28 @@ +From 9a1d11b9fbadf740c73aee6dca4fd0370b38e4a8 Tue Oct 3 13:49:13 2023 +From: Mariam Elshakfy <[email protected]> +Date: Tue, 3 Oct 2023 13:49:13 +0000 +Subject: [PATCH] Modify SPMC Base to DDR4 + +Since OP-TEE start address is changed to run +from DDR4, this patch changes SPMC base to +the correct one. + +Upstream-Status: Pending (not yet submitted to upstream) +Signed-off-by: Mariam Elshakfy <[email protected]> +--- + plat/arm/board/n1sdp/include/platform_def.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/plat/arm/board/n1sdp/include/platform_def.h b/plat/arm/board/n1sdp/include/platform_def.h +index b3799a7b2..b12c61b61 100644 +--- a/plat/arm/board/n1sdp/include/platform_def.h ++++ b/plat/arm/board/n1sdp/include/platform_def.h +@@ -118,7 +118,7 @@ + + #define PLAT_ARM_MAX_BL31_SIZE UL(0x40000) + +-#define PLAT_ARM_SPMC_BASE U(0x08000000) ++#define PLAT_ARM_SPMC_BASE U(0xDE000000) + #define PLAT_ARM_SPMC_SIZE UL(0x02000000) /* 32 MB */ + +
meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc +2 -0
@@ -13,6 +13,8 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files/n1sdp:" SRC_URI:append = " \ file://0001-Reserve-OP-TEE-memory-from-nwd.patch \ + file://0002-Modify-BL32-Location-to-DDR4.patch \ + file://0003-Modify-SPMC-Base-to-DDR4.patch \ " TFA_ROT_KEY= "plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem"
meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-n1sdp.inc +1 -0
@@ -23,6 +23,7 @@ SRC_URI:append = "\ file://0007-Platform-ARM-N1Sdp-Persistent-storage-for-N1Sdp.patch;patchdir=edk2-platforms \ file://0008-Platform-ARM-N1Sdp-Enable-FaultTolerantWrite-Dxe-dri.patch;patchdir=edk2-platforms \ file://0009-Platform-ARM-N1Sdp-manually-poll-QSPI-status-bit-aft.patch;patchdir=edk2-platforms \ + file://0010-Platform-ARM-N1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch;patchdir=edk2-platforms \ " do_deploy:append() {
meta-arm-bsp/recipes-bsp/uefi/files/edk2-platforms/0010-Platform-ARM-N1Sdp-Reserve-OP-TEE-Region-from-UEFI.patch new file +65 -0
65 lines not on this page · raw message
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0002-plat-n1sdp-add-N1SDP-platform-support.patch +2 -2
@@ -49,8 +49,8 @@ index 00000000..06b4975a +CFG_CORE_HEAP_SIZE = 0x32000 # 200kb + +CFG_TEE_CORE_NB_CORE = 4 -+CFG_TZDRAM_START ?= 0x08000000 -+CFG_TZDRAM_SIZE ?= 0x02008000 ++CFG_TZDRAM_START ?= 0xDE000000 ++CFG_TZDRAM_SIZE ?= 0x02000000 + +CFG_SHMEM_START ?= 0x83000000 +CFG_SHMEM_SIZE ?= 0x00210000
Signature · 1 line
2.34.1
PATCH 2/2 arm-bsp/n1sdp: Enable OP-TEE cache in N1SDP
In reply to [email protected]From: Mariam Elshakfy <[email protected]>
This change enables N1SDP cache to improve performance by removing this patch:
HACK-disable-instruction-cache-and-data-cache.patch
---
...ble-instruction-cache-and-data-cache.patch | 46 -------------------
...atch => 0003-Handle-logging-syscall.patch} | 0
...at-n1sdp-register-DRAM1-to-optee-os.patch} | 0
...-external-device-tree-base-and-size.patch} | 0
.../recipes-security/optee/optee-os-n1sdp.inc | 7 ++-
5 files changed, 3 insertions(+), 50 deletions(-)
delete mode 100644 meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0004-Handle-logging-syscall.patch => 0003-Handle-logging-syscall.patch} (100%)
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0005-plat-n1sdp-register-DRAM1-to-optee-os.patch => 0004-plat-n1sdp-register-DRAM1-to-optee-os.patch} (100%)
rename meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/{0006-plat-n1sdp-add-external-device-tree-base-and-size.patch => 0005-plat-n1sdp-add-external-device-tree-base-and-size.patch} (100%)meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch deleted +0 -46
@@ -1,46 +0,0 @@ -Upstream-Status: Pending [Not submitted to upstream yet] -Signed-off-by: Vishnu Banavath <[email protected]> - -From 0c3ce4c09cd7d2ff4cd2e62acab899dd88dc9514 Mon Sep 17 00:00:00 2001 -From: Vishnu Banavath <[email protected]> -Date: Wed, 20 Jul 2022 16:45:59 +0100 -Subject: [PATCH] HACK: disable instruction cache and data cache. - -For some reason, n1sdp fails to boot with instruction cache and -data cache enabled. This is a temporary change to disable I cache -and D cache until a proper fix is found. - -Signed-off-by: Vishnu Banavath <[email protected]> - -%% original patch: 0003-HACK-disable-instruction-cache-and-data-cache.patch - -diff --git a/core/arch/arm/kernel/entry_a64.S b/core/arch/arm/kernel/entry_a64.S -index 875b6e69..594d6928 100644 ---- a/core/arch/arm/kernel/entry_a64.S -+++ b/core/arch/arm/kernel/entry_a64.S -@@ -52,7 +52,7 @@ - - .macro set_sctlr_el1 - mrs x0, sctlr_el1 -- orr x0, x0, #SCTLR_I -+ bic x0, x0, #SCTLR_I - orr x0, x0, #SCTLR_SA - orr x0, x0, #SCTLR_SPAN - #if defined(CFG_CORE_RWDATA_NOEXEC) -@@ -490,11 +490,11 @@ LOCAL_FUNC enable_mmu , : , .identity_map - isb - - /* Enable I and D cache */ -- mrs x1, sctlr_el1 -+ /* mrs x1, sctlr_el1 - orr x1, x1, #SCTLR_I - orr x1, x1, #SCTLR_C - msr sctlr_el1, x1 -- isb -+ isb */ - - /* Adjust stack pointers and return address */ - msr spsel, #1 --- -2.17.1 -
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-Handle-logging-syscall.patch renamed from meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch +0 -0
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-plat-n1sdp-register-DRAM1-to-optee-os.patch renamed from meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0005-plat-n1sdp-register-DRAM1-to-optee-os.patch +0 -0
meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0005-plat-n1sdp-add-external-device-tree-base-and-size.patch renamed from meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0006-plat-n1sdp-add-external-device-tree-base-and-size.patch +0 -0
meta-arm-bsp/recipes-security/optee/optee-os-n1sdp.inc +3 -4
@@ -8,10 +8,9 @@ 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 \ - file://0005-plat-n1sdp-register-DRAM1-to-optee-os.patch \ - file://0006-plat-n1sdp-add-external-device-tree-base-and-size.patch \ + file://0003-Handle-logging-syscall.patch \ + file://0004-plat-n1sdp-register-DRAM1-to-optee-os.patch \ + file://0005-plat-n1sdp-add-external-device-tree-base-and-size.patch \ " EXTRA_OEMAKE += " CFG_TEE_CORE_LOG_LEVEL=4"
Signature · 1 line
2.34.1
Jon Mason
AppliedQuoted 8 lines · On Mon, 23 Oct 2023 13:16:59 +0100, [email protected] wrote:
From: Mariam Elshakfy <[email protected]>
These patches enable N1SDP cache to improve performance, change location of OP-TEE from DDR3 to DDR4, and reserve the used region in UEFI (EDK2) to protect against allocations by UEFI applications.
[...]
Applied, thanks!
[1/2] arm-bsp/n1sdp: Move OP-TEE to DDR4
commit: c3ee38fca534fd7b84503adc875086843403b96a
[2/2] arm-bsp/n1sdp: Enable OP-TEE cache in N1SDP
commit: 60eab95971dcef139e76fd2ead3b663b5a87840eBest regards,
Signature · 1 line
Jon Mason <[email protected]>