Skip to content

Commit 45c1776

Browse files
authored
Merge pull request #10467 from kfnta/release-candidate
Fix TF-M import commits order
2 parents 1e81845 + a6b8f63 commit 45c1776

File tree

17 files changed

+64
-242
lines changed

17 files changed

+64
-242
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
2-
* Copyright (c) 2017-2019, Arm Limited. All rights reserved.
2+
* Copyright (c) 2017-2018, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
66
*/
77
#include <stdint.h>
88
#include <stdbool.h>
9+
#include "cmsis.h"
10+
#include "rtx_os.h"
911
#include "cmsis_os2.h"
1012
#include "tfm_api.h"
1113
#include "tfm_ns_lock.h"
@@ -27,9 +29,14 @@ static struct ns_lock_state ns_lock = {.init=false, .id=NULL};
2729
/**
2830
* \brief Mutex properties, NS lock
2931
*/
32+
33+
static osRtxMutex_t ns_lock_cb = { 0 };
34+
3035
static const osMutexAttr_t ns_lock_attrib = {
3136
.name = "ns_lock",
32-
.attr_bits = osMutexPrioInherit
37+
.attr_bits = osMutexPrioInherit,
38+
.cb_mem = &ns_lock_cb,
39+
.cb_size = sizeof(ns_lock_cb)
3340
};
3441

3542
/**

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/CMakeLists.inc

Lines changed: 0 additions & 71 deletions
This file was deleted.

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/CMakeLists.inc

Lines changed: 0 additions & 74 deletions
This file was deleted.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#ifndef __TFM_MESSAGE_QUEUE_H__
88
#define __TFM_MESSAGE_QUEUE_H__
99

10+
#ifndef TFM_MSG_QUEUE_MAX_MSG_NUM
1011
#define TFM_MSG_QUEUE_MAX_MSG_NUM 128
12+
#endif
1113
#define TFM_MSG_MAGIC 0x15154343
1214
/* Message struct to collect parameter from client */
1315
struct tfm_msg_body_t {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
#include <stdbool.h>
1111
#include "tfm_list.h"
1212

13+
#ifndef TFM_SPM_MAX_ROT_SERV_NUM
1314
#define TFM_SPM_MAX_ROT_SERV_NUM 28
15+
#endif
1416
#define TFM_VERSION_POLICY_RELAXED 0
1517
#define TFM_VERSION_POLICY_STRICT 1
1618

19+
#ifndef TFM_CONN_HANDLE_MAX_NUM
1720
#define TFM_CONN_HANDLE_MAX_NUM 32
21+
#endif
1822

1923
/* RoT connection handle list */
2024
struct tfm_conn_handle_t {

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/tfm_spm.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TFM_POOL_DECLARE(msg_db_pool, sizeof(struct tfm_msg_body_t),
4646
TFM_MSG_QUEUE_MAX_MSG_NUM);
4747

4848
static struct tfm_spm_service_db_t g_spm_service_db[] = {
49-
#include "secure_fw/services/tfm_service_list.inc"
49+
#include "tfm_service_list.inc"
5050
};
5151

5252
/********************** SPM functions for handler mode ***********************/
@@ -109,6 +109,8 @@ int32_t tfm_spm_free_conn_handle(struct tfm_spm_service_t *service,
109109
/* Remove node from handle list */
110110
tfm_list_del_node(&node->list);
111111

112+
node->rhandle = NULL;
113+
112114
/* Back handle buffer to pool */
113115
tfm_pool_free(node);
114116
return IPC_SUCCESS;
@@ -271,7 +273,7 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
271273

272274
switch (service->service_db->minor_policy) {
273275
case TFM_VERSION_POLICY_RELAXED:
274-
if (minor_version < service->service_db->minor_version) {
276+
if (minor_version > service->service_db->minor_version) {
275277
return IPC_ERROR_VERSION;
276278
}
277279
break;
@@ -430,15 +432,19 @@ tfm_spm_partition_get_thread_info_ext(uint32_t partition_idx)
430432
return &g_spm_partition_db.partitions[partition_idx].sp_thrd;
431433
}
432434

433-
static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
435+
static uint32_t tfm_spm_partition_get_stack_size_ext(uint32_t partition_idx)
434436
{
435-
return (uint32_t)&(g_spm_partition_db.partitions[partition_idx].
436-
stack[TFM_STACK_SIZE]);
437+
return g_spm_partition_db.partitions[partition_idx].stack_size;
437438
}
438439

439440
static uint32_t tfm_spm_partition_get_stack_limit_ext(uint32_t partition_idx)
440441
{
441-
return (uint32_t)&g_spm_partition_db.partitions[partition_idx].stack;
442+
return g_spm_partition_db.partitions[partition_idx].stack_limit;
443+
}
444+
445+
static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
446+
{
447+
return tfm_spm_partition_get_stack_limit_ext(partition_idx) + tfm_spm_partition_get_stack_size_ext(partition_idx);
442448
}
443449

444450
static tfm_thrd_func_t
@@ -457,6 +463,8 @@ static uint32_t tfm_spm_partition_get_priority_ext(uint32_t partition_idx)
457463
/* Macros to pick linker symbols and allow references to sections in all level*/
458464
#define REGION_DECLARE_EXT(a, b, c) extern uint32_t REGION_NAME(a, b, c)
459465

466+
REGION_DECLARE_EXT(Image$$, ARM_LIB_HEAP, $$ZI$$Base);
467+
REGION_DECLARE_EXT(Image$$, ARM_LIB_HEAP, $$ZI$$Limit);
460468
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Base);
461469
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Limit);
462470
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$RW$$Base);
@@ -512,7 +520,19 @@ int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller)
512520
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
513521
return IPC_SUCCESS;
514522
}
523+
524+
base = (uintptr_t)NS_CODE_START;
525+
limit = (uintptr_t)(NS_CODE_START + NS_CODE_SIZE);
526+
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
527+
return IPC_SUCCESS;
528+
}
515529
} else {
530+
base = (uintptr_t)&REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Base);
531+
limit = (uintptr_t)&REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit);
532+
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
533+
return IPC_SUCCESS;
534+
}
535+
516536
base = (uintptr_t)&REGION_NAME(Image$$, ER_TFM_DATA, $$RW$$Base);
517537
limit = (uintptr_t)&REGION_NAME(Image$$, ER_TFM_DATA, $$RW$$Limit);
518538
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
@@ -537,6 +557,12 @@ int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller)
537557
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
538558
return IPC_SUCCESS;
539559
}
560+
561+
base = (uintptr_t)S_CODE_START;
562+
limit = (uintptr_t)(S_CODE_START + S_CODE_SIZE);
563+
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
564+
return IPC_SUCCESS;
565+
}
540566
}
541567

