aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJamie Fox <jamie.fox@arm.com>2020-02-17 16:08:40 +0000
committerJamie Fox <jamie.fox@arm.com>2020-04-20 20:04:33 +0100
commitd4c3c7435cab9943a12b1d4e2222b2ef75d20381 (patch)
tree8f5436f7c8dc32adddd31ce75419e735b52dc8ab /test
parentb9d9b457267f98fc3add2288dc0d031302402c4d (diff)
downloadtrusted-firmware-m-d4c3c7435cab9943a12b1d4e2222b2ef75d20381.tar.gz
Core: Remove memory permission check API
Removes the tfm_core_memory_permission_check() API and all uses of it. This API is no longer required as all necessary memory permission checks are performed by the SPM on the iovec parameters before control reaches the secure partition. Change-Id: I6489328f508d0405272b598500a04d4336c8d2b3 Signed-off-by: Jamie Fox <jamie.fox@arm.com>
Diffstat (limited to 'test')
-rw-r--r--test/suites/core/non_secure/core_ns_positive_testsuite.c76
-rw-r--r--test/test_services/tfm_core_test/core_test_defs.h4
-rw-r--r--test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h18
-rw-r--r--test/test_services/tfm_core_test/tfm_ss_core_test.c140
-rw-r--r--test/test_services/tfm_core_test/tfm_test_core.yaml14
-rw-r--r--test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c18
6 files changed, 12 insertions, 258 deletions
diff --git a/test/suites/core/non_secure/core_ns_positive_testsuite.c b/test/suites/core/non_secure/core_ns_positive_testsuite.c
index 4b275ab9ac..42a14e36b9 100644
--- a/test/suites/core/non_secure/core_ns_positive_testsuite.c
+++ b/test/suites/core/non_secure/core_ns_positive_testsuite.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
* Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -33,8 +33,6 @@
description, {0} }
#ifndef TFM_PSA_API
-static void tfm_core_test_permissions(struct test_result_t *ret);
-static void tfm_core_test_mpu_access(struct test_result_t *ret);
static void tfm_core_test_get_caller_client_id(struct test_result_t *ret);
static void tfm_core_test_spm_request(struct test_result_t *ret);
#endif /* TFM_PSA_API */
@@ -67,20 +65,11 @@ CORE_TEST_DESCRIPTION(CORE_TEST_ID_CHECK_INIT, tfm_core_test_check_init,
CORE_TEST_DESCRIPTION(CORE_TEST_ID_RECURSION, tfm_core_test_recursion,
"Test direct recursion of secure services"),
#endif
-#ifndef TFM_PSA_API
-CORE_TEST_DESCRIPTION(CORE_TEST_ID_MEMORY_PERMISSIONS,
- tfm_core_test_permissions,
- "Test secure service memory access permissions"),
-#endif /* TFM_PSA_API */
#ifdef TFM_ENABLE_IRQ_TEST
CORE_TEST_DESCRIPTION(CORE_TEST_ID_SECURE_IRQ,
tfm_core_test_irq,
"Test secure irq"),
#endif
-#ifndef TFM_PSA_API
-CORE_TEST_DESCRIPTION(CORE_TEST_ID_MPU_ACCESS, tfm_core_test_mpu_access,
- "Test secure service MPU accesses"),
-#endif /* TFM_PSA_API */
CORE_TEST_DESCRIPTION(CORE_TEST_ID_BUFFER_CHECK, tfm_core_test_buffer_check,
"Test secure service buffer accesses"),
CORE_TEST_DESCRIPTION(CORE_TEST_ID_SS_TO_SS, tfm_core_test_ss_to_ss,
@@ -674,69 +663,6 @@ static void tfm_core_test_recursion(struct test_result_t *ret)
}
#endif
-#ifndef TFM_PSA_API
-static char *error_to_string(const char *desc, int32_t err)
-{
- static char info[80];
-
- sprintf(info, "%s. Error code: %d, extra data: %d",
- desc,
- CORE_TEST_ERROR_GET_CODE(err),
- CORE_TEST_ERROR_GET_EXTRA(err));
- return info;
-}
-
-static void tfm_core_test_mpu_access(struct test_result_t *ret)
-{
- int32_t err;
- int32_t test_case_id = CORE_TEST_ID_MPU_ACCESS;
- uint32_t data[4] = {0};
- psa_invec in_vec[] = { {&test_case_id, sizeof(int32_t)},
- {data, sizeof(data)},
- {(void *)((int32_t)tfm_core_test_mpu_access &
- (~(0x3))),
- sizeof(uint32_t)} };
- psa_outvec outvec[] = { {data, sizeof(data)} };
- struct tfm_core_test_call_args_t args = {in_vec, 3, outvec, 1};
-
- err = tfm_core_test_call(tfm_spm_core_test_sfn_veneer, &args);
-
- if (err != CORE_TEST_ERRNO_SUCCESS) {
- char *info = error_to_string(
- "Service memory accesses configured incorrectly.", err);
- TEST_FAIL(info);
- return;
- }
-
- ret->val = TEST_PASSED;
-}
-
-static void tfm_core_test_permissions(struct test_result_t *ret)
-{
- int32_t err;
- int32_t test_case_id = CORE_TEST_ID_MEMORY_PERMISSIONS;
- uint32_t data[4] = {0};
- psa_invec in_vec[] = { {&test_case_id, sizeof(int32_t)},
- {data, sizeof(data)},
- {(void *)((int32_t)tfm_core_test_mpu_access &
- (~(0x3))),
- sizeof(uint32_t)} };
- psa_outvec outvec[] = { {data, sizeof(data)} };
- struct tfm_core_test_call_args_t args = {in_vec, 3, outvec, 1};
-
- err = tfm_core_test_call(tfm_spm_core_test_sfn_veneer, &args);
-
- if (err != CORE_TEST_ERRNO_SUCCESS) {
- char *info = error_to_string(
- "Service memory accesses configured incorrectly.", err);
- TEST_FAIL(info);
- return;
- }
-
- ret->val = TEST_PASSED;
-}
-#endif /* TFM_PSA_API */
-
static void tfm_core_test_buffer_check(struct test_result_t *ret)
{
int32_t res, i;
diff --git a/test/test_services/tfm_core_test/core_test_defs.h b/test/test_services/tfm_core_test/core_test_defs.h
index e2b26c559f..f1e07fbb84 100644
--- a/test/test_services/tfm_core_test/core_test_defs.h
+++ b/test/test_services/tfm_core_test/core_test_defs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -21,8 +21,6 @@ extern "C" {
#define CORE_TEST_ID_NS_THREAD 1001
#define CORE_TEST_ID_CHECK_INIT 1003
#define CORE_TEST_ID_RECURSION 1004
-#define CORE_TEST_ID_MEMORY_PERMISSIONS 1005
-#define CORE_TEST_ID_MPU_ACCESS 1006
#define CORE_TEST_ID_BUFFER_CHECK 1007
#define CORE_TEST_ID_SS_TO_SS 1008
#define CORE_TEST_ID_SS_TO_SS_BUFFER 1010
diff --git a/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h b/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h
index 346d0b7987..e4a41a4f70 100644
--- a/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h
+++ b/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h
@@ -16,16 +16,14 @@ extern "C" {
#define SPM_CORE_TEST_INIT_SUCCESS_SIGNAL (1U << (0 + 4))
#define SPM_CORE_TEST_DIRECT_RECURSION_SIGNAL (1U << (1 + 4))
-#define SPM_CORE_TEST_MPU_ACCESS_SIGNAL (1U << (2 + 4))
-#define SPM_CORE_TEST_MEMORY_PERMISSIONS_SIGNAL (1U << (3 + 4))
-#define SPM_CORE_TEST_SS_TO_SS_SIGNAL (1U << (4 + 4))
-#define SPM_CORE_TEST_SS_TO_SS_BUFFER_SIGNAL (1U << (5 + 4))
-#define SPM_CORE_TEST_OUTVEC_WRITE_SIGNAL (1U << (6 + 4))
-#define SPM_CORE_TEST_PERIPHERAL_ACCESS_SIGNAL (1U << (7 + 4))
-#define SPM_CORE_TEST_GET_CALLER_CLIENT_ID_SIGNAL (1U << (8 + 4))
-#define SPM_CORE_TEST_SPM_REQUEST_SIGNAL (1U << (9 + 4))
-#define SPM_CORE_TEST_BLOCK_SIGNAL (1U << (10 + 4))
-#define SPM_CORE_TEST_NS_THREAD_SIGNAL (1U << (11 + 4))
+#define SPM_CORE_TEST_SS_TO_SS_SIGNAL (1U << (2 + 4))
+#define SPM_CORE_TEST_SS_TO_SS_BUFFER_SIGNAL (1U << (3 + 4))
+#define SPM_CORE_TEST_OUTVEC_WRITE_SIGNAL (1U << (4 + 4))
+#define SPM_CORE_TEST_PERIPHERAL_ACCESS_SIGNAL (1U << (5 + 4))
+#define SPM_CORE_TEST_GET_CALLER_CLIENT_ID_SIGNAL (1U << (6 + 4))
+#define SPM_CORE_TEST_SPM_REQUEST_SIGNAL (1U << (7 + 4))
+#define SPM_CORE_TEST_BLOCK_SIGNAL (1U << (8 + 4))
+#define SPM_CORE_TEST_NS_THREAD_SIGNAL (1U << (9 + 4))
#ifdef __cplusplus
}
diff --git a/test/test_services/tfm_core_test/tfm_ss_core_test.c b/test/test_services/tfm_core_test/tfm_ss_core_test.c
index 35f6e65e1a..87d22ed5a8 100644
--- a/test/test_services/tfm_core_test/tfm_ss_core_test.c
+++ b/test/test_services/tfm_core_test/tfm_ss_core_test.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -113,94 +113,6 @@ psa_status_t spm_core_test_sfn_direct_recursion(
return CORE_TEST_ERRNO_SUCCESS;
}
}
-
-
-/* Service RW data array for testing memory accesses */
-static int32_t mem[4] = {1, 2, 3, 4};
-
-static psa_status_t test_mpu_access(
- uint32_t *data_r_ptr, uint32_t *code_ptr, uint32_t *data_w_ptr)
-{
- /* If these accesses fail, TFM Core kicks in, there's no returning to sfn */
- /* Code execution, stack access is implicitly tested */
- /* Read RW data */
- int32_t len = sizeof(uint32_t);
- int32_t tmp = mem[0];
-
- tmp++;
- /* Write to RW data region */
- mem[0] = mem[1];
- mem[1] = tmp;
- mem[2] = len;
- mem[3] = ~len;
-
- /* Read from NS data region */
- if (tfm_core_memory_permission_check(data_r_ptr, len, TFM_MEMORY_ACCESS_RO)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_INVALID_BUFFER);
- }
- mem[0] = *data_r_ptr;
-
- /* Write to NS data region */
- if (tfm_core_memory_permission_check(data_w_ptr, len, TFM_MEMORY_ACCESS_RW)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_INVALID_BUFFER);
- }
- data_w_ptr[0] = mem[0];
- data_w_ptr[1] = len;
-
- /* Read from NS code region */
- if (tfm_core_memory_permission_check(code_ptr, len, TFM_MEMORY_ACCESS_RO)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_INVALID_BUFFER);
- }
- data_w_ptr[2] = *code_ptr;
-
- return CORE_TEST_ERRNO_SUCCESS;
-}
-
-static psa_status_t test_memory_permissions(
- uint32_t *data_r_ptr, uint32_t *code_ptr, uint32_t *data_w_ptr)
-{
- int32_t len = sizeof(uint32_t);
- /* Read from NS data region */
- if (tfm_core_memory_permission_check(data_r_ptr, len, TFM_MEMORY_ACCESS_RO)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- /* Write to NS data region */
- if (tfm_core_memory_permission_check(data_w_ptr, len, TFM_MEMORY_ACCESS_RW)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- /* Read from NS code region */
- if (tfm_core_memory_permission_check(code_ptr, len, TFM_MEMORY_ACCESS_RO)
- != TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- /* Write to NS code region - should be rejected */
- if (tfm_core_memory_permission_check(code_ptr, len, TFM_MEMORY_ACCESS_RW)
- == TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- /* NS peripheral region - should be rejected */
- if (tfm_core_memory_permission_check(
- (uint32_t *)0x40000000, len, TFM_MEMORY_ACCESS_RO) == TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- /* S peripheral region - should be rejected */
- if (tfm_core_memory_permission_check(
- (uint32_t *)0x50000000, len, TFM_MEMORY_ACCESS_RO) == TFM_SUCCESS) {
- CORE_TEST_RETURN_ERROR(CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR);
- }
-
- return CORE_TEST_ERRNO_SUCCESS;
-}
#endif /* !defined(TFM_PSA_API) */
static psa_status_t test_peripheral_access(void)
@@ -246,16 +158,6 @@ static psa_status_t test_ss_to_ss_buffer(uint32_t *in_ptr, uint32_t *out_ptr,
return CORE_TEST_ERRNO_TEST_FAULT;
}
-#ifndef TFM_PSA_API
- /* Check requires byte-based size */
- if ((tfm_core_memory_permission_check(in_ptr, len << 2,
- TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS) ||
- (tfm_core_memory_permission_check(out_ptr, len << 2,
- TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS)) {
- return CORE_TEST_ERRNO_INVALID_BUFFER;
- }
-#endif /* !defined(TFM_PSA_API) */
-
for (i = 0; i < len; i++) {
ss_buffer[i] = in_ptr[i];
}
@@ -487,30 +389,6 @@ psa_status_t spm_core_test_sfn(struct psa_invec *in_vec, size_t in_len,
tc = *((uint32_t *)in_vec[0].base);
switch (tc) {
- case CORE_TEST_ID_MPU_ACCESS:
- if ((in_len != 3) || (out_len != 1) ||
- (in_vec[1].len < sizeof(int32_t)) ||
- (in_vec[2].len < sizeof(int32_t)) ||
- (out_vec[0].len < 3*sizeof(int32_t))) {
- return CORE_TEST_ERRNO_INVALID_PARAMETER;
- }
- arg1 = (int32_t)in_vec[1].base;
- arg2 = (int32_t)in_vec[2].base;
- arg3 = (int32_t)out_vec[0].base;
- return test_mpu_access(
- (uint32_t *)arg1, (uint32_t *)arg2, (uint32_t *)arg3);
- case CORE_TEST_ID_MEMORY_PERMISSIONS:
- if ((in_len != 3) || (out_len != 1) ||
- (in_vec[1].len < sizeof(int32_t)) ||
- (in_vec[2].len < sizeof(int32_t)) ||
- (out_vec[0].len < sizeof(int32_t))) {
- return CORE_TEST_ERRNO_INVALID_PARAMETER;
- }
- arg1 = (int32_t)in_vec[1].base;
- arg2 = (int32_t)in_vec[2].base;
- arg3 = (int32_t)out_vec[0].base;
- return test_memory_permissions(
- (uint32_t *)arg1, (uint32_t *)arg2, (uint32_t *)arg3);
case CORE_TEST_ID_SS_TO_SS:
return test_ss_to_ss();
case CORE_TEST_ID_SS_TO_SS_BUFFER:
@@ -560,16 +438,6 @@ static psa_status_t tfm_core_test_sfn_wrap_direct_recursion(psa_msg_t *msg)
return CORE_TEST_ERRNO_TEST_FAULT;
}
-static psa_status_t tfm_core_test_sfn_wrap_mpu_access(psa_msg_t *msg)
-{
- return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
-}
-
-static psa_status_t tfm_core_test_sfn_wrap_memory_permissions(psa_msg_t *msg)
-{
- return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
-}
-
static psa_status_t tfm_core_test_sfn_wrap_ss_to_ss(psa_msg_t *msg)
{
return test_ss_to_ss();
@@ -687,12 +555,6 @@ psa_status_t core_test_init(void)
} else if (signals & SPM_CORE_TEST_DIRECT_RECURSION_SIGNAL) {
core_test_signal_handle(SPM_CORE_TEST_DIRECT_RECURSION_SIGNAL,
tfm_core_test_sfn_wrap_direct_recursion);
- } else if (signals & SPM_CORE_TEST_MPU_ACCESS_SIGNAL) {
- core_test_signal_handle(SPM_CORE_TEST_MPU_ACCESS_SIGNAL,
- tfm_core_test_sfn_wrap_mpu_access);
- } else if (signals & SPM_CORE_TEST_MEMORY_PERMISSIONS_SIGNAL) {
- core_test_signal_handle(SPM_CORE_TEST_MEMORY_PERMISSIONS_SIGNAL,
- tfm_core_test_sfn_wrap_memory_permissions);
} else if (signals & SPM_CORE_TEST_SS_TO_SS_SIGNAL) {
core_test_signal_handle(SPM_CORE_TEST_SS_TO_SS_SIGNAL,
tfm_core_test_sfn_wrap_ss_to_ss);
diff --git a/test/test_services/tfm_core_test/tfm_test_core.yaml b/test/test_services/tfm_core_test/tfm_test_core.yaml
index 2127ef2961..a7e6a81a8b 100644
--- a/test/test_services/tfm_core_test/tfm_test_core.yaml
+++ b/test/test_services/tfm_core_test/tfm_test_core.yaml
@@ -57,20 +57,6 @@
"version_policy": "STRICT"
},
{
- "name": "SPM_CORE_TEST_MPU_ACCESS",
- "sid": "0x0000F022",
- "non_secure_clients": true,
- "version": 1,
- "version_policy": "STRICT"
- },
- {
- "name": "SPM_CORE_TEST_MEMORY_PERMISSIONS",
- "sid": "0x0000F023",
- "non_secure_clients": true,
- "version": 1,
- "version_policy": "STRICT"
- },
- {
"name": "SPM_CORE_TEST_SS_TO_SS",
"sid": "0x0000F024",
"non_secure_clients": true,
diff --git a/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c b/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
index b584b933be..d1187569a0 100644
--- a/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
+++ b/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -142,28 +142,12 @@ static psa_status_t spm_core_test_2_sfn_invert_internal(uint32_t *in_ptr,
int32_t i;
static uint32_t invert_buffer[SFN_INVERT_MAX_LEN];
-#ifndef TFM_PSA_API
- if (tfm_core_memory_permission_check(res_ptr, sizeof(int32_t),
- TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS) {
- return CORE_TEST_ERRNO_INVALID_BUFFER;
- }
-#endif /* !defined(TFM_PSA_API) */
*res_ptr = -1;
if (len > SFN_INVERT_MAX_LEN) {
return CORE_TEST_ERRNO_INVALID_BUFFER;
}
-#ifndef TFM_PSA_API
- /* Check requires byte-based size */
- if ((tfm_core_memory_permission_check(in_ptr, len << 2,
- TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS) ||
- (tfm_core_memory_permission_check(out_ptr, len << 2,
- TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS)) {
- return CORE_TEST_ERRNO_INVALID_BUFFER;
- }
-#endif /* !defined(TFM_PSA_API) */
-
for (i = 0; i < len; i++) {
invert_buffer[i] = in_ptr[i];
}