Skip to content

Commit b2fb3d7

Browse files
authored
Merge pull request #9823 from kfnta/wait_and_identity
mbed-SPM updates
2 parents ca06f94 + cfb60ec commit b2fb3d7

File tree

101 files changed

+92053
-79901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+92053
-79901
lines changed

TESTS/mbed-crypto/sanity/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ utest::v1::status_t case_teardown_handler(const Case *const source, const size_t
438438

439439
utest::v1::status_t test_setup(const size_t number_of_cases)
440440
{
441+
#ifndef NO_GREENTEA
441442
GREENTEA_SETUP(120, "default_auto");
443+
#endif
442444
return verbose_test_setup_handler(number_of_cases);
443445
}
444446

TESTS/psa/crypto_access_control/COMPONENT_PSA_SRV_IPC/test_partition_proxy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#include "psa/client.h"
19-
#include "psa_test_partition_ifs.h"
19+
#include "psa_manifest/sid.h"
2020
#include "test_partition_proxy.h"
2121

2222
#define MINOR_VER 1

TESTS/psa/crypto_access_control/COMPONENT_SPE/psa_test_partition_partition.h renamed to TESTS/psa/crypto_access_control/COMPONENT_SPE/psa_crypto_acl_test_partition.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@
2323
* Generated by tools/spm/generate_partition_code.py Version 1.0
2424
**********************************************************************************************************************/
2525

26-
#ifndef PSA_TEST_PARTITION_PARTITION_H
27-
#define PSA_TEST_PARTITION_PARTITION_H
26+
#ifndef PSA_CRYPTO_ACL_TEST_PARTITION_H
27+
#define PSA_CRYPTO_ACL_TEST_PARTITION_H
2828

29-
#define TEST_PARTITION_ID 128
29+
#define CRYPTO_ACL_TEST_ID 128
3030

31-
#define TEST_PARTITION_ROT_SRV_COUNT (9UL)
32-
#define TEST_PARTITION_EXT_ROT_SRV_COUNT (1UL)
31+
#define CRYPTO_ACL_TEST_ROT_SRV_COUNT (9UL)
32+
#define CRYPTO_ACL_TEST_EXT_ROT_SRV_COUNT (1UL)
3333

34-
/* TEST_PARTITION event flags */
35-
#define TEST_PARTITION_RESERVED1_POS (1UL)
36-
#define TEST_PARTITION_RESERVED1_MSK (1UL << TEST_PARTITION_RESERVED1_POS)
34+
/* CRYPTO_ACL_TEST event flags */
35+
#define CRYPTO_ACL_TEST_RESERVED1_POS (1UL)
36+
#define CRYPTO_ACL_TEST_RESERVED1_MSK (1UL << CRYPTO_ACL_TEST_RESERVED1_POS)
3737

38-
#define TEST_PARTITION_RESERVED2_POS (2UL)
39-
#define TEST_PARTITION_RESERVED2_MSK (1UL << TEST_PARTITION_RESERVED2_POS)
38+
#define CRYPTO_ACL_TEST_RESERVED2_POS (2UL)
39+
#define CRYPTO_ACL_TEST_RESERVED2_MSK (1UL << CRYPTO_ACL_TEST_RESERVED2_POS)
4040

4141

42+
#define CRYPTO_ACL_TEST_WAIT_ANY_IRQ_MSK (0)
4243

4344
#define CRYPTO_CREATE_PERSISTENT_KEY_MSK_POS (4UL)
4445
#define CRYPTO_CREATE_PERSISTENT_KEY_MSK (1UL << CRYPTO_CREATE_PERSISTENT_KEY_MSK_POS)
@@ -59,7 +60,7 @@
5960
#define CRYPTO_IMPORT_KEY_MSK_POS (12UL)
6061
#define CRYPTO_IMPORT_KEY_MSK (1UL << CRYPTO_IMPORT_KEY_MSK_POS)
6162

62-
#define TEST_PARTITION_WAIT_ANY_SID_MSK (\
63+
#define CRYPTO_ACL_TEST_WAIT_ANY_SID_MSK (\
6364
CRYPTO_CREATE_PERSISTENT_KEY_MSK | \
6465
CRYPTO_GENERATE_KEY_MSK | \
6566
CRYPTO_OPEN_PERSISTENT_KEY_MSK | \
@@ -71,4 +72,4 @@
7172
CRYPTO_IMPORT_KEY_MSK)
7273

7374

74-
#endif // PSA_TEST_PARTITION_PARTITION_H
75+
#endif // PSA_CRYPTO_ACL_TEST_PARTITION_H