542568
return IPC_ERROR_MEMORY_CHECK;

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/secure_utilities.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define EXC_NUM_PENDSV (14)
2626
#define EXC_NUM_SYSTICK (15)
2727

28+
#define printf(...)
29+
2830
/* Disable NS exceptions by setting NS PRIMASK to 1 */
2931
#define TFM_NS_EXC_DISABLE() __TZ_set_PRIMASK_NS(1)
3032
/* Enable NS exceptions by setting NS PRIMASK to 0 */

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/tfm_core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "tfm_internal.h"
1212
#include "tfm_api.h"
1313
#include "platform/include/tfm_spm_hal.h"
14-
#include "uart_stdout.h"
1514
#include "secure_utilities.h"
1615
#include "secure_fw/spm/spm_api.h"
1716
#include "secure_fw/include/tfm_spm_services_api.h"
@@ -88,7 +87,6 @@ int32_t tfm_core_init(void)
8887

8988
__enable_irq();
9089

91-
stdio_init();
9290
LOG_MSG("Secure image initializing!");
9391

9492
#ifdef TFM_CORE_DEBUG

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/tfm_psa_api_client.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ int32_t tfm_core_ns_ipc_request(void *fn, int32_t arg1, int32_t arg2,
4848
int32_t arg3, int32_t arg4)
4949
{
5050
int32_t args[4] = {arg1, arg2, arg3, arg4};
51-
struct tfm_sfn_req_s desc, *desc_ptr = &desc;
51+
volatile struct tfm_sfn_req_s desc;
52+
struct tfm_sfn_req_s *desc_ptr = &desc;
5253
int32_t res;
5354

5455
desc.sfn = fn;
@@ -98,7 +99,7 @@ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t minor_version)
9899
__tfm_secure_gateway_attributes__
99100
psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
100101
const psa_invec *in_vecs,
101-
const psa_invec *out_vecs)
102+
psa_outvec *out_vecs)
102103
{
103104
TFM_CORE_NS_IPC_REQUEST_VENEER(tfm_svcall_psa_call, handle, in_vecs,
104105
out_vecs, 0);

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/tfm_secure_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "tfm_secure_api.h"
1313
#include "tfm_nspm.h"
1414
#include "secure_utilities.h"
15-
#include "uart_stdout.h"
1615
#include "secure_fw/spm/spm_api.h"
1716
#include "region_defs.h"
1817
#include "tfm_api.h"

0 commit comments

Comments
 (0)