Skip to content

Commit 58d0b53

Browse files
authored
Merge pull request zephyrproject-rtos#101 from mswarowsky/tfm_20_upmerge
TF-M v2.0.0 upmerge
2 parents 33c0f47 + d94b1d8 commit 58d0b53

File tree

1,283 files changed

+165596
-35481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,283 files changed

+165596
-35481
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# Visual Studio Code
1010
.vscode/
1111

12+
# Local dependency repo
13+
localrepos.cmake
14+
1215
# Garbage files
1316
/build*/
1417
/cmake_build*/

.readthedocs.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# Copyright (c) 2023, Arm Limited. All rights reserved.
4+
#
5+
# SPDX-License-Identifier: BSD-3-Clause
6+
#
7+
#-------------------------------------------------------------------------------
8+
9+
# Read the Docs configuration file
10+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
11+
12+
# Version of the configuration file, v1 is no longer supported
13+
version: 2
14+
15+
# Configuration for the documentation build
16+
build:
17+
os: ubuntu-22.04
18+
tools:
19+
python: "3.11"
20+
apt_packages:
21+
- plantuml
22+
23+
# Build documentation in the "docs/" directory with Sphinx
24+
sphinx:
25+
configuration: docs/conf.py
26+
27+
# The documentation will also be built in a pdf format
28+
formats:
29+
- pdf
30+
- htmlzip
31+
32+
# Configuration of the Python environment
33+
python:
34+
install:
35+
- requirements: docs/requirements.txt

CMakeLists.txt

+13-16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ endif()
2121
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
2222
include(version)
2323
include(remote_library)
24+
include(utils)
25+
26+
if(EXISTS ${CMAKE_SOURCE_DIR}/localrepos.cmake)
27+
message(WARNING "Building using local repositories from \"" ${CMAKE_SOURCE_DIR}/localrepos.cmake "\"")
28+
include(${CMAKE_SOURCE_DIR}/localrepos.cmake)
29+
endif()
2430

2531
############################ CONFIGURATION #####################################
2632
include(config/pre_config.cmake)
@@ -36,31 +42,18 @@ include(config/post_config.cmake)
3642
############################### Compiler configuration #########################
3743

3844
include(${TFM_TOOLCHAIN_FILE})
39-
set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
45+
46+
set(CMAKE_C_COMPILER_FORCED true)
47+
set(CMAKE_CXX_COMPILER_FORCED true)
4048

4149
project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C CXX ASM)
4250
tfm_toolchain_reload_compiler()
4351

