Skip to content

Commit a8313be

Browse files
joerchantamasban
authored andcommitted
Boot: Align MCUboot to the latest version
Conflict note: bl2/ext/mcuboot/bl2_main.c: Trivial conflict with commit: 7763a47 lib/ext/tf-m-tests/repo_config_default.cmake: Ignored change to TFM_TEST_REPO_VERSION, since we supply our own through zephyrs main manifest file. Change to tf-m-tests repository appears to not be needed in zephyr. Signed-off-by: Sherry Zhang <[email protected]> Co-authored-by: Tamas Ban <[email protected]> Change-Id: I256ab23d330bd45a93ff33f0cd93e45822c0ed2f (cherry picked from commit 8faae45) Signed-off-by: Joakim Andersson <[email protected]>
1 parent f2a639c commit a8313be

File tree

7 files changed

+34
-28
lines changed

7 files changed

+34
-28
lines changed

bl2/ext/mcuboot/bl2_main.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2012-2014 Wind River Systems, Inc.
3-
* Copyright (c) 2017-2022 Arm Limited.
3+
* Copyright (c) 2017-2023 Arm Limited.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -89,7 +89,7 @@ static void do_boot(struct boot_rsp *rsp)
8989
int main(void)
9090
{
9191
struct boot_rsp rsp;
92-
fih_int fih_rc = FIH_FAILURE;
92+
fih_ret fih_rc = FIH_FAILURE;
9393
enum tfm_plat_err_t plat_err;
9494
int32_t image_id;
9595

@@ -127,7 +127,7 @@ int main(void)
127127
}
128128

129129
FIH_CALL(boot_nv_security_counter_init, fih_rc);
130-
if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
130+
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
131131
BOOT_LOG_ERR("Error while initializing the security counter");
132132
FIH_PANIC;
133133
}
@@ -151,8 +151,13 @@ int main(void)
151151
FIH_PANIC;
152152
}
153153

154+
/* Primary goal to zeroize the 'rsp' is to avoid to accidentally load
155+
* the NS image in case of a fault injection attack. However, it is
156+
* done anyway as a good practice to sanitize memory.
157+
*/
158+
memset(&rsp, 0, sizeof(struct boot_rsp));
154159
FIH_CALL(boot_go_for_image_id, fih_rc, &rsp, image_id);
155-
if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
160+
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
156161
BOOT_LOG_ERR("Unable to find bootable image");
157162
FIH_PANIC;
158163
}

bl2/ext/mcuboot/include/fih.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2023, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -20,11 +20,11 @@ extern "C" {
2020
#include "stdint.h"
2121

2222
/*
23-
* FIH return type macro changes the function return types to fih_int.
23+
* FIH return type macro changes the function return types to fih_ret.
2424
* All functions that need to be protected by FIH and called via FIH_CALL must
25-
* return a fih_int type.
25+
* return a fih_ret type.
2626
*/
27-
#define FIH_RET_TYPE(type) fih_int
27+
#define FIH_RET_TYPE(type) fih_ret
2828

2929
#include "bootutil/fault_injection_hardening.h"
3030

bl2/src/security_cnt.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2019-2023, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -36,19 +36,19 @@ static enum tfm_nv_counter_t get_nv_counter_from_image_id(uint32_t image_id)
3636
return (enum tfm_nv_counter_t)nv_counter;
3737
}
3838

39-
fih_int boot_nv_security_counter_init(void)
39+
fih_ret boot_nv_security_counter_init(void)
4040
{
41-
fih_int fih_rc = FIH_FAILURE;
41+
FIH_DECLARE(fih_rc, FIH_FAILURE);
4242

43-
fih_rc = fih_int_encode_zero_equality(tfm_plat_init_nv_counter());
43+
fih_rc = fih_ret_encode_zero_equality(tfm_plat_init_nv_counter());
4444

4545
FIH_RET(fih_rc);
4646
}
4747

48-
fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
48+
fih_ret boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
4949
{
5050
enum tfm_nv_counter_t nv_counter;
51-
fih_int fih_rc = FIH_FAILURE;
51+
FIH_DECLARE(fih_rc, FIH_FAILURE);
5252
uint32_t security_cnt_soft;
5353

5454
/* Check if it's a null-pointer. */
@@ -61,7 +61,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
6161
FIH_RET(FIH_FAILURE);
6262
}
6363

