Skip to content

Fix TF-M import commits order #10467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/*
* Copyright (c) 2017-2019, Arm Limited. All rights reserved.
* Copyright (c) 2017-2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <stdint.h>
#include <stdbool.h>
#include "cmsis.h"
#include "rtx_os.h"
#include "cmsis_os2.h"
#include "tfm_api.h"
#include "tfm_ns_lock.h"
Expand All @@ -27,9 +29,14 @@ static struct ns_lock_state ns_lock = {.init=false, .id=NULL};
/**
* \brief Mutex properties, NS lock
*/

static osRtxMutex_t ns_lock_cb = { 0 };

static const osMutexAttr_t ns_lock_attrib = {
.name = "ns_lock",
.attr_bits = osMutexPrioInherit
.attr_bits = osMutexPrioInherit,
.cb_mem = &ns_lock_cb,
.cb_size = sizeof(ns_lock_cb)
};

/**
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#ifndef __TFM_MESSAGE_QUEUE_H__
#define __TFM_MESSAGE_QUEUE_H__

#ifndef TFM_MSG_QUEUE_MAX_MSG_NUM
#define TFM_MSG_QUEUE_MAX_MSG_NUM 128
#endif
#define TFM_MSG_MAGIC 0x15154343
/* Message struct to collect parameter from client */
struct tfm_msg_body_t {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
#include <stdbool.h>
#include "tfm_list.h"

#ifndef TFM_SPM_MAX_ROT_SERV_NUM
#define TFM_SPM_MAX_ROT_SERV_NUM 28
#endif
#define TFM_VERSION_POLICY_RELAXED 0
#define TFM_VERSION_POLICY_STRICT 1

#ifndef TFM_CONN_HANDLE_MAX_NUM
#define TFM_CONN_HANDLE_MAX_NUM 32
#endif

/* RoT connection handle list */
struct tfm_conn_handle_t {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TFM_POOL_DECLARE(msg_db_pool, sizeof(struct tfm_msg_body_t),
TFM_MSG_QUEUE_MAX_MSG_NUM);

static struct tfm_spm_service_db_t g_spm_service_db[] = {
#include "secure_fw/services/tfm_service_list.inc"
#include "tfm_service_list.inc"
};

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

node->rhandle = NULL;

/* Back handle buffer to pool */
tfm_pool_free(node);
return IPC_SUCCESS;
Expand Down Expand Up @@ -271,7 +273,7 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,

switch (service->service_db->minor_policy) {
case TFM_VERSION_POLICY_RELAXED:
if (minor_version < service->service_db->minor_version) {
if (minor_version > service->service_db->minor_version) {
return IPC_ERROR_VERSION;
}
break;
Expand Down Expand Up @@ -430,15 +432,19 @@ tfm_spm_partition_get_thread_info_ext(uint32_t partition_idx)
return &g_spm_partition_db.partitions[partition_idx].sp_thrd;
}

static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
static uint32_t tfm_spm_partition_get_stack_size_ext(uint32_t partition_idx)
{
return (uint32_t)&(g_spm_partition_db.partitions[partition_idx].
stack[TFM_STACK_SIZE]);
return g_spm_partition_db.partitions[partition_idx].stack_size;
}

static uint32_t tfm_spm_partition_get_stack_limit_ext(uint32_t partition_idx)
{
return (uint32_t)&g_spm_partition_db.partitions[partition_idx].stack;
return g_spm_partition_db.partitions[partition_idx].stack_limit;
}

static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
{
return tfm_spm_partition_get_stack_limit_ext(partition_idx) + tfm_spm_partition_get_stack_size_ext(partition_idx);
}

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

REGION_DECLARE_EXT(Image$$, ARM_LIB_HEAP, $$ZI$$Base);
REGION_DECLARE_EXT(Image$$, ARM_LIB_HEAP, $$ZI$$Limit);
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Base);
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Limit);
REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$RW$$Base);
Expand Down Expand Up @@ -512,7 +520,19 @@ int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller)
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}

base = (uintptr_t)NS_CODE_START;
limit = (uintptr_t)(NS_CODE_START + NS_CODE_SIZE);
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}
} else {
base = (uintptr_t)&REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Base);
limit = (uintptr_t)&REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit);
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}

base = (uintptr_t)&REGION_NAME(Image$$, ER_TFM_DATA, $$RW$$Base);
limit = (uintptr_t)&REGION_NAME(Image$$, ER_TFM_DATA, $$RW$$Limit);
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
Expand All @@ -537,6 +557,12 @@ int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller)
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}

base = (uintptr_t)S_CODE_START;
limit = (uintptr_t)(S_CODE_START + S_CODE_SIZE);
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}
}

return IPC_ERROR_MEMORY_CHECK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define EXC_NUM_PENDSV (14)
#define EXC_NUM_SYSTICK (15)

#define printf(...)

/* Disable NS exceptions by setting NS PRIMASK to 1 */
#define TFM_NS_EXC_DISABLE() __TZ_set_PRIMASK_NS(1)
/* Enable NS exceptions by setting NS PRIMASK to 0 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "tfm_internal.h"
#include "tfm_api.h"
#include "platform/include/tfm_spm_hal.h"
#include "uart_stdout.h"
#include "secure_utilities.h"
#include "secure_fw/spm/spm_api.h"
#include "secure_fw/include/tfm_spm_services_api.h"
Expand Down Expand Up @@ -88,7 +87,6 @@ int32_t tfm_core_init(void)

__enable_irq();

stdio_init();
LOG_MSG("Secure image initializing!");

#ifdef TFM_CORE_DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int32_t tfm_core_ns_ipc_request(void *fn, int32_t arg1, int32_t arg2,
int32_t arg3, int32_t arg4)
{
int32_t args[4] = {arg1, arg2, arg3, arg4};
struct tfm_sfn_req_s desc, *desc_ptr = &desc;
volatile struct tfm_sfn_req_s desc;
struct tfm_sfn_req_s *desc_ptr = &desc;
int32_t res;

desc.sfn = fn;
Expand Down Expand Up @@ -98,7 +99,7 @@ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t minor_version)
__tfm_secure_gateway_attributes__
psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
const psa_invec *in_vecs,
const psa_invec *out_vecs)
psa_outvec *out_vecs)
{
TFM_CORE_NS_IPC_REQUEST_VENEER(tfm_svcall_psa_call, handle, in_vecs,
out_vecs, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "tfm_secure_api.h"
#include "tfm_nspm.h"
#include "secure_utilities.h"
#include "uart_stdout.h"
#include "secure_fw/spm/spm_api.h"
#include "region_defs.h"
#include "tfm_api.h"
Expand Down
Loading