Skip to content

Commit b0fe59d

Browse files
committed
[trusted-firmware-m]: Updated to e7efdc6
1 parent 2b354a4 commit b0fe59d

35 files changed

+1904
-1322
lines changed

components/TARGET_PSA/TARGET_TFM/COMPONENT_NSPE/interface/src/tfm_ns_lock_rtx.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77
#include <stdint.h>
88
#include <stdbool.h>
9-
#include "cmsis.h"
10-
#include "rtx_os.h"
9+
1110
#include "cmsis_os2.h"
11+
1212
#include "tfm_api.h"
1313
#include "tfm_ns_lock.h"
1414

@@ -29,14 +29,11 @@ static struct ns_lock_state ns_lock = {.init=false, .id=NULL};
2929
/**
3030
* \brief Mutex properties, NS lock
3131
*/
32-
33-
static osRtxMutex_t ns_lock_cb = { 0 };
34-
3532
static const osMutexAttr_t ns_lock_attrib = {
3633
.name = "ns_lock",
3734
.attr_bits = osMutexPrioInherit,
38-
.cb_mem = &ns_lock_cb,
39-
.cb_size = sizeof(ns_lock_cb)
35+
.cb_mem = NULL,
36+
.cb_size = 0U
4037
};
4138

4239
/**
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef __BOOT_RECORD_H__
9+
#define __BOOT_RECORD_H__
10+
11+
#include <stdint.h>
12+
#include <stddef.h>
13+
#include <limits.h>
14+
#include "../ext/mcuboot/bootutil/include/bootutil/image.h"
15+
#include "../ext/mcuboot/include/flash_map/flash_map.h"
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
/*!
22+
* \enum shared_data_err_t
23+
*
24+
* \brief Return values for adding data entry to shared memory area
25+
*/
26+
enum shared_memory_err_t {
27+
SHARED_MEMORY_OK = 0,
28+
SHARED_MEMORY_OVERFLOW = 1,
29+
SHARED_MEMORY_OVERWRITE = 2,
30+
31+
/* This is used to force the maximum size */
32+
TLV_TYPE_MAX = INT_MAX
33+
};
34+
35+
/*!
36+
* \enum boot_status_err_t
37+
*
38+
* \brief Return values for saving boot status information to shared memory are
39+
*/
40+
enum boot_status_err_t {
41+
BOOT_STATUS_OK,
42+
BOOT_STATUS_ERROR,
43+
};
44+
45+
/*!
46+
* \brief Add a data item to the shared data area between bootloader and
47+
* runtime SW
48+
*
49+
* \param[in] major_type TLV major type, identify consumer
50+
* \param[in] minor_type TLV minor type, identify TLV type
51+
* \param[in] size length of added data
52+
* \param[in] data pointer to data
53+
*
54+
* \return Returns error code as specified in \ref shared_memory_err_t
55+
*/
56+
enum shared_memory_err_t
57+
boot_add_data_to_shared_area(uint8_t major_type,
58+
uint16_t minor_type,
59+
size_t size,
60+
const uint8_t *data);
61+
62+
/*!
63+
* \brief Add an image's all boot status information to the shared data area
64+
* between bootloader and runtime SW
65+
*
66+
* \param[in] sw_module Identifier of the SW component
67+
* \param[in] hdr Pointer to the image header stored in RAM
68+
* \param[in] fap Pointer to the flash area where image is stored
69+
*
70+
* \return Returns error code as specified in \ref boot_status_err_t
71+
*/
72+
enum boot_status_err_t
73+
boot_save_boot_status(uint8_t sw_module,
74+
const struct image_header *hdr,
75+
const struct flash_area *fap);
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
81+
#endif /* __BOOT_RECORD_H__ */

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/platform/include/tfm_spm_hal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Arm Limited. All rights reserved.
2+
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -28,7 +28,7 @@
2828
*/
2929
struct tfm_spm_partition_platform_data_t;
3030

