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