64-
fih_rc = fih_int_encode_zero_equality(
64+
fih_rc = fih_ret_encode_zero_equality(
6565
tfm_plat_read_nv_counter(nv_counter,
6666
sizeof(security_cnt_soft),
6767
(uint8_t *)&security_cnt_soft));

config/config_base.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ set(TFM_MBEDCRYPTO_PSA_CRYPTO_CONFIG_PATH "${CMAKE_SOURCE_DIR}/lib/ext/mbedcry
135135
set(TFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH "" CACHE PATH "Config to append to standard Mbed Crypto config, used by platforms to cnfigure feature support")
136136

137137
set(MCUBOOT_PATH "DOWNLOAD" CACHE PATH "Path to MCUboot (or DOWNLOAD to fetch automatically")
138-
set(MCUBOOT_VERSION "v1.9.0" CACHE STRING "The version of MCUboot to use")
138+
set(MCUBOOT_VERSION "7453075" CACHE STRING "The version of MCUboot to use")
139139

140140
set(PSA_ARCH_TESTS_PATH "DOWNLOAD" CACHE PATH "Path to PSA arch tests (or DOWNLOAD to fetch automatically")
141141
set(PSA_ARCH_TESTS_VERSION "cf8bd71" CACHE STRING "The version of PSA arch tests to use")

platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ target_sources(bl1_main
159159
PRIVATE
160160
${MCUBOOT_PATH}/boot/bootutil/src/loader.c
161161
${MCUBOOT_PATH}/boot/bootutil/src/bootutil_misc.c
162+
${MCUBOOT_PATH}/boot/bootutil/src/bootutil_public.c
162163
${MCUBOOT_PATH}/boot/bootutil/src/image_validate.c
163164
${MCUBOOT_PATH}/boot/bootutil/src/image_rsa.c
164165
${MCUBOOT_PATH}/boot/bootutil/src/tlv.c

platform/ext/target/arm/corstone1000/bl1/bl1_security_cnt.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
#include "tfm_plat_provisioning.h"
1414
#include "fwu_agent.h"
1515

16-
fih_int boot_nv_security_counter_init(void)
16+
fih_ret boot_nv_security_counter_init(void)
1717
{
18-
fih_int fih_rc = FIH_FAILURE;
18+
FIH_DECLARE(fih_rc, FIH_FAILURE);
1919

20-
fih_rc = fih_int_encode_zero_equality(tfm_plat_init_nv_counter());
20+
fih_rc = fih_ret_encode_zero_equality(tfm_plat_init_nv_counter());
2121

2222
FIH_RET(fih_rc);
2323
}
2424

25-
fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
25+
fih_ret boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
2626
{
27-
fih_int fih_rc = FIH_FAILURE;
27+
FIH_DECLARE(fih_rc, FIH_FAILURE);
2828
uint32_t security_cnt_soft;
2929

3030
/* Check if it's a null-pointer. */
@@ -36,7 +36,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
3636
FIH_RET(FIH_FAILURE);
3737
}
3838

39-
fih_rc = fih_int_encode_zero_equality(
39+
fih_rc = fih_ret_encode_zero_equality(
4040
tfm_plat_read_nv_counter(PLAT_NV_COUNTER_BL1_0,
4141
sizeof(security_cnt_soft),
4242
(uint8_t *)&security_cnt_soft));

platform/ext/target/arm/corstone1000/bl2_security_cnt.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ static enum tfm_nv_counter_t get_nv_counter_from_image_id(uint32_t image_id)
3737
return (enum tfm_nv_counter_t)nv_counter;
3838
}
3939

40-
fih_int boot_nv_security_counter_init(void)
40+
fih_ret boot_nv_security_counter_init(void)
4141
{
42-
fih_int fih_rc = FIH_FAILURE;
42+
FIH_DECLARE(fih_rc, FIH_FAILURE);
4343

44-
fih_rc = fih_int_encode_zero_equality(tfm_plat_init_nv_counter());
44+
fih_rc = fih_ret_encode_zero_equality(tfm_plat_init_nv_counter());
4545

4646
FIH_RET(fih_rc);
4747
}
4848

49-
fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
49+
fih_ret boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
5050
{
5151
enum tfm_nv_counter_t nv_counter;
52-
fih_int fih_rc = FIH_FAILURE;
52+
FIH_DECLARE(fih_rc, FIH_FAILURE);
5353
uint32_t security_cnt_soft;
5454

5555
/* Check if it's a null-pointer. */
@@ -62,7 +62,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
6262
FIH_RET(FIH_FAILURE);
6363
}
6464

65-
fih_rc = fih_int_encode_zero_equality(
65+
fih_rc = fih_ret_encode_zero_equality(
6666
tfm_plat_read_nv_counter(nv_counter,
6767
sizeof(security_cnt_soft),
6868
(uint8_t *)&security_cnt_soft));

0 commit comments

Comments
 (0)