31-
#if TFM_LVL != 1
31+
#if defined (TFM_PSA_API) || (TFM_LVL != 1)
3232
/**
3333
* \brief Holds SPM db fields that define the memory regions used by a
3434
* partition.
@@ -147,7 +147,7 @@ uint32_t tfm_spm_hal_get_ns_MSP(void);
147147
uint32_t tfm_spm_hal_get_ns_entry_point(void);
148148

149149

150-
#if TFM_LVL != 1
150+
#if (TFM_LVL != 1) && !defined(TFM_PSA_API)
151151
/**
152152
* \brief Configure the sandbox for a partition.
153153
*
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
#-------------------------------------------------------------------------------
7+
8+
#Definitions to compile the "core" module.
9+
#This file assumes it will be included from a project specific cmakefile, and
10+
#will not create a library or executable.
11+
#Inputs:
12+
# TFM_ROOT_DIR - directory where secure FW sourec is located.
13+
#
14+
#Outputs:
15+
# Will modify include directories to make the source compile.
16+
# ALL_SRC_C: C source files to be compiled will be added to this list.
17+
# This shall be added to your add_executable or add_library command.
18+
# ALL_SRC_CXX: C++ source files to be compiled will be added to this list.
19+
# This shall be added to your add_executable or add_library command.
20+
# ALL_SRC_ASM: assembly source files to be compiled will be added to this
21+
# list. This shall be added to your add_executable or add_library
22+
# command.
23+
# Include directories will be modified by using the include_directories()
24+
# commands as needed.
25+
26+
#Get the current directory where this file is located.
27+
set(SS_CORE_DIR ${CMAKE_CURRENT_LIST_DIR})
28+
if(NOT DEFINED TFM_ROOT_DIR)
29+
message(FATAL_ERROR
30+
"Please set TFM_ROOT_DIR before including this file.")
31+
endif()
32+
33+
set (SS_CORE_C_SRC
34+
"${SS_CORE_DIR}/tfm_core.c"
35+
"${SS_CORE_DIR}/tfm_handler.c"
36+
"${SS_CORE_DIR}/tfm_secure_api.c"
37+
"${SS_CORE_DIR}/tfm_func_api.c"
38+
"${SS_CORE_DIR}/tfm_spm_services.c"
39+
"${SS_CORE_DIR}/tfm_nspm.c"
40+
"${SS_CORE_DIR}/tfm_boot_data.c"
41+
)
42+
43+
#Append all our source files to global lists.
44+
list(APPEND ALL_SRC_C ${SS_CORE_C_SRC})
45+
unset(SS_CORE_C_SRC)
46+
47+
#Setting include directories
48+
embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
49+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
50+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
51+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
52+
53+
set(BUILD_CMSIS_CORE Off)
54+
set(BUILD_RETARGET Off)
55+
set(BUILD_NATIVE_DRIVERS Off)
56+
set(BUILD_STARTUP Off)
57+
set(BUILD_TARGET_CFG Off)
58+
set(BUILD_TARGET_HARDWARE_KEYS Off)
59+
set(BUILD_TARGET_NV_COUNTERS Off)
60+
set(BUILD_CMSIS_DRIVERS Off)
61+
set(BUILD_TIME Off)
62+
set(BUILD_UART_STDOUT Off)
63+
set(BUILD_FLASH Off)
64+
set(BUILD_BOOT_SEED Off)
65+
set(BUILD_DEVICE_ID Off)
66+
if(NOT DEFINED PLATFORM_CMAKE_FILE)
67+
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
68+
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
69+
message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
70+
else()
71+
include(${PLATFORM_CMAKE_FILE})
72+
endif()
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
#-------------------------------------------------------------------------------
7+
8+
#Definitions to compile the "ipc" module.
9+
#This file assumes it will be included from a project specific cmakefile, and
10+
#will not create a library or executable.
11+
#Inputs:
12+
# TFM_ROOT_DIR - directory where secure FW sourec is located.
13+
#
14+
#Outputs:
15+
# Will modify include directories to make the source compile.
16+
# ALL_SRC_C: C source files to be compiled will be added to this list.
17+
# This shall be added to your add_executable or add_library command.
18+
# ALL_SRC_CXX: C++ source files to be compiled will be added to this list.
19+
# This shall be added to your add_executable or add_library command.
20+
# ALL_SRC_ASM: assembly source files to be compiled will be added to this
21+
# list. This shall be added to your add_executable or add_library
22+
# command.
23+
# Include directories will be modified by using the include_directories()
24+
# commands as needed.
25+
26+
#Get the current directory where this file is located.
27+
set(SS_IPC_DIR ${CMAKE_CURRENT_LIST_DIR})
28+
if(NOT DEFINED TFM_ROOT_DIR)
29+
message(FATAL_ERROR
30+
"Please set TFM_ROOT_DIR before including this file.")
31+
endif()
32+
33+
if (NOT DEFINED TFM_PSA_API)
34+
message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined. ")
35+
elseif (TFM_PSA_API)
36+
set (SS_IPC_C_SRC "${SS_IPC_DIR}/tfm_svcalls.c"
37+
"${SS_IPC_DIR}/psa_service.c"
38+
"${SS_IPC_DIR}/psa_client.c"
39+
"${SS_IPC_DIR}/tfm_arch_v8m.c"
40+
"${SS_IPC_DIR}/tfm_thread.c"
41+
"${SS_IPC_DIR}/tfm_wait.c"
42+
"${SS_IPC_DIR}/tfm_utils.c"
43+
"${SS_IPC_DIR}/tfm_message_queue.c"
44+
"${SS_IPC_DIR}/tfm_pools.c"
45+
"${SS_IPC_DIR}/tfm_spm.c"
46+
"${SS_IPC_DIR}/../tfm_core.c"
47+
"${SS_IPC_DIR}/../tfm_secure_api.c"
48+
"${SS_IPC_DIR}/../tfm_spm_services.c"
49+
"${SS_IPC_DIR}/../tfm_handler.c"
50+
"${SS_IPC_DIR}/../tfm_nspm.c"
51+
"${SS_IPC_DIR}/../tfm_boot_data.c"
52+
)
53+
endif()
54+
55+
#Append all our source files to global lists.
56+
list(APPEND ALL_SRC_C ${SS_IPC_C_SRC})
57+
unset(SS_IPC_C_SRC)
58+
59+
#Setting include directories
60+
embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
61+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
62+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
63+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
64+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core/ipc ABSOLUTE)
65+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core/ipc/include ABSOLUTE)
66+
67+
if(NOT DEFINED PLATFORM_CMAKE_FILE)
68+
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
69+
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
70+
message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
71+
else()
72+
include(${PLATFORM_CMAKE_FILE})
73+
endif()

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/include/tfm_message_queue.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#ifndef __TFM_MESSAGE_QUEUE_H__
88
#define __TFM_MESSAGE_QUEUE_H__
99

10-
#ifndef TFM_MSG_QUEUE_MAX_MSG_NUM
11-
#define TFM_MSG_QUEUE_MAX_MSG_NUM 128
12-
#endif
10+
#define TFM_MSG_QUEUE_MAX_MSG_NUM 16
1311
#define TFM_MSG_MAGIC 0x15154343
1412
/* Message struct to collect parameter from client */
1513
struct tfm_msg_body_t {

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/include/tfm_spm.h

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111
#include "tfm_list.h"
1212
#include "tfm_secure_api.h"
1313

14-
#ifndef TFM_SPM_MAX_ROT_SERV_NUM
1514
#define TFM_SPM_MAX_ROT_SERV_NUM 28
16-
#endif
1715
#define TFM_VERSION_POLICY_RELAXED 0
1816
#define TFM_VERSION_POLICY_STRICT 1
1917

20-
#ifndef TFM_CONN_HANDLE_MAX_NUM
2118
#define TFM_CONN_HANDLE_MAX_NUM 32
22-
#endif
2319

2420
/* RoT connection handle list */
2521
struct tfm_conn_handle_t {
@@ -75,6 +71,16 @@ struct tfm_spm_ipc_partition_t {
7571
*/
7672
uint32_t tfm_spm_partition_get_running_partition_id_ext(void);
7773

74+
/**
75+
* \brief Get the current partition mode.
76+
*
77+
* \param[in] partition_idx Index of current partition
78+
*
79+
* \retval TFM_PARTITION_PRIVILEGED_MODE Privileged mode
80+
* \retval TFM_PARTITION_UNPRIVILEGED_MODE Unprivileged mode
81+
*/
82+
uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx);
83+
7884
/******************** Service handle management functions ********************/
7985

8086
/**
@@ -279,22 +285,38 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
279285
uint32_t minor_version);
280286

281287
/**
282-
* \brief Check the memory reference is valid.
283-
*
284-
* \param[in] buffer Pointer of memory reference
285-
* \param[in] len Length of memory reference in bytes
286-
* \param[in] ns_caller From non-secure caller
287-
* \param[in] access Type of access specified by the
288-
* \ref tfm_memory_access_e
289-
*
290-
* \retval IPC_SUCCESS Success
291-
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
292-
* \retval IPC_ERROR_MEMORY_CHECK Check failed
288+
* \brief Check the memory reference is valid.
289+
*
290+
* \param[in] buffer Pointer of memory reference
291+
* \param[in] len Length of memory reference in bytes
292+
* \param[in] ns_caller From non-secure caller
293+
* \param[in] access Type of access specified by the
294+
* \ref tfm_memory_access_e
295+
* \param[in] privileged Privileged mode or unprivileged mode:
296+
* \ref TFM_PARTITION_UNPRIVILEGED_MODE
297+
* \ref TFM_PARTITION_PRIVILEGED_MODE
298+
*
299+
* \retval IPC_SUCCESS Success
300+
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
301+
* \retval IPC_ERROR_MEMORY_CHECK Check failed
293302
*/
294303
int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller,
295-
enum tfm_memory_access_e access);
304+
enum tfm_memory_access_e access,
305+
uint32_t privileged);
296306

