Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 1 | # Select which SPMC version to use. Possible values: |
| 2 | # - github: up-stream version from master branch |
| 3 | # - tforg: trustedfirmware.org fork (integration or psa-development branch) |
| 4 | SPMC_VERSION ?= github |
| 5 | |
| 6 | # Trusted Services build configs. SP_COMMON_FLAGS is passed to each Trusted |
| 7 | # Services SP. |
| 8 | SP_COMMON_FLAGS ?= |
| 9 | #PSA SP specific build configs: |
| 10 | ifeq (tforg, $(SPMC_VERSION)) |
| 11 | DTS_CONFIG ?= -DLINUX_SP_DEFINITION |
| 12 | PSA_CRYPTO_EXTRA_FLAGS ?= |
| 13 | else |
| 14 | PSA_CRYPTO_EXTRA_FLAGS ?= -DTS_PLATFORM=ts/mock |
| 15 | DTS_CONFIG ?= |
| 16 | endif |
| 17 | PSA_ITS_EXTRA_FLAGS ?= |
| 18 | PSA_PROTECTED_STORAGE_EXTRA_FLAGS ?= |
| 19 | PSA_ATTESTATION_EXTRA_FLAGS ?= |
| 20 | PSA_SMM_GATEWAY_EXTRA_FLAGS ?= |
| 21 | |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 22 | DTS ?= optee_ffa |
| 23 | DTS_PATH ?= $(BUILD_PATH)/fvp |
| 24 | USE_FVP_BASE_PLAT ?= 1 |
| 25 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 26 | # Use "embedded" or "fip" |
| 27 | SP_PACKAGING_METHOD ?= embedded |
| 28 | |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 29 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_CORE_SEL1_SPMC=y CFG_CORE_FFA=y |
Gyorgy Szing | f3a6712 | 2021-06-28 17:47:14 +0200 | [diff] [blame] | 30 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_CORE_HEAP_SIZE=131072 |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 31 | OPTEE_OS_COMMON_EXTRA_FLAGS += O=out/arm |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 32 | ifeq (tforg, $(SPMC_VERSION)) |
| 33 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_WITH_SP=y |
Jelle Sels | d58d027 | 2021-06-04 10:36:22 +0200 | [diff] [blame] | 34 | SP_EVENT_LOG ?=y |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 35 | else |
| 36 | SP_EVENT_LOG ?=n |
| 37 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_SECURE_PARTITION=y |
| 38 | endif |
| 39 | |
Jelle Sels | d58d027 | 2021-06-04 10:36:22 +0200 | [diff] [blame] | 40 | ifeq (y,$(SP_EVENT_LOG)) |
| 41 | TF_A_FLAGS ?= \ |
| 42 | ARM_TSP_RAM_LOCATION=tdram \ |
| 43 | BL32=$(OPTEE_OS_PAGER_V2_BIN) \ |
| 44 | BL33=$(EDK2_BIN) \ |
| 45 | DEBUG=0 \ |
| 46 | PLAT=fvp \ |
| 47 | SPMD_SPM_AT_SEL2=0 \ |
| 48 | MBEDTLS_DIR=$(ROOT)/mbedtls \ |
| 49 | ARM_ROTPK_LOCATION=devel_rsa \ |
| 50 | ARM_TSP_RAM_LOCATION=tdram \ |
| 51 | FVP_USE_GIC_DRIVER=FVP_GICV3 \ |
| 52 | GENERATE_COT=1 \ |
| 53 | MEASURED_BOOT=1 \ |
| 54 | PLAT=fvp \ |
| 55 | ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \ |
| 56 | TPM_HASH_ALG=sha256 \ |
| 57 | TRUSTED_BOARD_BOOT=1 \ |
| 58 | EVENT_LOG_LEVEL=20 \ |
| 59 | BL2_optee=y \ |
| 60 | SPD=spmd |
| 61 | else |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 62 | TF_A_FLAGS ?= \ |
| 63 | ARM_TSP_RAM_LOCATION=tdram \ |
| 64 | BL32=$(OPTEE_OS_PAGER_V2_BIN) \ |
| 65 | BL33=$(EDK2_BIN) \ |
| 66 | DEBUG=$(DEBUG) \ |
| 67 | PLAT=fvp \ |
| 68 | SPD=spmd \ |
| 69 | SPMD_SPM_AT_SEL2=0 |
Jelle Sels | d58d027 | 2021-06-04 10:36:22 +0200 | [diff] [blame] | 70 | endif |
Balint Dobszay | d777a3e | 2020-07-15 15:53:05 +0200 | [diff] [blame] | 71 | include fvp.mk |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 72 | |
Jelle Sels | d58d027 | 2021-06-04 10:36:22 +0200 | [diff] [blame] | 73 | TF_A_FLAGS+=ARM_SPMC_MANIFEST_DTS=$(CURDIR)/fvp/spmc_manifest.dts |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 74 | TS_INSTALL_PREFIX:=$(CURDIR)/../out-ts |
| 75 | |
| 76 | # Add machinery allowing to build secure partitions from Trusted Services. |
| 77 | # |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 78 | # build-sp <sp-name>,<uuid>,<TS build flags> |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 79 | # <sp name> The name of the SP. |
| 80 | # |
| 81 | # When called build and clean targets for the SP will be defined as: |
| 82 | # |
| 83 | # ffa-<sp name>-sp - Build the SP with cmake, and include the SP |
| 84 | # export makefile to make the SP binary part |
| 85 | # of the OP-TEE OS image. |
| 86 | # ffa-<sp name>-sp-clean - run make clean on the cmake project |
| 87 | # ffa-<sp name>-sp-realclean - remove all cmake output |
| 88 | # |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 89 | # To run these for each SP in one step, the "ffa-sp-all", "ffa-sp-all-clean" and |
| 90 | # "ffa-sp-all-realclean" targets are defined. |
| 91 | # |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 92 | # The build and the clean target are added to the dependency tree of common |
| 93 | # op-tee targets. |
| 94 | # |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 95 | #example: |
| 96 | #$(eval $(call build-sp,crypto,d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0, -DTS_PLATFORM=ts/mock)) |
| 97 | #This wil build the crypto_sp with the mock platorm as it backend. |
| 98 | #Don't add spaces between the ',' and the uuid and name. |
Gyorgy Szing | 0a5029d | 2020-11-06 00:33:49 +0100 | [diff] [blame] | 99 | |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 100 | .PHONY: ffa-sp-all |
| 101 | .PHONY: ffa-sp-all-clean |
| 102 | .PHONY: ffa-sp-all-realclean |
| 103 | |
| 104 | optee-os-common: ffa-sp-all |
| 105 | optee-os-clean: ffa-sp-all-clean |
| 106 | |
| 107 | ffa-sp-all-realclean: |
| 108 | rm -rf $(TS_INSTALL_PREFIX)/opteesp |
| 109 | |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 110 | ifeq (tforg-fip, $(SPMC_VERSION)-$(SP_PACKAGING_METHOD)) |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 111 | # If FIP packaging method is selected, TF-A requires a number of config options: |
| 112 | # - ARM_BL2_SP_LIST_DTS: This file will be included into the TB_FW_CONFIG DT |
| 113 | # of TF-A. It contains the UUID and load address of SP |
| 114 | # packages present in the FIP, BL2 will load them based |
| 115 | # on this information. |
| 116 | # - ARM_SPMC_MANIFEST_DTS: Contains information about the SPMC: consumed by the |
| 117 | # SPMD at SPMC init. And about the SP packages: the |
| 118 | # SPMC can only know where the packages were loaded by |
| 119 | # BL2 based on this file. |
| 120 | # - SP_LAYOUT_FILE: JSON file which describes the corresponding SP image |
| 121 | # and SP manifest DT pairs, TF-A will create the SP |
| 122 | # packages based on this. However, the TS build |
| 123 | # provides a separate JSON file for each SP. A Python |
| 124 | # snippet is used to merge these JSONs into one file. |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 125 | define include_sp |
| 126 | TS_SP_JSON_LIST+=${TS_INSTALL_PREFIX}/opteesp/json/$1.json |
| 127 | endef |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 128 | SP_LAYOUT_FILE := $(TS_INSTALL_PREFIX)/opteesp/json/sp_layout.json |
| 129 | |
| 130 | TF_A_FLAGS+=SP_LAYOUT_FILE=$(SP_LAYOUT_FILE) |
| 131 | TF_A_FLAGS+=ARM_BL2_SP_LIST_DTS=$(CURDIR)/fvp/bl2_sp_images.dtsi |
Balint Dobszay | d520b00 | 2021-03-29 18:54:30 +0200 | [diff] [blame] | 132 | OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_FIP_SP=y |
| 133 | |
| 134 | MERGE_JSON_PY := import json, sys |
| 135 | MERGE_JSON_PY += \ncombined = {} |
| 136 | MERGE_JSON_PY += \nfor path in sys.stdin.read().split(): |
| 137 | MERGE_JSON_PY += \n with open(path) as f: |
| 138 | MERGE_JSON_PY += \n current = json.load(f) |
| 139 | MERGE_JSON_PY += \n combined = {**combined, **current} |
| 140 | MERGE_JSON_PY += \nprint(json.dumps(combined, indent=4)) |
| 141 | |
| 142 | $(SP_LAYOUT_FILE): ffa-sp-all |
| 143 | @echo $(TS_SP_JSON_LIST) | python3 -c "$$(echo -e '$(MERGE_JSON_PY)')" > $(SP_LAYOUT_FILE) |
| 144 | |
| 145 | .PHONY: ffa-sp-layout-clean |
| 146 | ffa-sp-layout-clean: |
| 147 | @rm -f $(SP_LAYOUT_FILE) |
| 148 | |
| 149 | arm-tf: $(SP_LAYOUT_FILE) |
| 150 | ffa-sp-all-clean: ffa-sp-layout-clean |
| 151 | endif |
Balint Dobszay | 7700109 | 2021-02-15 13:52:55 +0100 | [diff] [blame] | 152 | |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 153 | ifeq (embedded, $(SP_PACKAGING_METHOD)) |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 154 | # If embedded packaging method is selected, the SP manifest files from TS have |
| 155 | # to be merged into a common DTS file, which is passed to OP-TEE as the embedded |
| 156 | # DT file. For each SP a dtsi file is exported from TS, which contains a single |
| 157 | # node, representing that SP. |
| 158 | # The TS_SP_DTSI_LIST parameter contains a line like this for each SP: |
| 159 | # |
| 160 | # #include "<absolute_path_to_dtsi>/<sp_uuid>.dtsi" |
| 161 | # |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 162 | define include_sp |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 163 | ifeq (tforg, $(SPMC_VERSION)) |
| 164 | OPTEE_OS_COMMON_EXTRA_FLAGS+=EARLY_TA_PATHS+=${TS_INSTALL_PREFIX}/opteesp/bin/$1.stripped.elf |
| 165 | TS_SP_DTSI_LIST+="\\n\#include \"${TS_INSTALL_PREFIX}/opteesp/manifest/$1.dtsi\"" |
| 166 | else |
| 167 | OPTEE_OS_COMMON_EXTRA_FLAGS+=SP_PATHS+=${TS_INSTALL_PREFIX}/opteesp/bin/$1.stripped.elf |
| 168 | endif |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 169 | endef |
| 170 | |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 171 | ifeq (tforg, $(SPMC_VERSION)) |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 172 | SP_MANIFEST_FILE := $(OUT_PATH)/sp_manifest.dts |
| 173 | OPTEE_OS_COMMON_EXTRA_FLAGS+=CFG_EMBED_DTB_SOURCE_FILE=$(SP_MANIFEST_FILE) |
| 174 | |
| 175 | $(SP_MANIFEST_FILE): ffa-sp-all |
| 176 | @echo -e "/dts-v1/;\n/ {$(TS_SP_DTSI_LIST)\n};" > $(SP_MANIFEST_FILE) |
| 177 | |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 178 | optee-os-common: $(SP_MANIFEST_FILE) |
| 179 | |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 180 | .PHONY: ffa-sp-manifest-clean |
| 181 | ffa-sp-manifest-clean: |
| 182 | @rm -f $(SP_MANIFEST_FILE) |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 183 | ffa-sp-all-clean: ffa-sp-manifest-clean |
| 184 | endif |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 185 | endif |
Balint Dobszay | 5c7c058 | 2021-04-13 13:02:22 +0200 | [diff] [blame] | 186 | |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 187 | define build-sp |
| 188 | .PHONY: ffa-$1-sp |
| 189 | ffa-$1-sp: |
| 190 | $(eval $(call include_sp,$2)) |
| 191 | CROSS_COMPILE="$$(AARCH64_CROSS_COMPILE)" cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$${TS_INSTALL_PREFIX} \ |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 192 | -S $$(CURDIR)/../trusted-services/deployments/$1/opteesp -B $$(CURDIR)/../ts-build/$1 \ |
| 193 | ${SP_COMMON_FLAGS} $3 |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 194 | cmake --build $$(CURDIR)/../ts-build/$1 -- -j$$(nproc) |
| 195 | cmake --install $$(CURDIR)/../ts-build/$1 |
| 196 | |
| 197 | .PHONY: ffa-$1-sp-clean |
| 198 | ffa-$1-sp-clean: |
| 199 | cmake --build $$(CURDIR)/../ts-build/$1 -- clean -j$$(nproc) |
| 200 | |
| 201 | .PHONY: ffa-$1-sp-realclean |
| 202 | ffa-$1-sp-realclean: |
| 203 | rm -rf $$(CURDIR)/../ts-build/$1 |
| 204 | |
| 205 | ffa-sp-all: ffa-$1-sp |
| 206 | ffa-sp-all-clean: ffa-$1-sp-clean |
| 207 | ffa-sp-all-realclean: ffa-$1-sp-realclean |
| 208 | endef |
| 209 | |
Jelle Sels | b2ccc05 | 2022-01-19 15:49:28 +0100 | [diff] [blame^] | 210 | $(eval $(call build-sp,internal-trusted-storage,dc1eef48-b17a-4ccf-ac8b-dfcff7711b14, ${PSA_ITS_EXTRA_FLAGS})) |
| 211 | $(eval $(call build-sp,protected-storage,751bf801-3dde-4768-a514-0f10aeed1790, ${PSA_PROTECTED_STORAGE_EXTRA_FLAGS})) |
| 212 | $(eval $(call build-sp,crypto,d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0, ${PSA_CRYPTO_EXTRA_FLAGS})) |
| 213 | ifeq (tforg, $(SPMC_VERSION)) |
| 214 | $(eval $(call build-sp,attestation,a1baf155-8876-4695-8f7c-54955e8db974, ${PSA_ATTESTATION_EXTRA_FLAGS})) |
| 215 | $(eval $(call build-sp,smm-gateway,ed32d533-99e6-4209-9cc0-2d72cdd998a7, ${PSA_SMM_GATEWAY_EXTRA_FLAGS})) |
| 216 | endif |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 217 | |
| 218 | .PHONY: sp_uuid_list |
| 219 | sp_uuid_list: $(SHARED_DIR)/sp_uuid_list.txt |
| 220 | |
| 221 | .PHONY: sp_uuid_list_clean |
| 222 | sp_uuid_list_clean: |
| 223 | rm -rf $(SHARED_DIR)/sp_uuid_list.txt |
| 224 | |
| 225 | ffa-sp-all-clean: sp_uuid_list_clean |
| 226 | |
| 227 | $(SHARED_DIR)/sp_uuid_list.txt: ffa-sp-all |
Balint Dobszay | 1cd203b | 2021-04-28 13:24:12 +0200 | [diff] [blame] | 228 | find $(TS_INSTALL_PREFIX)/opteesp/bin -name "[0-9a-f-]*.elf" -type f | \ |
| 229 | sed -n "s@.*/\(.*\).stripped.elf@\1@gp" | tr '\n' ',' | \ |
| 230 | head -c -1 > $(SHARED_DIR)/sp_uuid_list.txt |
Gyorgy Szing | 7d8a64b | 2020-11-10 15:54:01 +0100 | [diff] [blame] | 231 | |
Jelle Sels | e6f9633 | 2022-01-19 15:45:37 +0100 | [diff] [blame] | 232 | # Add targets to build the "arm_ffa_user" Linux Kernel module. |
| 233 | arm_ffa_user: sp_uuid_list linux |
| 234 | $(eval ROOT:=$(CURDIR)/..) |
| 235 | make -C $(CURDIR)/../linux_poc $(LINUX_COMMON_FLAGS) install |
| 236 | |
Gyorgy Szing | 7d8a64b | 2020-11-10 15:54:01 +0100 | [diff] [blame] | 237 | arm_ffa_user_clean: |
| 238 | make -C $(CURDIR)/../linux_poc clean |
| 239 | |
| 240 | all: arm_ffa_user |