Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | # |
Jayanth Dodderi Chidanand | 656336b | 2023-03-31 10:42:10 +0100 | [diff] [blame] | 2 | # Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | # |
| 6 | |
Marcin Juszkiewicz | a70ef5e | 2023-07-24 21:08:16 +0200 | [diff] [blame] | 7 | PLAT_QEMU_PATH := plat/qemu/qemu |
| 8 | PLAT_QEMU_COMMON_PATH := plat/qemu/common |
| 9 | |
Marcin Juszkiewicz | e6dea09 | 2023-07-24 22:22:42 +0200 | [diff] [blame] | 10 | SEPARATE_CODE_AND_RODATA := 1 |
| 11 | ENABLE_STACK_PROTECTOR := 0 |
| 12 | |
Marcin Juszkiewicz | 7754e82 | 2023-07-24 20:56:29 +0200 | [diff] [blame] | 13 | include plat/qemu/common/common.mk |
| 14 | |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 15 | # Use the GICv2 driver on QEMU by default |
| 16 | QEMU_USE_GIC_DRIVER := QEMU_GICV2 |
| 17 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 18 | ifeq (${ARM_ARCH_MAJOR},7) |
| 19 | # ARMv7 Qemu support in trusted firmware expects the Cortex-A15 model. |
| 20 | # Qemu Cortex-A15 model does not implement the virtualization extension. |
| 21 | # For this reason, we cannot set ARM_CORTEX_A15=yes and must define all |
| 22 | # the ARMv7 build directives. |
Govindraj Raja | cd10c6e | 2023-05-30 16:52:15 -0500 | [diff] [blame] | 23 | MARCH_DIRECTIVE := -mcpu=cortex-a15 |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 24 | $(eval $(call add_define,ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)) |
| 25 | $(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER)) |
Jerome Forissier | decc8dd | 2020-02-07 11:13:46 +0100 | [diff] [blame] | 26 | $(eval $(call add_define,ARMV7_SUPPORTS_VFP)) |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 27 | # Qemu expects a BL32 boot stage. |
| 28 | NEED_BL32 := yes |
| 29 | endif # ARMv7 |
| 30 | |
| 31 | ifeq (${SPD},opteed) |
| 32 | add-lib-optee := yes |
| 33 | endif |
| 34 | ifeq ($(AARCH32_SP),optee) |
| 35 | add-lib-optee := yes |
| 36 | endif |
Jens Wiklander | ff263dc | 2021-05-25 18:15:11 +0200 | [diff] [blame] | 37 | ifeq ($(SPMC_OPTEE),1) |
| 38 | $(eval $(call add_define,SPMC_OPTEE)) |
| 39 | add-lib-optee := yes |
| 40 | endif |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 41 | |
Raymond Mao | 032ba02 | 2023-06-28 15:07:15 -0700 | [diff] [blame] | 42 | ifeq (${TRANSFER_LIST},1) |
| 43 | include lib/transfer_list/transfer_list.mk |
| 44 | endif |
| 45 | |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 46 | ifeq ($(NEED_BL32),yes) |
| 47 | $(eval $(call add_define,QEMU_LOAD_BL32)) |
| 48 | endif |
| 49 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 50 | ifneq (${TRUSTED_BOARD_BOOT},0) |
| 51 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 52 | AUTH_SOURCES := drivers/auth/auth_mod.c \ |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 53 | drivers/auth/img_parser_mod.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 54 | drivers/auth/tbbr/tbbr_cot_common.c |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 55 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 56 | BL1_SOURCES += ${AUTH_SOURCES} \ |
| 57 | bl1/tbbr/tbbr_img_desc.c \ |
| 58 | plat/common/tbbr/plat_tbbr.c \ |
Radoslaw Biernacki | 69d1d9c | 2018-05-17 22:19:11 +0200 | [diff] [blame] | 59 | ${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 60 | $(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S \ |
| 61 | drivers/auth/tbbr/tbbr_cot_bl1.c |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 62 | |
| 63 | BL2_SOURCES += ${AUTH_SOURCES} \ |
| 64 | plat/common/tbbr/plat_tbbr.c \ |
Radoslaw Biernacki | 69d1d9c | 2018-05-17 22:19:11 +0200 | [diff] [blame] | 65 | ${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c \ |
Manish V Badarkhe | 043fd62 | 2020-05-16 16:36:39 +0100 | [diff] [blame] | 66 | $(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S \ |
| 67 | drivers/auth/tbbr/tbbr_cot_bl2.c |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 68 | |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 69 | include drivers/auth/mbedtls/mbedtls_x509.mk |
| 70 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 71 | ROT_KEY = $(BUILD_PLAT)/rot_key.pem |
| 72 | ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin |
| 73 | |
| 74 | $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"')) |
| 75 | |
| 76 | $(BUILD_PLAT)/bl1/qemu_rotpk.o: $(ROTPK_HASH) |
| 77 | $(BUILD_PLAT)/bl2/qemu_rotpk.o: $(ROTPK_HASH) |
| 78 | |
| 79 | certificates: $(ROT_KEY) |
| 80 | |
Manish V Badarkhe | d8c877f | 2020-09-03 16:54:47 +0100 | [diff] [blame] | 81 | $(ROT_KEY): | $(BUILD_PLAT) |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 82 | @echo " OPENSSL $@" |
Salome Thirot | 0b35da3 | 2022-07-14 16:14:15 +0100 | [diff] [blame] | 83 | $(Q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 84 | |
| 85 | $(ROTPK_HASH): $(ROT_KEY) |
| 86 | @echo " OPENSSL $@" |
Salome Thirot | 0b35da3 | 2022-07-14 16:14:15 +0100 | [diff] [blame] | 87 | $(Q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\ |
| 88 | ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 89 | endif |
| 90 | |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 91 | # Include Measured Boot makefile before any Crypto library makefile. |
| 92 | # Crypto library makefile may need default definitions of Measured Boot build |
| 93 | # flags present in Measured Boot makefile. |
| 94 | ifeq (${MEASURED_BOOT},1) |
| 95 | MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk |
| 96 | $(info Including ${MEASURED_BOOT_MK}) |
| 97 | include ${MEASURED_BOOT_MK} |
| 98 | |
laurenw-arm | 7d2954b | 2022-06-16 13:36:52 -0500 | [diff] [blame] | 99 | ifneq (${MBOOT_EL_HASH_ALG}, sha256) |
| 100 | $(eval $(call add_define,TF_MBEDTLS_MBOOT_USE_SHA512)) |
| 101 | endif |
| 102 | |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 103 | BL2_SOURCES += plat/qemu/qemu/qemu_measured_boot.c \ |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 104 | plat/qemu/qemu/qemu_helpers.c \ |
| 105 | ${EVENT_LOG_SOURCES} |
| 106 | |
| 107 | BL1_SOURCES += plat/qemu/qemu/qemu_bl1_measured_boot.c |
| 108 | |
| 109 | endif |
| 110 | |
| 111 | ifneq ($(filter 1,${MEASURED_BOOT} ${TRUSTED_BOARD_BOOT}),) |
| 112 | CRYPTO_SOURCES := drivers/auth/crypto_mod.c |
| 113 | |
| 114 | BL1_SOURCES += ${CRYPTO_SOURCES} |
| 115 | BL2_SOURCES += ${CRYPTO_SOURCES} |
| 116 | |
| 117 | # We expect to locate the *.mk files under the directories specified below |
| 118 | # |
| 119 | include drivers/auth/mbedtls/mbedtls_crypto.mk |
| 120 | endif |
| 121 | |
Marcin Juszkiewicz | 424e3a8 | 2023-07-24 21:18:51 +0200 | [diff] [blame] | 122 | BL2_SOURCES += ${FDT_WRAPPERS_SOURCES} \ |
Jens Wiklander | a43c128 | 2022-11-22 14:39:26 +0100 | [diff] [blame] | 123 | common/uuid.c |
Jens Wiklander | 6335a97 | 2018-09-04 15:08:48 +0200 | [diff] [blame] | 124 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 125 | ifeq ($(add-lib-optee),yes) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 126 | BL2_SOURCES += lib/optee/optee_utils.c |
| 127 | endif |
| 128 | |
Sumit Garg | 4ac3034 | 2019-11-14 17:34:56 +0530 | [diff] [blame] | 129 | ifneq (${DECRYPTION_SUPPORT},none) |
| 130 | BL1_SOURCES += drivers/io/io_encrypted.c |
| 131 | BL2_SOURCES += drivers/io/io_encrypted.c |
| 132 | endif |
| 133 | |
Leif Lindholm | ded7d3d | 2021-03-10 15:00:50 +0000 | [diff] [blame] | 134 | # Include GICv2 driver files |
| 135 | include drivers/arm/gic/v2/gicv2.mk |
| 136 | QEMU_GICV2_SOURCES := ${GICV2_SOURCES} \ |
Hongbo Zhang | 32338ec | 2018-04-19 13:06:07 +0800 | [diff] [blame] | 137 | plat/common/plat_gicv2.c \ |
Radoslaw Biernacki | 69d1d9c | 2018-05-17 22:19:11 +0200 | [diff] [blame] | 138 | ${PLAT_QEMU_COMMON_PATH}/qemu_gicv2.c |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 139 | |
Alexei Fedorov | 84f1b5d | 2020-03-23 18:45:17 +0000 | [diff] [blame] | 140 | # Include GICv3 driver files |
| 141 | include drivers/arm/gic/v3/gicv3.mk |
| 142 | |
| 143 | QEMU_GICV3_SOURCES := ${GICV3_SOURCES} \ |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 144 | plat/common/plat_gicv3.c \ |
Radoslaw Biernacki | 69d1d9c | 2018-05-17 22:19:11 +0200 | [diff] [blame] | 145 | ${PLAT_QEMU_COMMON_PATH}/qemu_gicv3.c |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 146 | |
| 147 | ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV2) |
| 148 | QEMU_GIC_SOURCES := ${QEMU_GICV2_SOURCES} |
| 149 | else ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV3) |
| 150 | QEMU_GIC_SOURCES := ${QEMU_GICV3_SOURCES} |
| 151 | else |
| 152 | $(error "Incorrect GIC driver chosen for QEMU platform") |
| 153 | endif |
| 154 | |
Marcin Juszkiewicz | 61c9903 | 2023-07-24 21:37:00 +0200 | [diff] [blame] | 155 | ifeq (${ARCH},aarch64) |
| 156 | BL31_SOURCES += drivers/arm/pl061/pl061_gpio.c \ |
Maxim Uvarov | a0b85c2 | 2020-12-14 10:17:44 +0000 | [diff] [blame] | 157 | drivers/gpio/gpio.c \ |
Marcin Juszkiewicz | 61c9903 | 2023-07-24 21:37:00 +0200 | [diff] [blame] | 158 | ${PLAT_QEMU_COMMON_PATH}/qemu_pm.c \ |
| 159 | ${PLAT_QEMU_COMMON_PATH}/topology.c |
Jens Wiklander | ff263dc | 2021-05-25 18:15:11 +0200 | [diff] [blame] | 160 | |
Dongjiu Geng | a0de1d6 | 2023-04-04 19:24:11 +0800 | [diff] [blame] | 161 | ifeq (${SDEI_SUPPORT}, 1) |
| 162 | BL31_SOURCES += plat/qemu/common/qemu_sdei.c |
| 163 | endif |
| 164 | |
Jens Wiklander | ff263dc | 2021-05-25 18:15:11 +0200 | [diff] [blame] | 165 | ifeq (${SPD},spmd) |
Jens Wiklander | d4b84f0 | 2022-11-18 15:40:04 +0100 | [diff] [blame] | 166 | BL31_SOURCES += plat/common/plat_spmd_manifest.c \ |
| 167 | common/uuid.c \ |
| 168 | ${LIBFDT_SRCS} \ |
| 169 | ${FDT_WRAPPERS_SOURCES} |
Jens Wiklander | ff263dc | 2021-05-25 18:15:11 +0200 | [diff] [blame] | 170 | endif |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 171 | endif |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 172 | |
| 173 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 174 | # in the FIP if the platform requires. |
| 175 | ifneq ($(BL32_EXTRA1),) |
Sumit Garg | 4ac3034 | 2019-11-14 17:34:56 +0530 | [diff] [blame] | 176 | ifneq (${DECRYPTION_SUPPORT},none) |
| 177 | $(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1,,$(ENCRYPT_BL32))) |
| 178 | else |
Masahiro Yamada | 9c5ca52 | 2018-01-26 11:42:01 +0900 | [diff] [blame] | 179 | $(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 180 | endif |
Sumit Garg | 4ac3034 | 2019-11-14 17:34:56 +0530 | [diff] [blame] | 181 | endif |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 182 | ifneq ($(BL32_EXTRA2),) |
Sumit Garg | 4ac3034 | 2019-11-14 17:34:56 +0530 | [diff] [blame] | 183 | ifneq (${DECRYPTION_SUPPORT},none) |
| 184 | $(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2,,$(ENCRYPT_BL32))) |
| 185 | else |
Masahiro Yamada | 9c5ca52 | 2018-01-26 11:42:01 +0900 | [diff] [blame] | 186 | $(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 187 | endif |
Sumit Garg | 4ac3034 | 2019-11-14 17:34:56 +0530 | [diff] [blame] | 188 | endif |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 189 | |
Jens Wiklander | a43c128 | 2022-11-22 14:39:26 +0100 | [diff] [blame] | 190 | ifneq ($(QEMU_TB_FW_CONFIG_DTS),) |
| 191 | FDT_SOURCES += ${QEMU_TB_FW_CONFIG_DTS} |
| 192 | QEMU_TB_FW_CONFIG := ${BUILD_PLAT}/fdts/$(notdir $(basename ${QEMU_TB_FW_CONFIG_DTS})).dtb |
| 193 | # Add the TB_FW_CONFIG to FIP |
| 194 | $(eval $(call TOOL_ADD_PAYLOAD,${QEMU_TB_FW_CONFIG},--tb-fw-config,${QEMU_TB_FW_CONFIG})) |
| 195 | endif |
| 196 | |
Jens Wiklander | d4b84f0 | 2022-11-18 15:40:04 +0100 | [diff] [blame] | 197 | ifneq ($(QEMU_TOS_FW_CONFIG_DTS),) |
| 198 | FDT_SOURCES += ${QEMU_TOS_FW_CONFIG_DTS} |
| 199 | QEMU_TOS_FW_CONFIG := ${BUILD_PLAT}/fdts/$(notdir $(basename ${QEMU_TOS_FW_CONFIG_DTS})).dtb |
| 200 | # Add the TOS_FW_CONFIG to FIP |
| 201 | $(eval $(call TOOL_ADD_PAYLOAD,${QEMU_TOS_FW_CONFIG},--tos-fw-config,${QEMU_TOS_FW_CONFIG})) |
| 202 | endif |
| 203 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 204 | BL32_RAM_LOCATION := tdram |
| 205 | ifeq (${BL32_RAM_LOCATION}, tsram) |
| 206 | BL32_RAM_LOCATION_ID = SEC_SRAM_ID |
Jean-Philippe Brucker | 721b83d | 2023-09-07 18:13:07 +0100 | [diff] [blame] | 207 | ifeq (${ENABLE_RME},1) |
| 208 | # Avoid overlap between BL2 and BL32 to ease GPT partition |
| 209 | $(error "With RME, BL32 must use secure DRAM") |
| 210 | endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 211 | else ifeq (${BL32_RAM_LOCATION}, tdram) |
| 212 | BL32_RAM_LOCATION_ID = SEC_DRAM_ID |
| 213 | else |
| 214 | $(error "Unsupported BL32_RAM_LOCATION value") |
| 215 | endif |
| 216 | |
| 217 | # Process flags |
| 218 | $(eval $(call add_define,BL32_RAM_LOCATION_ID)) |
David Cunado | c5b0c0f | 2017-10-31 23:19:21 +0000 | [diff] [blame] | 219 | |
Andrew Walbran | 9c4d069 | 2020-01-15 14:11:31 +0000 | [diff] [blame] | 220 | # Don't have the Linux kernel as a BL33 image by default |
| 221 | ARM_LINUX_KERNEL_AS_BL33 := 0 |
| 222 | $(eval $(call assert_boolean,ARM_LINUX_KERNEL_AS_BL33)) |
| 223 | $(eval $(call add_define,ARM_LINUX_KERNEL_AS_BL33)) |
| 224 | |
| 225 | ARM_PRELOADED_DTB_BASE := PLAT_QEMU_DT_BASE |
| 226 | $(eval $(call add_define,ARM_PRELOADED_DTB_BASE)) |
| 227 | |
Andre Przywara | a3f6fd4 | 2022-10-04 13:56:19 +0100 | [diff] [blame] | 228 | qemu_fw.bios: bl1 fip |
| 229 | $(ECHO) " DD $@" |
| 230 | $(Q)cp ${BUILD_PLAT}/bl1.bin ${BUILD_PLAT}/$@ |
| 231 | $(Q)dd if=${BUILD_PLAT}/fip.bin of=${BUILD_PLAT}/$@ bs=64k seek=4 status=none |
| 232 | |
| 233 | qemu_fw.rom: qemu_fw.bios |
| 234 | $(ECHO) " DD $@" |
| 235 | $(Q)cp ${BUILD_PLAT}/$^ ${BUILD_PLAT}/$@ |
| 236 | $(Q)dd if=/dev/zero of=${BUILD_PLAT}/$@ bs=1M seek=64 count=0 status=none |
| 237 | |
| 238 | ifneq (${BL33},) |
| 239 | all: qemu_fw.bios qemu_fw.rom |
| 240 | endif |
Dongjiu Geng | a0de1d6 | 2023-04-04 19:24:11 +0800 | [diff] [blame] | 241 | |
| 242 | ifeq (${EL3_EXCEPTION_HANDLING},1) |
| 243 | BL31_SOURCES += plat/common/aarch64/plat_ehf.c |
| 244 | endif |