From: Shiju Jose shiju.jose@huawei.com
Add changes to run 2 SPs at S-EL1 for SPMC_AT_EL=2, where Hafnium is loaded at S-EL2.
This is an experimental version to test loading and booting of more than one SP.
Notes and Observations: 1. Secondary SP is built from the optee-os code with different CFG_TZDRAM parameters. 2. optee-os to be build after building the secondary-optee-os, otherwise getting Stage-2 page fault when booting the primary SP. 3. When build together with optee-os the secondary-optee-os is build only when the corresponding target(secondary-optee-os-common) in the common.mk is used.
Signed-off-by: Shiju Jose shiju.jose@huawei.com --- common.mk | 7 ++++ qemu_v8.mk | 36 ++++++++++++++++--- qemu_v8/secondary_optee_sp_manifest.dts | 46 +++++++++++++++++++++++++ qemu_v8/sp_layout.json | 4 +++ qemu_v8/spmc_el2_manifest.dts | 10 +++++- qemu_v8/tb_fw_config.dts | 4 +++ 6 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 qemu_v8/secondary_optee_sp_manifest.dts
diff --git a/common.mk b/common.mk index e5f2333..1de5426 100644 --- a/common.mk +++ b/common.mk @@ -542,6 +542,13 @@ optee-os-common: optee-os-clean-common: $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_COMMON_FLAGS) clean
+.PHONY: secondary-optee-os-common +secondary-optee-os-common: + $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_COMMON_FLAGS) + +.PHONY: secondary-optee-os-clean-common +secondary-optee-os-clean-common: + $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_COMMON_FLAGS) clean ################################################################################ # OP-TEE Rust ################################################################################ diff --git a/qemu_v8.mk b/qemu_v8.mk index d6bf9a7..20b5b8b 100644 --- a/qemu_v8.mk +++ b/qemu_v8.mk @@ -100,7 +100,7 @@ ROOTFS_ENTRY ?= 0x44000000 ROOTFS_LOADADDR ?= 0x44000000
ifeq ($(SPMC_AT_EL),2) -BL32_DEPS ?= hafnium optee-os +BL32_DEPS ?= hafnium secondary-optee-os optee-os else BL32_DEPS ?= optee-os endif @@ -130,7 +130,7 @@ endif # Targets ################################################################################ TARGET_DEPS := arm-tf buildroot linux optee-os qemu -TARGET_CLEAN := arm-tf-clean buildroot-clean linux-clean optee-os-clean \ +TARGET_CLEAN := arm-tf-clean buildroot-clean linux-clean optee-os-clean secondary-optee-os-clean \ qemu-clean check-clean
TARGET_DEPS += $(BL33_DEPS) @@ -246,6 +246,7 @@ endif rm -f $(BINARIES_PATH)/bl32_extra2.bin rm -f $(BINARIES_PATH)/tos_fw_config.dtb rm -f $(BINARIES_PATH)/op-tee.pkg + rm -f $(BINARIES_PATH)/sec-op-tee.pkg ifeq ($(SPMC_AT_EL),1) ln -sf $(TF_A_OUT)/fdts/spmc_el1_manifest.dtb \ $(BINARIES_PATH)/tos_fw_config.dtb @@ -259,6 +260,7 @@ else ifeq ($(SPMC_AT_EL),2) $(BINARIES_PATH)/tb_fw_config.dtb ln -sf $(HAFNIUM_BIN) $(BINARIES_PATH)/bl32.bin ln -sf $(TF_A_OUT)/op-tee.pkg $(BINARIES_PATH)/op-tee.pkg + ln -sf $(TF_A_OUT)/sec-op-tee.pkg $(BINARIES_PATH)/sec-op-tee.pkg else ifeq ($(SPMC_AT_EL),3) ln -sf $(TF_A_OUT)/fdts/spmc_el3_manifest.dtb \ $(BINARIES_PATH)/tos_fw_config.dtb @@ -373,13 +375,17 @@ OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_2 = CFG_CORE_SEL2_SPMC=y OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_2 += CFG_ARM_GICV3=n CFG_CORE_HAFNIUM_INTC=y # [0e00.0000 0e2f.ffff] is reserved to early boot and SPMC # [0e30.0000 0e33.ffff] is reserved manifest etc (op-tee.pkg) -OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_2 += CFG_TZDRAM_START=0x0e304000 -OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_2 += CFG_TZDRAM_SIZE=0x00cfc000 OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_2 += CFG_CORE_WORKAROUND_NSITR_CACHE_PRIME=n OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_3 = CFG_CORE_EL3_SPMC=y OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_3 += CFG_DT_ADDR=0x40000000 OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_3 += CFG_CORE_RESERVED_SHM=n
+OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_2 = CFG_TZDRAM_START=0x0e304000 +OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_2 += CFG_TZDRAM_SIZE=0x006fc000 + +SECONDARY_OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_2 = CFG_TZDRAM_START=0x0ea04000 +SECONDARY_OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_2 += CFG_TZDRAM_SIZE=0x005fc000 + ifeq ($(XEN_BOOT),y) OPTEE_OS_COMMON_FLAGS += CFG_VIRTUALIZATION=y endif @@ -394,10 +400,32 @@ endif
OPTEE_OS_COMMON_FLAGS += $(OPTEE_OS_COMMON_FLAGS_SPMC_AT_EL_$(SPMC_AT_EL))
+OP_TEE_OS_PATH ?= $(ROOT)/optee_os +OP_TEE_OS_BIN ?= $(OP_TEE_OS_PATH)/out/arm/core/tee-pager_v2.bin +SECONDARY_OP_TEE_OS_BIN ?= $(OP_TEE_OS_PATH)/out/arm/core/secondary-tee-pager_v2.bin + +.PHONY: optee-os +optee-os: optee-os-clean-common +optee-os: OPTEE_OS_COMMON_FLAGS := $(OPTEE_OS_COMMON_FLAGS) $(OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_$(SPMC_AT_EL)) optee-os: optee-os-common
+################################################################################ +# secondary optee-os +################################################################################ + +.PHONY: secondary-optee-os +secondary-optee-os: secondary-optee-os-clean-common +secondary-optee-os: OPTEE_OS_COMMON_FLAGS := $(OPTEE_OS_COMMON_FLAGS) $(SECONDARY_OPTEE_OS_TZDRAM_FLAGS_SPMC_AT_EL_$(SPMC_AT_EL)) +secondary-optee-os: secondary-optee-os-common +secondary-optee-os: + cp $(OP_TEE_OS_BIN) $(SECONDARY_OP_TEE_OS_BIN) + +.PHONY: optee-os-clean optee-os-clean: optee-os-clean-common
+.PHONY: secondary-optee-os-clean +secondary-optee-os-clean: rm $(SECONDARY_OPTEE_OS_BIN) + ################################################################################ # Hafnium ################################################################################ diff --git a/qemu_v8/secondary_optee_sp_manifest.dts b/qemu_v8/secondary_optee_sp_manifest.dts new file mode 100644 index 0000000..0002351 --- /dev/null +++ b/qemu_v8/secondary_optee_sp_manifest.dts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020, Arm Limited. All rights reserved. + * Copyright (c) 2022, Linaro Limited + * + * SPDX-License-Identifier: BSD-3-Clause + * + * This file is a Partition Manifest (PM) for a minimal Secure Partition (SP) + * that has additional optional properties defined. + * + */ + +/dts-v1/; + +/ { + compatible = "arm,ffa-manifest-1.0"; + + /* Properties */ + description = "sec-op-tee"; + ffa-version = <0x00010001>; /* 31:16 - Major, 15:0 - Minor */ + uuid = <0xe4b5f42f 0xed112faf 0x3351d7b9 0xe9cc99fc>; + id = <1>; + execution-ctx-count = <8>; + exception-level = <2>; /* S-EL1 */ + execution-state = <0>; /* AARCH64 */ + load-address = <0xea00000>; + entrypoint-offset = <0x4000>; + xlat-granule = <0>; /* 4KiB */ + boot-order = <0>; + messaging-method = <0x3>; /* Direct messaging only */ + ns-interrupts-action = <1>; /* NS_ACTION_ME */ + + /* Boot protocol */ + gp-register-num = <0x0>; + + device-regions { + compatible = "arm,ffa-manifest-device-regions"; + + uart1 { + base-address = <0x00000000 0x09040000>; + pages-count = <1>; + attributes = <0x3>; /* read-write */ + /* SPI, level-triggered, secure, priority=1 */ + interrupts = <0x28 0xb01>; + }; + }; +}; diff --git a/qemu_v8/sp_layout.json b/qemu_v8/sp_layout.json index c6a02a9..2f9e5b9 100644 --- a/qemu_v8/sp_layout.json +++ b/qemu_v8/sp_layout.json @@ -2,5 +2,9 @@ "op-tee" : { "image": "../../optee_os/out/arm/core/tee-pager_v2.bin", "pm": "optee_sp_manifest.dts" + }, + "sec-op-tee" : { + "image": "../../optee_os/out/arm/core/secondary-tee-pager_v2.bin", + "pm": "secondary_optee_sp_manifest.dts" } } diff --git a/qemu_v8/spmc_el2_manifest.dts b/qemu_v8/spmc_el2_manifest.dts index 7acaa38..4e73df1 100644 --- a/qemu_v8/spmc_el2_manifest.dts +++ b/qemu_v8/spmc_el2_manifest.dts @@ -30,7 +30,15 @@ load_address = <0xe300000>; debug_name = "op-tee"; vcpu_count = <4>; - mem_size = <0xd00000>; + mem_size = <0x700000>; + }; + + vm2 { + is_ffa_partition; + load_address = <0xea00000>; + debug_name = "sec-op-tee"; + vcpu_count = <4>; + mem_size = <0x600000>; }; };
diff --git a/qemu_v8/tb_fw_config.dts b/qemu_v8/tb_fw_config.dts index 68f7b3b..ce3c26a 100644 --- a/qemu_v8/tb_fw_config.dts +++ b/qemu_v8/tb_fw_config.dts @@ -14,5 +14,9 @@ uuid = "486178e0-e7f8-11e3-bc5e-0002a5d5c51b"; load-address = <0xe300000>; }; + sec-op-tee { + uuid = "2ff4b5e4-af2f-11ed-b9d7-5133fc99cce9"; + load-address = <0xea00000>; + }; }; };