44-
# Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually
45-
# set then set both to the value of that, else set both to the value of
46-
# TFM_INSTALL_PATH. This has to be done after the call to `project()`.
47-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
48-
set(CMAKE_INSTALL_PREFIX ${TFM_INSTALL_PATH} CACHE PATH "" FORCE)
49-
else()
50-
set(TFM_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path to which to install TF-M files" FORCE)
51-
endif()
52-
5352
add_subdirectory(lib/ext)
5453
add_subdirectory(lib/fih)
5554
add_subdirectory(tools)
5655
add_subdirectory(secure_fw)
5756

58-
if(NS AND NS_EVALUATION_APP_PATH)
59-
add_subdirectory(${NS_EVALUATION_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/evaluation-app)
60-
elseif(NS OR TFM_S_REG_TEST OR TFM_NS_REG_TEST OR TEST_BL2 OR TEST_BL1_1 OR TEST_BL1_2)
61-
add_subdirectory(${TFM_TEST_REPO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
62-
endif()
63-
6457
add_subdirectory(interface)
6558
if(BL2)
6659
add_subdirectory(bl2)
@@ -77,6 +70,10 @@ if(CRYPTO_HW_ACCELERATOR)
7770
add_subdirectory(platform/ext/accelerator)
7871
endif()
7972

73+
if(IS_DIRECTORY ${CONFIG_TFM_TEST_DIR})
74+
add_subdirectory(${CONFIG_TFM_TEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
75+
endif()
76+
8077
############################ Config Check ######################################
8178

8279
include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)

Kconfig.misc

-23
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,8 @@ endmenu
7070

7171
################################# Manifest #####################################
7272

73-
menu "TF-M manifest"
74-
7573
config TFM_MANIFEST_LIST
7674
string "TF-M native Secure Partition manifests list file"
7775
default "$(TFM_SOURCE_DIR)/tools/tfm_manifest_list.yaml"
7876
help
7977
TF-M native Secure Partition manifests list file
80-
81-
config TFM_EXTRA_MANIFEST_LIST_FILES
82-
string "Extra manifest list file(s)"
83-
default ""
84-
help
85-
Used to list extra Secure Partition manifests.
86-
87-
config TFM_EXTRA_GENERATED_FILE_LIST_PATH
88-
string "Path to extra generated file list."
89-
default ""
90-
help
91-
Appended to stardard TFM generated file list
92-
93-
config TFM_EXTRA_PARTITION_PATHS
94-
string "List of extra Secure Partitions directories."
95-
default ""
96-
help
97-
An extra Secure Parition folder contains source code, CMakeLists.txt and
98-
manifest files
99-
100-
endmenu

bl1/Kconfig

+8
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,12 @@ config TFM_BL1_LOGGING
9696
bool "Enable BL1 Logging"
9797
default y
9898

99+
config BL1_2_BUILD_TYPE
100+
string "BL1_2 build type"
101+
default "$(CMAKE_BUILD_TYPE)"
102+
103+
config BL1_SHARED_SYMBOLS_PATH
104+
string "Path to list of symbols that BL1_1 that can be referenced from BL1_2"
105+
default "${TFM_SOURCE_DIR}/bl1/bl1_1/bl1_1_shared_symbols.txt"
106+
99107
endif

bl1/bl1_1/CMakeLists.txt

+30-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#-------------------------------------------------------------------------------
2-
# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
2+
# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
33
#
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
@@ -29,22 +29,24 @@ target_link_options(bl1_1
2929
target_sources(bl1_1
3030
PRIVATE
3131
main.c
32+
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
3233
)
3334

3435
target_link_libraries(bl1_1
3536
PRIVATE
3637
bl1_1_lib
3738
bl1_1_shared_lib
38-
platform_bl1
39+
platform_bl1_1
3940
$<$<BOOL:${TEST_BL1_1}>:bl1_1_tests>
4041
)
4142

4243
target_compile_definitions(bl1_1
4344
PRIVATE
4445
$<$<BOOL:${TEST_BL1_1}>:TEST_BL1_1>
46+
$<$<AND:$<BOOL:${CONFIG_TFM_BOOT_STORE_MEASUREMENTS}>,$<NOT:$<BOOL:${CONFIG_TFM_BOOT_STORE_ENCODED_MEASUREMENTS}>>>:TFM_MEASURED_BOOT_API>
4547
)
4648

47-
target_share_symbols(bl1_1 ${CMAKE_CURRENT_SOURCE_DIR}/bl1_1_shared_symbols.txt)
49+
target_share_symbols(bl1_1 ${BL1_SHARED_SYMBOLS_PATH})
4850

4951
################################################################################
5052

@@ -84,26 +86,28 @@ add_custom_command(OUTPUT bl1_2_padded.bin bl1_2_padded_hash.bin
8486

8587
################################################################################
8688

87-
add_custom_target(bl1_provisioning_bundle
88-
ALL
89-
SOURCES bl1_provisioning_bundle.bin
90-
)
91-
92-
add_custom_command(OUTPUT bl1_provisioning_bundle.bin
93-
DEPENDS ${TFM_BL2_ENCRYPTION_KEY_PATH}
94-
DEPENDS ${TFM_GUK_PATH}
95-
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
96-
DEPENDS $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin
97-
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
98-
bl1_2_padded_bin bl2_signed_bin
99-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
100-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
101-
--bl2_encryption_key_input_file ${TFM_BL2_ENCRYPTION_KEY_PATH}
102-
--bl2_signing_key_input_file ${TFM_BL2_SIGNING_KEY_PATH}
103-
--guk_input_file ${TFM_GUK_PATH}
104-
--bl1_2_padded_hash_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
105-
--bl2_signed_hash_input_file $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin
106-
--bl1_2_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
107-
--bundle_output_file bl1_provisioning_bundle.bin
108-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_provisioning_bundle.bin $<TARGET_FILE_DIR:bl1_1>
109-
)
89+
if (TFM_BL1_DEFAULT_PROVISIONING)
90+
add_custom_target(bl1_provisioning_bundle
91+
ALL
92+
SOURCES bl1_provisioning_bundle.bin
93+
)
94+
95+
add_custom_command(OUTPUT bl1_provisioning_bundle.bin
96+
DEPENDS ${TFM_BL2_ENCRYPTION_KEY_PATH}
97+
DEPENDS ${TFM_GUK_PATH}
98+
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
99+
DEPENDS $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin
100+
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
101+
bl1_2_padded_bin bl2_signed_bin
102+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
103+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
104+
--bl2_encryption_key_input_file ${TFM_BL2_ENCRYPTION_KEY_PATH}
105+
--bl2_signing_key_input_file ${TFM_BL2_SIGNING_KEY_PATH}
106+
--guk_input_file ${TFM_GUK_PATH}
107+
--bl1_2_padded_hash_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
108+
--bl2_signed_hash_input_file $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin
109+
--bl1_2_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
110+
--bundle_output_file bl1_provisioning_bundle.bin
111+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_provisioning_bundle.bin $<TARGET_FILE_DIR:bl1_1>
112+
)
113+
endif()

bl1/bl1_1/bl1_1_shared_symbols.txt

+15-37
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
1-
bl1_sha256_compute
2-
bl1_sha256_init
3-
bl1_sha256_update
4-
bl1_sha256_finish
5-
1+
Driver_FLASH0
2+
SystemInit
63
bl1_aes_256_ctr_decrypt
74
bl1_derive_key
8-
bl1_otp_read_nv_counter
9-
bl1_otp_write_nv_counter
10-
bl1_otp_read_bl2_image_hash
115
bl1_otp_read_key
12-
bl1_otp_read
13-
mbedtls_init
14-
crypto_hw_accelerator_init
15-
crypto_hw_accelerator_finish
16-
fih_delay_init
17-
fih_delay_finish
18-
bl_secure_memeql
19-
bl_secure_memcpy
20-
21-
fih_delay_random_uchar
22-
_fih_cfi_ctr
23-
FIH_FAILURE
24-
FIH_SUCCESS
25-
_fih_mask
26-
fih_cfi_decrement
27-
fih_cfi_get_and_increment
28-
fih_cfi_validate
29-
fih_panic_loop
30-
31-
SystemInit
32-
boot_platform_init
33-
boot_platform_post_init
34-
boot_platform_quit
35-
bl1_image_get_flash_offset
6+
bl1_sha256_compute
7+
bl1_sha256_finish
8+
bl1_sha256_init
9+
bl1_sha256_update
10+
bl1_trng_generate_random
11+
computed_bl1_2_hash
12+
pq_crypto_verify
13+
stdio_init
3614
stdio_output_string
37-
Driver_FLASH0
38-
platform_code_is_bl1_2
39-
40-
run_testsuite
41-
tfm_log_printf
15+
stdio_uninit
16+
tfm_plat_init_nv_counter
17+
tfm_plat_otp_read
18+
tfm_plat_read_nv_counter
19+
tfm_plat_set_nv_counter

bl1/bl1_1/lib/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#-------------------------------------------------------------------------------
2-
# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
2+
# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
33
#
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
@@ -22,5 +22,5 @@ target_include_directories(bl1_1_lib
2222
target_link_libraries(bl1_1_lib
2323
INTERFACE
2424
bl1_1_shared_lib
25-
platform_bl1
25+
platform_bl1_1
2626
)

bl1/bl1_1/lib/image_otp.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2022-2023, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -14,9 +14,16 @@ fih_int bl1_read_bl1_2_image(uint8_t *image)
1414
{
1515
fih_int fih_rc;
1616
enum tfm_plat_err_t plat_err;
17+
uint32_t bl1_2_len;
1718

18-
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_BL1_2_IMAGE, BL1_2_CODE_SIZE,
19-
image);
19+
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_BL1_2_IMAGE_LEN, sizeof(bl1_2_len),
20+
(uint8_t *)&bl1_2_len);
21+
fih_rc = fih_int_encode_zero_equality(plat_err);
22+
if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
23+
FIH_RET(fih_rc);
24+
}
25+
26+
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_BL1_2_IMAGE, bl1_2_len, image);
2027
fih_rc = fih_int_encode_zero_equality(plat_err);
2128

2229
FIH_RET(fih_rc);

0 commit comments

Comments
 (0)