TESTS/psa/crypto_access_control/COMPONENT_SPE/test_partition.c

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@
1616
*/
1717

1818
#include <stdlib.h>
19-
#include "psa_test_partition_partition.h"
20-
#include "psa/service.h"
19+
#include "psa_crypto_acl_test_partition.h"
2120
#include "psa/client.h"
21+
#include "psa/service.h"
2222
#include "psa/crypto.h"
2323

2424
typedef psa_status_t (*SignalHandler)(psa_msg_t *);
2525

26-
#if defined(TARGET_TFM)
27-
#define SPM_PANIC(format, ...) \
28-
{ \
29-
while(1){}; \
30-
}
31-
#endif
32-
3326
static void read_input_param_from_message(psa_msg_t *msg, uint8_t param_index, void *param_ptr)
3427
{
3528
size_t bytes_read = psa_read(msg->handle, param_index, param_ptr, msg->in_size[param_index]);
@@ -207,41 +200,59 @@ void test_partition_main(void)
207200
psa_signal_t signal;
208201
psa_msg_t msg = {0};
209202
while (1) {
210-
signal = psa_wait_any(PSA_BLOCK);
203+
signal = psa_wait(CRYPTO_ACL_TEST_WAIT_ANY_SID_MSK, PSA_BLOCK);
211204
if (signal & CRYPTO_CREATE_PERSISTENT_KEY_MSK) {
212-
psa_get(CRYPTO_CREATE_PERSISTENT_KEY_MSK, &msg);
205+
if (PSA_SUCCESS != psa_get(CRYPTO_CREATE_PERSISTENT_KEY_MSK, &msg)) {
206+
continue;
207+
}
213208
message_handler(&msg, crypto_create_persistent_key);
214209
}
215210
if (signal & CRYPTO_GENERATE_KEY_MSK) {
216-
psa_get(CRYPTO_GENERATE_KEY_MSK, &msg);
211+
if (PSA_SUCCESS != psa_get(CRYPTO_GENERATE_KEY_MSK, &msg)) {
212+
continue;
213+
}
217214
message_handler(&msg, crypto_generate_key);
218215
}
219216
if (signal & CRYPTO_OPEN_PERSISTENT_KEY_MSK) {
220-
psa_get(CRYPTO_OPEN_PERSISTENT_KEY_MSK, &msg);
217+
if (PSA_SUCCESS != psa_get(CRYPTO_OPEN_PERSISTENT_KEY_MSK, &msg)) {
218+
continue;
219+
}
221220
message_handler(&msg, crypto_open_persistent_key);
222221
}
223222
if (signal & CRYPTO_CLOSE_KEY_MSK) {
224-
psa_get(CRYPTO_CLOSE_KEY_MSK, &msg);
223+
if (PSA_SUCCESS != psa_get(CRYPTO_CLOSE_KEY_MSK, &msg)) {
224+
continue;
225+
}
225226
message_handler(&msg, crypto_close_key);
226227
}
227228
if (signal & CRYPTO_SET_KEY_POLICY_MSK) {
228-
psa_get(CRYPTO_SET_KEY_POLICY_MSK, &msg);
229+
if (PSA_SUCCESS != psa_get(CRYPTO_SET_KEY_POLICY_MSK, &msg)) {
230+
continue;
231+
}
229232
message_handler(&msg, crypto_set_key_policy);
230233
}
231234
if (signal & CRYPTO_DESTROY_KEY_MSK) {
232-
psa_get(CRYPTO_DESTROY_KEY_MSK, &msg);
235+
if (PSA_SUCCESS != psa_get(CRYPTO_DESTROY_KEY_MSK, &msg)) {
236+
continue;
237+
}
233238
message_handler(&msg, crypto_destroy_key);
234239
}
235240
if (signal & CRYPTO_GET_KEY_INFO_MSK) {
236-
psa_get(CRYPTO_GET_KEY_INFO_MSK, &msg);
241+
if (PSA_SUCCESS != psa_get(CRYPTO_GET_KEY_INFO_MSK, &msg)) {
242+
continue;
243+
}
237244
message_handler(&msg, crypto_get_key_info);
238245
}
239246
if (signal & CRYPTO_GET_KEY_POLICY_MSK) {
240-
psa_get(CRYPTO_GET_KEY_POLICY_MSK, &msg);
247+
if (PSA_SUCCESS != psa_get(CRYPTO_GET_KEY_POLICY_MSK, &msg)) {
248+
continue;
249+
}
241250
message_handler(&msg, crypto_get_key_policy);
242251
}
243252
if (signal & CRYPTO_IMPORT_KEY_MSK) {
244-
psa_get(CRYPTO_IMPORT_KEY_MSK, &msg);
253+
if (PSA_SUCCESS != psa_get(CRYPTO_IMPORT_KEY_MSK, &msg)) {
254+
continue;
255+
}
245256
message_handler(&msg, crypto_import_key);
246257
}
247258
}

TESTS/psa/crypto_access_control/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_partition_partition.c renamed to TESTS/psa/crypto_access_control/TARGET_MBED_SPM/COMPONENT_SPE/psa_crypto_acl_test_partition.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,30 @@
2828
#include "rtx_os.h"
2929
#include "spm_panic.h"
3030
#include "spm_internal.h"
31-
#include "psa_test_partition_partition.h"
32-
#include "psa_test_partition_ifs.h"
33-
#include "psa_crypto_srv_ifs.h"
31+
#include "psa_crypto_acl_test_partition.h"
32+
#include "psa_manifest/sid.h"
3433

3534

3635
/* Threads stacks */
37-
MBED_ALIGN(8) uint8_t test_partition_thread_stack[512] = {0};
36+
MBED_ALIGN(8) uint8_t crypto_acl_test_thread_stack[512] = {0};
3837

3938
/* Threads control blocks */
40-
osRtxThread_t test_partition_thread_cb = {0};
39+
osRtxThread_t crypto_acl_test_thread_cb = {0};
4140

4241
/* Thread attributes - for thread initialization */
43-
osThreadAttr_t test_partition_thread_attr = {
44-
.name = "test_partition",
42+
osThreadAttr_t crypto_acl_test_thread_attr = {
43+
.name = "crypto_acl_test",
4544
.attr_bits = 0,
46-
.cb_mem = &test_partition_thread_cb,
47-
.cb_size = sizeof(test_partition_thread_cb),
48-
.stack_mem = test_partition_thread_stack,
45+
.cb_mem = &crypto_acl_test_thread_cb,
46+
.cb_size = sizeof(crypto_acl_test_thread_cb),
47+
.stack_mem = crypto_acl_test_thread_stack,
4948
.stack_size = 512,
5049
.priority = osPriorityNormal,
5150
.tz_module = 0,
5251
.reserved = 0
5352
};
5453

55-
spm_rot_service_t test_partition_rot_services[TEST_PARTITION_ROT_SRV_COUNT] = {
54+
spm_rot_service_t crypto_acl_test_rot_services[CRYPTO_ACL_TEST_ROT_SRV_COUNT] = {
5655
{
5756
.sid = CRYPTO_CREATE_PERSISTENT_KEY,
5857
.mask = CRYPTO_CREATE_PERSISTENT_KEY_MSK,
@@ -163,41 +162,41 @@ spm_rot_service_t test_partition_rot_services[TEST_PARTITION_ROT_SRV_COUNT] = {
163162
},
164163
};
165164

166-
/* External SIDs used by TEST_PARTITION */
167-
const uint32_t test_partition_external_sids[1] = {
165+
/* External SIDs used by CRYPTO_ACL_TEST */
166+
const uint32_t crypto_acl_test_external_sids[1] = {
168167
PSA_KEY_MNG_ID,
169168
};
170169

171-
static osRtxMutex_t test_partition_mutex = {0};
172-
static const osMutexAttr_t test_partition_mutex_attr = {
173-
.name = "test_partition_mutex",
170+
static osRtxMutex_t crypto_acl_test_mutex = {0};
171+
static const osMutexAttr_t crypto_acl_test_mutex_attr = {
172+
.name = "crypto_acl_test_mutex",
174173
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
175-
.cb_mem = &test_partition_mutex,
176-
.cb_size = sizeof(test_partition_mutex),
174+
.cb_mem = &crypto_acl_test_mutex,
175+
.cb_size = sizeof(crypto_acl_test_mutex),
177176
};
178177

179178

180179
extern void test_partition_main(void *ptr);
181180

182-
void test_partition_init(spm_partition_t *partition)
181+
void crypto_acl_test_init(spm_partition_t *partition)
183182
{
184183
if (NULL == partition) {
185184
SPM_PANIC("partition is NULL!\n");
186185
}
187186

188-
partition->mutex = osMutexNew(&test_partition_mutex_attr);
187+
partition->mutex = osMutexNew(&crypto_acl_test_mutex_attr);
189188
if (NULL == partition->mutex) {
190-
SPM_PANIC("Failed to create mutex for secure partition test_partition!\n");
189+
SPM_PANIC("Failed to create mutex for secure partition crypto_acl_test!\n");
191190
}
192191

193-
for (uint32_t i = 0; i < TEST_PARTITION_ROT_SRV_COUNT; ++i) {
194-
test_partition_rot_services[i].partition = partition;
192+
for (uint32_t i = 0; i < CRYPTO_ACL_TEST_ROT_SRV_COUNT; ++i) {
193+
crypto_acl_test_rot_services[i].partition = partition;
195194
}
196-
partition->rot_services = test_partition_rot_services;
195+
partition->rot_services = crypto_acl_test_rot_services;
197196

198-
partition->thread_id = osThreadNew(test_partition_main, NULL, &test_partition_thread_attr);
197+
partition->thread_id = osThreadNew(test_partition_main, NULL, &crypto_acl_test_thread_attr);
199198
if (NULL == partition->thread_id) {
200-
SPM_PANIC("Failed to create start main thread of partition test_partition!\n");
199+
SPM_PANIC("Failed to create start main thread of partition crypto_acl_test!\n");
201200
}
202201
}
203202

TESTS/psa/crypto_access_control/COMPONENT_SPE/psa_setup.c renamed to TESTS/psa/crypto_access_control/TARGET_MBED_SPM/COMPONENT_SPE/psa_setup.c

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,22 @@
2727
#include "spm_internal.h"
2828
#include "handles_manager.h"
2929
#include "cmsis.h"
30-
#include "psa_test_partition_partition.h"
3130
#include "psa_attest_srv_partition.h"
3231
#include "psa_crypto_srv_partition.h"
3332
#include "psa_platform_partition.h"
3433
#include "psa_its_partition.h"
34+
#include "psa_crypto_acl_test_partition.h"
3535

36-
extern const uint32_t test_partition_external_sids[1];
3736
extern const uint32_t attest_srv_external_sids[7];
3837
extern const uint32_t crypto_srv_external_sids[4];
3938
extern const uint32_t platform_external_sids[1];
39+
extern const uint32_t crypto_acl_test_external_sids[1];
4040

4141
spm_partition_t g_partitions[5] = {
42-
{
43-
.partition_id = TEST_PARTITION_ID,
44-
.thread_id = 0,
45-
.flags_rot_srv = TEST_PARTITION_WAIT_ANY_SID_MSK,
46-
.flags_interrupts = 0,
47-
.rot_services = NULL,
48-
.rot_services_count = TEST_PARTITION_ROT_SRV_COUNT,
49-
.extern_sids = test_partition_external_sids,
50-
.extern_sids_count = TEST_PARTITION_EXT_ROT_SRV_COUNT,
51-
.irq_mapper = NULL,
52-
},
5342
{
5443
.partition_id = ATTEST_SRV_ID,
5544
.thread_id = 0,
56-
.flags_rot_srv = ATTEST_SRV_WAIT_ANY_SID_MSK,
57-
.flags_interrupts = 0,
45+
.flags = ATTEST_SRV_WAIT_ANY_SID_MSK | ATTEST_SRV_WAIT_ANY_IRQ_MSK,
5846
.rot_services = NULL,
5947
.rot_services_count = ATTEST_SRV_ROT_SRV_COUNT,
6048
.extern_sids = attest_srv_external_sids,
@@ -64,8 +52,7 @@ spm_partition_t g_partitions[5] = {
6452
{
6553
.partition_id = CRYPTO_SRV_ID,
6654
.thread_id = 0,
67-
.flags_rot_srv = CRYPTO_SRV_WAIT_ANY_SID_MSK,
68-
.flags_interrupts = 0,
55+
.flags = CRYPTO_SRV_WAIT_ANY_SID_MSK | CRYPTO_SRV_WAIT_ANY_IRQ_MSK,
6956
.rot_services = NULL,
7057
.rot_services_count = CRYPTO_SRV_ROT_SRV_COUNT,
7158
.extern_sids = crypto_srv_external_sids,
@@ -75,8 +62,7 @@ spm_partition_t g_partitions[5] = {
7562
{
7663
.partition_id = PLATFORM_ID,
7764
.thread_id = 0,
78-
.flags_rot_srv = PLATFORM_WAIT_ANY_SID_MSK,
79-
.flags_interrupts = 0,
65+
.flags = PLATFORM_WAIT_ANY_SID_MSK | PLATFORM_WAIT_ANY_IRQ_MSK,
8066
.rot_services = NULL,
8167
.rot_services_count = PLATFORM_ROT_SRV_COUNT,
8268
.extern_sids = platform_external_sids,
@@ -86,14 +72,23 @@ spm_partition_t g_partitions[5] = {
8672
{
8773
.partition_id = ITS_ID,
8874
.thread_id = 0,
89-
.flags_rot_srv = ITS_WAIT_ANY_SID_MSK,
90-
.flags_interrupts = 0,
75+
.flags = ITS_WAIT_ANY_SID_MSK | ITS_WAIT_ANY_IRQ_MSK,
9176
.rot_services = NULL,
9277
.rot_services_count = ITS_ROT_SRV_COUNT,
9378
.extern_sids = NULL,
9479
.extern_sids_count = ITS_EXT_ROT_SRV_COUNT,
9580
.irq_mapper = NULL,
9681
},
82+
{
83+
.partition_id = CRYPTO_ACL_TEST_ID,
84+
.thread_id = 0,
85+
.flags = CRYPTO_ACL_TEST_WAIT_ANY_SID_MSK | CRYPTO_ACL_TEST_WAIT_ANY_IRQ_MSK,
86+
.rot_services = NULL,
87+
.rot_services_count = CRYPTO_ACL_TEST_ROT_SRV_COUNT,
88+
.extern_sids = crypto_acl_test_external_sids,
89+
.extern_sids_count = CRYPTO_ACL_TEST_EXT_ROT_SRV_COUNT,
90+
.irq_mapper = NULL,
91+
},
9792
};
9893

9994
/* Check all the defined memory regions for overlapping. */
@@ -104,23 +99,23 @@ const mem_region_t *mem_regions = NULL;
10499
const uint32_t mem_region_count = 0;
105100

106101
// forward declaration of partition initializers
107-
void test_partition_init(spm_partition_t *partition);
108102
void attest_srv_init(spm_partition_t *partition);
109103
void crypto_srv_init(spm_partition_t *partition);
110104
void platform_init(spm_partition_t *partition);
111105
void its_init(spm_partition_t *partition);
106+
void crypto_acl_test_init(spm_partition_t *partition);
112107

113108
uint32_t init_partitions(spm_partition_t **partitions)
114109
{
115110
if (NULL == partitions) {
116111
SPM_PANIC("partitions is NULL!\n");
117112
}
118113

119-
test_partition_init(&(g_partitions[0]));
120-
attest_srv_init(&(g_partitions[1]));
121-
crypto_srv_init(&(g_partitions[2]));
122-
platform_init(&(g_partitions[3]));
123-
its_init(&(g_partitions[4]));
114+
attest_srv_init(&(g_partitions[0]));
115+
crypto_srv_init(&(g_partitions[1]));
116+
platform_init(&(g_partitions[2]));
117+
its_init(&(g_partitions[3]));
118+
crypto_acl_test_init(&(g_partitions[4]));
124119

125120
*partitions = g_partitions;
126121
return 5;

TESTS/psa/crypto_access_control/crypto_acl_test_partition_psa.json renamed to TESTS/psa/crypto_access_control/crypto_acl_tests_partition_psa.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "TEST_PARTITION",
2+
"name": "CRYPTO_ACL_TEST",
33
"type": "APPLICATION-ROT",
44
"priority": "NORMAL",
55
"id": "0x00000080",

TESTS/psa/crypto_access_control/psa_test_partition_ifs.h renamed to TESTS/psa/crypto_access_control/psa_crypto_acl_test_ifs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* Generated by tools/spm/generate_partition_code.py Version 1.0
2424
**********************************************************************************************************************/
2525

26-
#ifndef PSA_TEST_PARTITION_PARTITION_ROT_SERVICES_H
27-
#define PSA_TEST_PARTITION_PARTITION_ROT_SERVICES_H
26+
#ifndef PSA_CRYPTO_ACL_TEST_PARTITION_ROT_SERVICES_H
27+
#define PSA_CRYPTO_ACL_TEST_PARTITION_ROT_SERVICES_H
2828

2929
#define CRYPTO_CREATE_PERSISTENT_KEY 0x00000200
3030
#define CRYPTO_GENERATE_KEY 0x00000201
@@ -36,4 +36,4 @@
3636
#define CRYPTO_GET_KEY_POLICY 0x00000207
3737
#define CRYPTO_IMPORT_KEY 0x00000208
3838

39-
#endif // PSA_TEST_PARTITION_PARTITION_ROT_SERVICES_H
39+
#endif // PSA_CRYPTO_ACL_TEST_PARTITION_ROT_SERVICES_H

0 commit comments

Comments
 (0)