297307
/* This function should be called before schedule function */
298308
void tfm_spm_init(void);
299309

310+
/*
311+
* PendSV specified function.
312+
*
313+
* Parameters :
314+
* ctxb - State context storage pointer
315+
*
316+
* Notes:
317+
* This is a staging API. Scheduler should be called in SPM finally and
318+
* this function will be obsoleted later.
319+
*/
320+
void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb);
321+
300322
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
#ifndef __TFM_SPM_SIGNAL_DEFS_H__
8+
#define __TFM_SPM_SIGNAL_DEFS_H__
9+
10+
#include "test/test_services/tfm_ipc_service/tfm_ipc_service_partition.h"
11+
#include "test/test_services/tfm_core_test/tfm_ss_core_test_signal.h"
12+
#include "test/test_services/tfm_core_test_2/tfm_ss_core_test_2_signal.h"
13+
#include "secure_fw/services/crypto/tfm_crypto_signal.h"
14+
#include "test/test_services/tfm_secure_client_service/tfm_sec_client_ser_sig.h"
15+
#include "secure_fw/services/secure_storage/tfm_sst_signal.h"
16+
#include "secure_fw/services/initial_attestation/tfm_attest_signal.h"
17+
18+
#endif /* __TFM_SPM_SIGNAL_DEFS_H__ */

0 commit comments

Comments
 (0)