Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
David Hu | fb4a8b7 | 2022-01-13 16:46:02 +0800 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Chris Brand | 636ab48 | 2022-05-19 15:55:37 -0700 | [diff] [blame] | 3 | # Copyright (c) 2021-2022 Cypress Semiconductor Corporation (an Infineon company) |
| 4 | # or an affiliate of Cypress Semiconductor Corporation. All rights reserved. |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: BSD-3-Clause |
| 7 | # |
| 8 | #------------------------------------------------------------------------------- |
| 9 | |
| 10 | function(tfm_invalid_config) |
| 11 | if (${ARGV}) |
| 12 | string (REPLACE ";" " " ARGV_STRING "${ARGV}") |
Minos Galanakis | f216e2b | 2020-11-09 17:12:01 +0000 | [diff] [blame] | 13 | string (REPLACE "STREQUAL" "=" ARGV_STRING "${ARGV_STRING}") |
| 14 | string (REPLACE "GREATER" ">" ARGV_STRING "${ARGV_STRING}") |
| 15 | string (REPLACE "LESS" "<" ARGV_STRING "${ARGV_STRING}") |
| 16 | string (REPLACE "VERSION_LESS" "<" ARGV_STRING "${ARGV_STRING}") |
| 17 | string (REPLACE "EQUAL" "=" ARGV_STRING "${ARGV_STRING}") |
| 18 | string (REPLACE "IN_LIST" "in" ARGV_STRING "${ARGV_STRING}") |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 19 | |
| 20 | message(FATAL_ERROR "INVALID CONFIG: ${ARGV_STRING}") |
| 21 | endif() |
| 22 | endfunction() |
| 23 | |
Kevin Peng | 386374c | 2021-11-04 14:36:17 +0800 | [diff] [blame] | 24 | set (VALID_ISOLATION_LEVELS 1 2 3) |
Mingyang Sun | c9d2471 | 2020-10-23 15:06:34 +0800 | [diff] [blame] | 25 | |
Kevin Peng | 386374c | 2021-11-04 14:36:17 +0800 | [diff] [blame] | 26 | tfm_invalid_config(NOT TFM_ISOLATION_LEVEL IN_LIST VALID_ISOLATION_LEVELS) |
Roman Mazurak | ff8e507 | 2022-09-14 00:08:48 +0300 | [diff] [blame] | 27 | tfm_invalid_config(TFM_ISOLATION_LEVEL EQUAL 3 AND NOT PLATFORM_HAS_ISOLATION_L3_SUPPORT) |
Kevin Peng | 386374c | 2021-11-04 14:36:17 +0800 | [diff] [blame] | 28 | tfm_invalid_config(TFM_ISOLATION_LEVEL GREATER 1 AND PSA_FRAMEWORK_HAS_MM_IOVEC) |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 29 | |
Chris Brand | 56b4d0c | 2021-12-17 16:15:58 -0800 | [diff] [blame] | 30 | tfm_invalid_config(TFM_MULTI_CORE_TOPOLOGY AND TFM_NS_MANAGE_NSID) |
Mark Horvath | dadc1ea | 2021-03-12 15:39:25 +0100 | [diff] [blame] | 31 | tfm_invalid_config(TFM_PLAT_SPECIFIC_MULTI_CORE_COMM AND NOT TFM_MULTI_CORE_TOPOLOGY) |
David Hu | 372b45c | 2022-11-16 10:06:28 +0800 | [diff] [blame^] | 32 | # Multi-core platform with mailbox partition cannot fully work with SFN backend yet. |
| 33 | tfm_invalid_config(TFM_PARTITION_NS_AGENT_MAILBOX AND CONFIG_TFM_SPM_BACKEND_SFN) |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 34 | |
Chris Brand | 30106ba | 2022-01-13 13:48:50 -0800 | [diff] [blame] | 35 | tfm_invalid_config(TFM_ISOLATION_LEVEL EQUAL 3 AND CONFIG_TFM_STACK_WATERMARKS) |
| 36 | |
David Hu | 12f2587 | 2021-08-23 14:55:46 +0800 | [diff] [blame] | 37 | tfm_invalid_config((TFM_S_REG_TEST OR TFM_NS_REG_TEST) AND TEST_PSA_API) |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 38 | |
Øyvind Rønningstad | 7200471 | 2021-03-11 15:55:28 +0100 | [diff] [blame] | 39 | tfm_invalid_config(SUITE STREQUAL "IPC" AND NOT TEST_PSA_API STREQUAL "IPC") |
| 40 | |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 41 | tfm_invalid_config(TEST_PSA_API STREQUAL "CRYPTO" AND NOT TFM_PARTITION_CRYPTO) |
| 42 | tfm_invalid_config(TEST_PSA_API STREQUAL "INITIAL_ATTESTATION" AND NOT TFM_PARTITION_INITIAL_ATTESTATION) |
| 43 | tfm_invalid_config(TEST_PSA_API STREQUAL "INTERNAL_TRUSTED_STORAGE" AND NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) |
| 44 | tfm_invalid_config(TEST_PSA_API STREQUAL "PROTECTED_STORAGE" AND NOT TFM_PARTITION_PROTECTED_STORAGE) |
| 45 | tfm_invalid_config(TEST_PSA_API STREQUAL "STORAGE" AND NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) |
| 46 | tfm_invalid_config(TEST_PSA_API STREQUAL "STORAGE" AND NOT TFM_PARTITION_PROTECTED_STORAGE) |
| 47 | |
David Vincze | 8608bdb | 2022-02-11 12:04:54 +0100 | [diff] [blame] | 48 | ########################## BL1 ################################################# |
| 49 | |
| 50 | tfm_invalid_config((BL1 AND PLATFORM_DEFAULT_BL1 AND CONFIG_TFM_BOOT_STORE_MEASUREMENTS) AND NOT TFM_PARTITION_MEASURED_BOOT) |
| 51 | |
David Vincze | 0c515de | 2020-11-25 19:02:57 +0100 | [diff] [blame] | 52 | ########################## BL2 ################################################# |
| 53 | |
| 54 | get_property(MCUBOOT_STRATEGY_LIST CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS) |
shejia01 | 8444011 | 2021-07-07 10:49:09 +0800 | [diff] [blame] | 55 | tfm_invalid_config(BL2 AND (NOT MCUBOOT_UPGRADE_STRATEGY IN_LIST MCUBOOT_STRATEGY_LIST)) |
David Vincze | 0c515de | 2020-11-25 19:02:57 +0100 | [diff] [blame] | 56 | |
Tintu Thomas | eab1b47 | 2022-03-21 14:27:58 +0000 | [diff] [blame] | 57 | # Maximum number of MCUBoot images supported by TF-M NV counters and ROTPKs |
| 58 | tfm_invalid_config(MCUBOOT_IMAGE_NUMBER GREATER 4) |
Raef Coles | 91fadb9 | 2021-06-18 09:20:50 +0100 | [diff] [blame] | 59 | |
David Vincze | 8c95d2a | 2022-01-19 10:11:58 +0100 | [diff] [blame] | 60 | tfm_invalid_config((BL2 AND CONFIG_TFM_BOOT_STORE_MEASUREMENTS AND NOT CONFIG_TFM_BOOT_STORE_ENCODED_MEASUREMENTS) AND NOT MCUBOOT_DATA_SHARING) |
David Vincze | 8608bdb | 2022-02-11 12:04:54 +0100 | [diff] [blame] | 61 | tfm_invalid_config((NOT (TFM_PARTITION_FIRMWARE_UPDATE OR CONFIG_TFM_BOOT_STORE_MEASUREMENTS)) AND MCUBOOT_DATA_SHARING) |
David Vincze | 8c95d2a | 2022-01-19 10:11:58 +0100 | [diff] [blame] | 62 | |
Michel Jaouen | 24c3dd0 | 2021-08-12 15:32:13 +0200 | [diff] [blame] | 63 | get_property(MCUBOOT_ALIGN_VAL_LIST CACHE MCUBOOT_ALIGN_VAL PROPERTY STRINGS) |
| 64 | tfm_invalid_config(BL2 AND (NOT MCUBOOT_ALIGN_VAL IN_LIST MCUBOOT_ALIGN_VAL_LIST)) |
| 65 | |
Tamas Ban | 3a7cb3c | 2020-11-25 15:45:04 +0000 | [diff] [blame] | 66 | ####################### Code sharing ########################################### |
| 67 | |
Mark Horvath | c97eb92 | 2022-09-12 11:17:37 +0200 | [diff] [blame] | 68 | set(TFM_CODE_SHARING_PLATFORM_LISTS arm/mps2/an521 arm/musca_b1) # Without crypto hw acceleration |
Tamas Ban | 3a7cb3c | 2020-11-25 15:45:04 +0000 | [diff] [blame] | 69 | tfm_invalid_config(NOT TFM_CODE_SHARING STREQUAL "OFF" AND NOT TFM_PLATFORM IN_LIST TFM_CODE_SHARING_PLATFORM_LISTS) |
| 70 | tfm_invalid_config(NOT TFM_CODE_SHARING STREQUAL "OFF" AND CRYPTO_HW_ACCELERATOR) |
Dávid Házi | 302f81d | 2022-10-17 20:42:44 +0200 | [diff] [blame] | 71 | tfm_invalid_config(NOT TFM_CODE_SHARING STREQUAL "OFF" AND NOT C_COMPILER_ID:IAR) |
Summer Qin | 2cd2ab7 | 2020-04-22 14:55:00 +0800 | [diff] [blame] | 72 | |
Raef Coles | 148b947 | 2021-06-18 08:48:17 +0100 | [diff] [blame] | 73 | ########################## Platform ############################################ |
| 74 | |
| 75 | tfm_invalid_config(OTP_NV_COUNTERS_RAM_EMULATION AND NOT (PLATFORM_DEFAULT_OTP OR PLATFORM_DEFAULT_NV_COUNTERS)) |
Michel Jaouen | d0fd8d9 | 2021-10-14 09:22:41 +0200 | [diff] [blame] | 76 | tfm_invalid_config(PLATFORM_DEFAULT_NV_COUNTERS AND NOT PLATFORM_DEFAULT_OTP_WRITEABLE) |
Sebastian Bøe | 7ad5d85 | 2022-11-03 13:51:21 +0100 | [diff] [blame] | 77 | tfm_invalid_config(TFM_DUMMY_PROVISIONING AND (PLATFORM_DEFAULT_OTP AND NOT PLATFORM_DEFAULT_OTP_WRITEABLE)) |
Raef Coles | 249aba9 | 2022-06-16 10:20:29 +0100 | [diff] [blame] | 78 | tfm_invalid_config(TFM_NS_NV_COUNTER_AMOUNT GREATER 3) |
Raef Coles | 148b947 | 2021-06-18 08:48:17 +0100 | [diff] [blame] | 79 | |
Sherry Zhang | 07b4241 | 2021-01-07 14:19:41 +0800 | [diff] [blame] | 80 | ####################### Firmware Update Parttion ############################### |
| 81 | |
David Hu | 79bb75c | 2022-08-02 18:04:51 +0800 | [diff] [blame] | 82 | tfm_invalid_config(NOT PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT AND TFM_PARTITION_FIRMWARE_UPDATE) |
Sherry Zhang | 07b4241 | 2021-01-07 14:19:41 +0800 | [diff] [blame] | 83 | tfm_invalid_config(TFM_PARTITION_FIRMWARE_UPDATE AND NOT TFM_PARTITION_PLATFORM) |
| 84 | tfm_invalid_config((MCUBOOT_UPGRADE_STRATEGY STREQUAL "DIRECT_XIP" OR MCUBOOT_UPGRADE_STRATEGY STREQUAL "RAM_LOAD") AND TFM_PARTITION_FIRMWARE_UPDATE) |
| 85 | tfm_invalid_config(TFM_PARTITION_FIRMWARE_UPDATE AND NOT MCUBOOT_DATA_SHARING) |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 86 | |
Chris Brand | 636ab48 | 2022-05-19 15:55:37 -0700 | [diff] [blame] | 87 | ####################### Protected Storage Parttion ############################### |
| 88 | |
| 89 | tfm_invalid_config(TFM_PARTITION_PROTECTED_STORAGE AND NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) |
Chris Brand | 9ea9ac7 | 2022-06-27 09:01:21 -0700 | [diff] [blame] | 90 | # PS only uses the platform partition when PS_ROLLBACK_PROTECTION is ON, but |
David Vincze | a6f501e | 2021-06-14 10:42:30 +0200 | [diff] [blame] | 91 | # the dependency in the manifest file means the dependency is unconditional |
Chris Brand | 9ea9ac7 | 2022-06-27 09:01:21 -0700 | [diff] [blame] | 92 | tfm_invalid_config(TFM_PARTITION_PROTECTED_STORAGE AND NOT TFM_PARTITION_PLATFORM) |
Joakim Andersson | 760ce61 | 2021-12-30 15:06:19 +0100 | [diff] [blame] | 93 | tfm_invalid_config(PS_ROLLBACK_PROTECTION AND TFM_PLATFORM_NV_COUNTER_MODULE_DISABLED) |
Chris Brand | 636ab48 | 2022-05-19 15:55:37 -0700 | [diff] [blame] | 94 | tfm_invalid_config(PS_ROLLBACK_PROTECTION AND NOT PS_ENCRYPTION) |
Sherry Zhang | bcb1aa3 | 2022-09-21 13:23:05 +0800 | [diff] [blame] | 95 | tfm_invalid_config(PS_ENCRYPTION AND (PS_CRYPTO_AEAD_ALG STREQUAL "PSA_ALG_GCM" OR PS_CRYPTO_AEAD_ALG STREQUAL "PSA_ALG_CCM") AND NOT PS_ROLLBACK_PROTECTION) |
Chris Brand | 636ab48 | 2022-05-19 15:55:37 -0700 | [diff] [blame] | 96 | |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 97 | ########################## FIH ################################################# |
| 98 | |
| 99 | get_property(TFM_FIH_PROFILE_LIST CACHE TFM_FIH_PROFILE PROPERTY STRINGS) |
| 100 | tfm_invalid_config(NOT TFM_FIH_PROFILE IN_LIST TFM_FIH_PROFILE_LIST) |
David Hu | e056d18 | 2021-03-29 15:14:01 +0800 | [diff] [blame] | 101 | |
Joakim Andersson | 7f572ff | 2022-08-09 16:50:36 +0200 | [diff] [blame] | 102 | ########################### TF-M initial attestation ##################################### |
| 103 | |
| 104 | tfm_invalid_config(ATTEST_INCLUDE_TEST_CODE AND NOT (TEST_NS_ATTESTATION OR TEST_S_ATTESTATION)) |
| 105 | |
Summer Qin | 9347dc7 | 2021-07-12 18:57:57 +0800 | [diff] [blame] | 106 | ########################### TF-M crypto ######################################## |
| 107 | |
Anton Komlev | 1416f15 | 2022-10-25 15:19:42 +0100 | [diff] [blame] | 108 | if (${TFM_PARTITION_CRYPTO}) |
| 109 | tfm_invalid_config(CRYPTO_NV_SEED AND CRYPTO_HW_ACCELERATOR) |
| 110 | tfm_invalid_config(NOT CRYPTO_NV_SEED AND NOT CRYPTO_HW_ACCELERATOR) |
| 111 | endif() |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 112 | |
Chris Brand | 636ab48 | 2022-05-19 15:55:37 -0700 | [diff] [blame] | 113 | ######################## TF-M Profile config check ############################# |
David Hu | 1feb4b1 | 2022-02-23 17:22:07 +0800 | [diff] [blame] | 114 | |
| 115 | tfm_invalid_config(TFM_PROFILE STREQUAL "profile_small" AND CONFIG_TFM_SPM_BACKEND_IPC) |
| 116 | |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 117 | ########################### Test check config ################################## |
| 118 | |
David Hu | 12f2587 | 2021-08-23 14:55:46 +0800 | [diff] [blame] | 119 | if(TFM_S_REG_TEST OR TFM_NS_REG_TEST) |
David Hu | 3d2121f | 2021-08-23 18:00:26 +0800 | [diff] [blame] | 120 | include(${TFM_TEST_PATH}/config/check_config.cmake) |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 121 | endif() |
Feder Liang | 5519438 | 2021-11-22 16:45:33 +0800 | [diff] [blame] | 122 | |
| 123 | ###################### Compiler check for FP support ########################### |
| 124 | |
| 125 | include(config/cp_check.cmake) |
Chris Brand | 9edf081 | 2022-07-05 14:18:42 -0700 | [diff] [blame] | 126 | |
| 127 | ###################### Platform-specific checks ################################ |
| 128 | |
| 129 | if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 130 | include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 131 | endif() |