Skip to content

Commit c48361b

Browse files
committed
"Update directory platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST"
1 parent eff8fda commit c48361b

23 files changed

+1845
-1012
lines changed

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_ns_interface.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
*
66
*/
77
#include <stdint.h>
8-
#include <stdbool.h>
98

109
#include "os_wrapper/mutex.h"
1110

12-
#include "tfm_api.h"
1311
#include "tfm_ns_interface.h"
1412

1513
/**
1614
* \brief the ns_lock ID
1715
*/
1816
static void *ns_lock_handle = NULL;
1917

20-
__attribute__((weak))
2118
int32_t tfm_ns_interface_dispatch(veneer_fn fn,
2219
uint32_t arg0, uint32_t arg1,
2320
uint32_t arg2, uint32_t arg3)
@@ -35,16 +32,15 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
3532
return result;
3633
}
3734

38-
__attribute__((weak))
39-
enum tfm_status_e tfm_ns_interface_init(void)
35+
uint32_t tfm_ns_interface_init(void)
4036
{
4137
void *handle;
4238

4339
handle = os_wrapper_mutex_create();
4440
if (!handle) {
45-
return TFM_ERROR_GENERIC;
41+
return OS_WRAPPER_ERROR;
4642
}
4743

4844
ns_lock_handle = handle;
49-
return TFM_SUCCESS;
45+
return OS_WRAPPER_SUCCESS;
5046
}

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_psa_ns_api.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
2+
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -8,6 +8,7 @@
88
#include "psa/client.h"
99
#include "tfm_ns_interface.h"
1010
#include "tfm_api.h"
11+
#include "tfm_psa_call_param.h"
1112

1213
/**** API functions ****/
1314

@@ -47,23 +48,17 @@ psa_status_t psa_call(psa_handle_t handle, int32_t type,
4748
psa_outvec *out_vec,
4849
size_t out_len)
4950
{
50-
/* FixMe: sanity check can be added to offload some NS thread checks from
51-
* TFM secure API
52-
*/
53-
54-
/* Due to v8M restrictions, TF-M NS API needs to add another layer of
55-
* serialization in order for NS to pass arguments to S
56-
*/
57-
const struct tfm_control_parameter_t ctrl_param = {
58-
.type = type,
59-
.in_len = in_len,
60-
.out_len = out_len,
61-
};
51+
if ((type > INT16_MAX) ||
52+
(type < INT16_MIN) ||
53+
(in_len > UINT8_MAX) ||
54+
(out_len > UINT8_MAX)) {
55+
return PSA_ERROR_PROGRAMMER_ERROR;
56+
}
6257

6358
return tfm_ns_interface_dispatch(
6459
(veneer_fn)tfm_psa_call_veneer,
6560
(uint32_t)handle,
66-
(uint32_t)&ctrl_param,
61+
PARAM_PACK(type, in_len, out_len),
6762
(uint32_t)in_vec,
6863
(uint32_t)out_vec);
6964
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TF-Mv1.3.0
1+
TF-Mv1.4.0

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/psa/client.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
extern "C" {
1818
#endif
1919

20+
#ifndef IOVEC_LEN
21+
#define IOVEC_LEN(arr) ((uint32_t)(sizeof(arr)/sizeof(arr[0])))
22+
#endif
23+
2024
/*********************** PSA Client Macros and Types *************************/
2125

2226
/**
@@ -126,6 +130,14 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t version);
126130
/**
127131
* \brief Call an RoT Service on an established connection.
128132
*
133+
* \note FF-M 1.0 proposes 6 parameters for psa_call but the secure gateway ABI
134+
* support at most 4 parameters. TF-M chooses to encode 'in_len',
135+
* 'out_len', and 'type' into a 32-bit integer to improve efficiency.
136+
* Compared with struct-based encoding, this method saves extra memory
137+
* check and memory copy operation. The disadvantage is that the 'type'
138+
* range has to be reduced into a 16-bit integer. So with this encoding,
139+
* the valid range for 'type' is 0-32767.
140+
*
129141
* \param[in] handle A handle to an established connection.
130142
* \param[in] type The request type.
131143
* Must be zero( \ref PSA_IPC_CALL) or positive.

0 commit comments

Comments
 (0)