diff options
author | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-12-05 14:21:28 +0000 |
---|---|---|
committer | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-12-10 16:01:48 +0000 |
commit | f6164aabe5b01b705a1e224ba4a254d4496e3667 (patch) | |
tree | 75f7e7b14475e899bb26c749b6044bed2b4f0f6b | |
parent | 4762fefef13a0502d14c9eec7baa39a454080152 (diff) |
SPM: Remove old interfaces and tests
Remove code based on MM_COMMUNICATE. Remove tests based on it.
Also, remove the now empty arm_def.h.
Change-Id: I08a2680b10df3a24c67abb10e5dc07fda99f6fb9
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
-rw-r--r-- | include/plat/arm/common/arm_def.h | 24 | ||||
-rw-r--r-- | include/runtime_services/secure_el0_payloads/mm_svc.h | 31 | ||||
-rw-r--r-- | include/runtime_services/secure_el0_payloads/secure_partition.h | 70 | ||||
-rw-r--r-- | include/runtime_services/secure_el0_payloads/spm_svc.h | 1 | ||||
-rw-r--r-- | plat/arm/board/fvp/include/platform_def.h | 1 | ||||
-rw-r--r-- | plat/arm/board/juno/include/platform_def.h | 1 | ||||
-rw-r--r-- | spm/cactus/cactus.h | 1 | ||||
-rw-r--r-- | spm/cactus/cactus_main.c | 2 | ||||
-rw-r--r-- | spm/cactus/cactus_service_loop.c | 102 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/secure_service_helpers.c | 23 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_secure_service_handle.c | 254 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_secure_service_interrupts.c | 137 | ||||
-rw-r--r-- | tftf/tests/tests-spm.mk | 3 | ||||
-rw-r--r-- | tftf/tests/tests-spm.xml | 9 |
14 files changed, 6 insertions, 653 deletions
diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h deleted file mode 100644 index a23fc50..0000000 --- a/include/plat/arm/common/arm_def.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef __ARM_DEF_H__ -#define __ARM_DEF_H__ - -/****************************************************************************** - * Definitions common to all ARM standard platforms - *****************************************************************************/ - -/******************************************************************************* - * Location of the memory buffer shared between Normal World (i.e. TFTF) and the - * Secure Partition (e.g. Cactus) to pass data associated to secure service - * requests. - * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_* - * macros). - ******************************************************************************/ -#define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull -#define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull - -#endif /* __ARM_DEF_H__ */ diff --git a/include/runtime_services/secure_el0_payloads/mm_svc.h b/include/runtime_services/secure_el0_payloads/mm_svc.h deleted file mode 100644 index 290fd7d..0000000 --- a/include/runtime_services/secure_el0_payloads/mm_svc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2017, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef __MM_SVC_H__ -#define __MM_SVC_H__ - -#include <utils_def.h> - -#define MM_VERSION_MAJOR U(1) -#define MM_VERSION_MAJOR_SHIFT 16 -#define MM_VERSION_MAJOR_MASK U(0x7FFF) -#define MM_VERSION_MINOR U(0) -#define MM_VERSION_MINOR_SHIFT 0 -#define MM_VERSION_MINOR_MASK U(0xFFFF) -#define MM_VERSION_FORM(major, minor) ((major << MM_VERSION_MAJOR_SHIFT) | (minor)) -#define MM_VERSION_COMPILED MM_VERSION_FORM(MM_VERSION_MAJOR, MM_VERSION_MINOR) - -/* - * SMC IDs defined in [1] for accessing MM services from the Non-secure world. - * These FIDs occupy the range 0x40 - 0x5f. - * [1] DEN0060A_ARM_MM_Interface_Specification.pdf - */ -#define MM_VERSION_AARCH32 U(0x84000040) - -#define MM_COMMUNICATE_AARCH64 U(0xC4000041) -#define MM_COMMUNICATE_AARCH32 U(0x84000041) - -#endif /* __MM_SVC_H__ */ diff --git a/include/runtime_services/secure_el0_payloads/secure_partition.h b/include/runtime_services/secure_el0_payloads/secure_partition.h index 4ee466c..712337e 100644 --- a/include/runtime_services/secure_el0_payloads/secure_partition.h +++ b/include/runtime_services/secure_el0_payloads/secure_partition.h @@ -4,27 +4,14 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __SECURE_PARTITION_H__ -#define __SECURE_PARTITION_H__ +#ifndef SECURE_PARTITION_H +#define SECURE_PARTITION_H -#ifndef __ASSEMBLY__ -#include <cassert.h> #include <param_header.h> #include <types.h> -#endif #include <utils_def.h> /* - * Definitions used to access the members of secure_partition_boot_info from - * assembly code. - */ -#define SP_BOOT_INFO_STACK_BASE_OFFSET U(32) -#define SP_BOOT_INFO_IMAGE_SIZE_OFFSET U(64) -#define SP_BOOT_INFO_PCPU_STACK_SIZE_OFFSET U(72) - -#ifndef __ASSEMBLY__ - -/* * Flags used by the secure_partition_mp_info structure to describe the * characteristics of a cpu. Only a single flag is defined at the moment to * indicate the primary cpu. @@ -43,60 +30,9 @@ typedef struct secure_partition_mp_info { typedef struct secure_partition_boot_info { param_header_t h; - uint64_t sp_mem_base; - uint64_t sp_mem_limit; - uint64_t sp_image_base; - uint64_t sp_stack_base; - uint64_t sp_heap_base; - uint64_t sp_ns_comm_buf_base; - uint64_t sp_shared_buf_base; - uint64_t sp_image_size; - uint64_t sp_pcpu_stack_size; - uint64_t sp_heap_size; - uint64_t sp_ns_comm_buf_size; - uint64_t sp_shared_buf_size; - uint32_t num_sp_mem_regions; uint32_t num_cpus; secure_partition_mp_info_t *mp_info; } secure_partition_boot_info_t; -/* - * This structure is used to pass data associated to secure service requests. - */ -#define SPS_MAX_PAYLOAD_SIZE 32 -typedef struct secure_partition_request_info { - uint32_t id; - uint64_t data_size; - uint8_t data[SPS_MAX_PAYLOAD_SIZE]; -} secure_partition_request_info_t; - -/* Define some fast secure partition requests (SPS) IDs. */ -#define SPS_TIMER_SLEEP 1 -#define SPS_CHECK_ALIVE 2 - -#define CACTUS_FAST_REQUEST_SUCCESS 0xCACF900D - -secure_partition_request_info_t *create_sps_request(uint32_t id, - const void *data, - uint64_t data_size); - -/* - * Compile time assertions related to the 'secure_partition_boot_info' structure - * to ensure that the assembler and the compiler view of the offsets of the - * structure members is the same. - */ -CASSERT(SP_BOOT_INFO_STACK_BASE_OFFSET == - __builtin_offsetof(secure_partition_boot_info_t, sp_stack_base), \ - assert_secure_partition_boot_info_sp_stack_base_offset_mismatch); - -CASSERT(SP_BOOT_INFO_IMAGE_SIZE_OFFSET == - __builtin_offsetof(secure_partition_boot_info_t, sp_image_size), \ - assert_secure_partition_boot_info_sp_image_size_offset_mismatch); - -CASSERT(SP_BOOT_INFO_PCPU_STACK_SIZE_OFFSET == - __builtin_offsetof(secure_partition_boot_info_t, sp_pcpu_stack_size), \ - assert_secure_partition_boot_info_sp_pcpu_stack_size_offset_mismatch); - -#endif /* __ASSEMBLY__ */ -#endif /* __SECURE_PARTITION_H__ */ +#endif /* SECURE_PARTITION_H */ diff --git a/include/runtime_services/secure_el0_payloads/spm_svc.h b/include/runtime_services/secure_el0_payloads/spm_svc.h index e3b6cc5..e1f9df3 100644 --- a/include/runtime_services/secure_el0_payloads/spm_svc.h +++ b/include/runtime_services/secure_el0_payloads/spm_svc.h @@ -33,7 +33,6 @@ * They occupy the range 0x60-0x7f. */ #define SPM_VERSION_AARCH32 U(0x84000060) -#define SP_EVENT_COMPLETE_AARCH64 U(0xC4000061) #define SP_MEMORY_ATTRIBUTES_GET_AARCH64 U(0xC4000064) #define SP_MEMORY_ATTRIBUTES_SET_AARCH64 U(0xC4000065) diff --git a/plat/arm/board/fvp/include/platform_def.h b/plat/arm/board/fvp/include/platform_def.h index 2ef467b..55477b4 100644 --- a/plat/arm/board/fvp/include/platform_def.h +++ b/plat/arm/board/fvp/include/platform_def.h @@ -5,7 +5,6 @@ */ #include <arch.h> -#include <arm_def.h> #include "../fvp_def.h" /******************************************************************************* diff --git a/plat/arm/board/juno/include/platform_def.h b/plat/arm/board/juno/include/platform_def.h index 66d7224..38c5fe4 100644 --- a/plat/arm/board/juno/include/platform_def.h +++ b/plat/arm/board/juno/include/platform_def.h @@ -5,7 +5,6 @@ */ #include <arch.h> -#include <arm_def.h> #include "../juno_def.h" /******************************************************************************* diff --git a/spm/cactus/cactus.h b/spm/cactus/cactus.h index 94d214c..fb8155f 100644 --- a/spm/cactus/cactus.h +++ b/spm/cactus/cactus.h @@ -7,7 +7,6 @@ #ifndef __CACTUS_H__ #define __CACTUS_H__ -#include <secure_partition.h> #include <types.h> /* Linker symbols used to figure out the memory layout of Cactus. */ diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c index faf8ccc..889c174 100644 --- a/spm/cactus/cactus_main.c +++ b/spm/cactus/cactus_main.c @@ -10,9 +10,7 @@ #include <pl011.h> #include <plat_arm.h> #include <platform_def.h> -#include <secure_partition.h> #include <sp_helpers.h> -#include <spm_svc.h> #include <std_svc.h> #include "cactus.h" diff --git a/spm/cactus/cactus_service_loop.c b/spm/cactus/cactus_service_loop.c index 9f542b5..a6b576d 100644 --- a/spm/cactus/cactus_service_loop.c +++ b/spm/cactus/cactus_service_loop.c @@ -7,64 +7,11 @@ #include <assert.h> #include <debug.h> #include <mm_svc.h> -#include <secure_partition.h> #include <sp_helpers.h> +#include <sprt_svc.h> #include <spm_svc.h> #include <string.h> - -/* - * Handle a fast secure service request, i.e. one made through an MM_COMMUNICATE - * call. - * - * cc - * Calling convention. If MM_COMMUNICATE has been invoked using the SMC32 - * calling convention, this argument must be 32, else 64. - * - * sps - * Communication buffer attached to the secure partition service request. - */ -static int32_t cactus_handle_fast_request(int cc, - secure_partition_request_info_t *sps) -{ - assert(cc == 32 || cc == 64); - - /* No SMC32 is supported at the moment. Just ignore them. */ - if (cc == 32) { - INFO("Ignoring MM_COMMUNICATE_AARCH32 call\n"); - return SPM_SUCCESS; - } - - /* See secure_partition.h for possible ID values. */ - switch (sps->id) { - case SPS_TIMER_SLEEP: { - if (sps->data_size != 1) { - ERROR("Invalid payload size for SPM_SPS_TIMER_SLEEP request (%llu)\n", - sps->data_size); - return SPM_INVALID_PARAMETER; - } - int duration_sec = sps->data[0]; - sp_sleep(duration_sec); - - /* - * Write back to the communication buffer to acknowledge the - * request has been successfully handled. - */ - uint32_t response = CACTUS_FAST_REQUEST_SUCCESS; - memcpy(sps->data, &response, sizeof(response)); - return SPM_SUCCESS; - } - - case SPS_CHECK_ALIVE: - return SPM_SUCCESS; - - default: - INFO("Unsupported MM_COMMUNICATE_AARCH64 call with service ID 0x%x, ignoring it\n", - sps->id); - return SPM_INVALID_PARAMETER; - } -} - __dead2 void secure_services_loop(void) { int32_t event_status_code; @@ -84,53 +31,6 @@ __dead2 void secure_services_loop(void) int32_t event_id = sp_svc(&svc_values); switch (event_id) { - case MM_COMMUNICATE_AARCH64: - { - uint64_t ctx_addr = svc_values.arg1; - uint32_t ctx_size = svc_values.arg2; - uint64_t cookie = svc_values.arg3; - - NOTICE("Cactus: Received MM_COMMUNICATE_AARCH64 call\n"); - NOTICE("Cactus: Context address: 0x%llx\n", ctx_addr); - NOTICE("Cactus: Context size : %u\n", ctx_size); - NOTICE("Cactus: Cookie : 0x%llx\n", cookie); - - if (ctx_addr == 0) { - ERROR("Context address is invalid\n"); - event_status_code = SPM_INVALID_PARAMETER; - continue; - } - - secure_partition_request_info_t *sps = (void *)(uintptr_t) ctx_addr; - NOTICE("Received fast secure service request with ID #%u\n", - sps->id); - event_status_code = cactus_handle_fast_request(64, sps); - break; - } - - case MM_COMMUNICATE_AARCH32: - { - uint32_t ctx_addr = svc_values.arg1; - uint32_t ctx_size = svc_values.arg2; - uint32_t cookie = svc_values.arg3; - - NOTICE("Cactus: Received MM_COMMUNICATE_AARCH32 call\n"); - NOTICE("Cactus: Context address: 0x%x\n", ctx_addr); - NOTICE("Cactus: Context size : %u\n", ctx_size); - NOTICE("Cactus: Cookie : 0x%x\n", cookie); - - if (ctx_addr == 0) { - ERROR("Context address is invalid\n"); - event_status_code = SPM_INVALID_PARAMETER; - continue; - } - - secure_partition_request_info_t *sps = (void *)(uintptr_t) ctx_addr; - NOTICE("Received fast secure service request with ID #%u\n", - sps->id); - event_status_code = cactus_handle_fast_request(32, sps); - break; - } default: NOTICE("Unhandled Service ID 0x%x\n", event_id); diff --git a/tftf/tests/runtime_services/secure_service/secure_service_helpers.c b/tftf/tests/runtime_services/secure_service/secure_service_helpers.c deleted file mode 100644 index 8675dae..0000000 --- a/tftf/tests/runtime_services/secure_service/secure_service_helpers.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <platform.h> -#include <secure_partition.h> -#include <string.h> - - -secure_partition_request_info_t *create_sps_request(uint32_t id, - const void *data, - uint64_t data_size) -{ - secure_partition_request_info_t *sps_request - = (void *) ARM_SECURE_SERVICE_BUFFER_BASE; - sps_request->id = id; - sps_request->data_size = data_size; - if (data_size != 0) - memcpy(sps_request->data, data, data_size); - return sps_request; -} diff --git a/tftf/tests/runtime_services/secure_service/test_secure_service_handle.c b/tftf/tests/runtime_services/secure_service/test_secure_service_handle.c deleted file mode 100644 index ce4dd5c..0000000 --- a/tftf/tests/runtime_services/secure_service/test_secure_service_handle.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <debug.h> -#include <events.h> -#include <mm_svc.h> -#include <plat_topology.h> -#include <platform.h> -#include <power_management.h> -#include <secure_partition.h> -#include <smccc.h> -#include <spm_svc.h> -#include <test_helpers.h> -#include <tftf_lib.h> -#include <xlat_tables_v2.h> - -static event_t cpu_has_finished_test[PLATFORM_CORE_COUNT]; - -/* Test routine for test_secure_partition_secondary_cores_seq() */ -static test_result_t test_secure_partition_secondary_cores_seq_fn(void) -{ - test_result_t result = TEST_RESULT_SUCCESS; - u_register_t cpu_mpid = read_mpidr_el1() & MPID_MASK; - unsigned int core_pos = platform_get_core_pos(cpu_mpid); - - secure_partition_request_info_t *sps_request = - create_sps_request(SPS_CHECK_ALIVE, NULL, 0); - - INFO("Sending MM_COMMUNICATE_AARCH64 from CPU %u\n", - platform_get_core_pos(read_mpidr_el1() & MPID_MASK)); - - smc_args mm_communicate_smc = { - MM_COMMUNICATE_AARCH64, - 0, - (u_register_t) sps_request, - 0 - }; - - smc_ret_values smc_ret = tftf_smc(&mm_communicate_smc); - - if ((uint32_t)smc_ret.ret0 != 0) { - tftf_testcase_printf("Cactus returned: 0x%x\n", - (uint32_t)smc_ret.ret0); - - result = TEST_RESULT_FAIL; - } - - tftf_send_event(&cpu_has_finished_test[core_pos]); - - return result; -} - -/* - * @Test_Aim@ This tests that secondary CPUs can access SPM services - * sequentially. - */ -test_result_t test_secure_partition_secondary_cores_seq(void) -{ - int psci_ret; - u_register_t lead_mpid, cpu_mpid; - unsigned int cpu_node, core_pos; - test_result_t result = TEST_RESULT_SUCCESS; - - SKIP_TEST_IF_LESS_THAN_N_CPUS(2); - - SKIP_TEST_IF_MM_VERSION_LESS_THAN(1, 0); - - VERBOSE("Mapping NS<->SP shared buffer\n"); - - int rc = mmap_add_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE, - MT_MEMORY | MT_RW | MT_NS); - if (rc != 0) { - tftf_testcase_printf("%d: mmap_add_dynamic_region() = %d\n", - __LINE__, rc); - result = TEST_RESULT_FAIL; - goto exit; - } - - lead_mpid = read_mpidr_el1() & MPID_MASK; - - INFO("Lead CPU is CPU %u\n", platform_get_core_pos(lead_mpid)); - - if (test_secure_partition_secondary_cores_seq_fn() != TEST_RESULT_SUCCESS) { - result = TEST_RESULT_FAIL; - goto exit_unmap; - } - - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU, we have already tested it */ - if (cpu_mpid == lead_mpid) { - continue; - } - - core_pos = platform_get_core_pos(cpu_mpid); - - tftf_init_event(&cpu_has_finished_test[core_pos]); - - VERBOSE("Powering on CPU %u\n", core_pos); - - psci_ret = tftf_cpu_on(cpu_mpid, - (uintptr_t)test_secure_partition_secondary_cores_seq_fn, 0); - if (psci_ret != PSCI_E_SUCCESS) { - tftf_testcase_printf( - "Failed to power on CPU %d (rc = %d)\n", - core_pos, psci_ret); - result = TEST_RESULT_FAIL; - goto exit_unmap; - } - - tftf_wait_for_event(&cpu_has_finished_test[core_pos]); - } - -exit_unmap: - VERBOSE("Unmapping NS<->SP shared buffer\n"); - - mmap_remove_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE); - -exit: - return result; -} - -/******************************************************************************/ - -static event_t cpu_can_start_test[PLATFORM_CORE_COUNT]; - -/* Test routine for test_secure_partition_secondary_core() */ -static test_result_t test_secure_partition_secondary_cores_sim_fn(void) -{ - test_result_t result = TEST_RESULT_SUCCESS; - u_register_t cpu_mpid = read_mpidr_el1() & MPID_MASK; - unsigned int core_pos = platform_get_core_pos(cpu_mpid); - - secure_partition_request_info_t *sps_request = - create_sps_request(SPS_CHECK_ALIVE, NULL, 0); - - smc_args mm_communicate_smc = { - MM_COMMUNICATE_AARCH64, - 0, - (u_register_t) sps_request, - 0 - }; - - tftf_wait_for_event(&cpu_can_start_test[core_pos]); - - /* - * Invoke SMCs for some time to make sure that all CPUs are doing it at - * the same time during the test. - */ - for (int i = 0; i < 100; i++) { - smc_ret_values smc_ret = tftf_smc(&mm_communicate_smc); - - if ((uint32_t)smc_ret.ret0 != 0) { - tftf_testcase_printf("Cactus returned 0x%x at CPU %d\n", - (uint32_t)smc_ret.ret0, core_pos); - result = TEST_RESULT_FAIL; - break; - } - } - - tftf_send_event(&cpu_has_finished_test[core_pos]); - - return result; -} - -/* - * @Test_Aim@ This tests that secondary CPUs can access SPM services - * simultaneously. - */ -test_result_t test_secure_partition_secondary_cores_sim(void) -{ - int psci_ret; - u_register_t lead_mpid, cpu_mpid; - unsigned int cpu_node, core_pos; - test_result_t result = TEST_RESULT_SUCCESS; - - SKIP_TEST_IF_LESS_THAN_N_CPUS(2); - - SKIP_TEST_IF_MM_VERSION_LESS_THAN(1, 0); - - VERBOSE("Mapping NS<->SP shared buffer\n"); - - int rc = mmap_add_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE, - MT_MEMORY | MT_RW | MT_NS); - if (rc != 0) { - tftf_testcase_printf("%d: mmap_add_dynamic_region() = %d\n", - __LINE__, rc); - result = TEST_RESULT_FAIL; - goto exit; - } - - lead_mpid = read_mpidr_el1() & MPID_MASK; - - INFO("Lead CPU is CPU %u\n", platform_get_core_pos(lead_mpid)); - - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - core_pos = platform_get_core_pos(cpu_mpid); - tftf_init_event(&cpu_can_start_test[core_pos]); - } - - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU as it is already powered on */ - if (cpu_mpid == lead_mpid) { - continue; - } - - core_pos = platform_get_core_pos(cpu_mpid); - - VERBOSE("Powering on CPU %u\n", core_pos); - - psci_ret = tftf_cpu_on(cpu_mpid, - (uintptr_t)test_secure_partition_secondary_cores_sim_fn, 0); - if (psci_ret != PSCI_E_SUCCESS) { - tftf_testcase_printf( - "Failed to power on CPU %d (rc = %d)\n", - core_pos, psci_ret); - result = TEST_RESULT_FAIL; - goto exit_unmap; - } - } - - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - core_pos = platform_get_core_pos(cpu_mpid); - tftf_send_event(&cpu_can_start_test[core_pos]); - } - - result = test_secure_partition_secondary_cores_sim_fn(); - - /* Wait until all CPUs have finished to unmap the NS<->SP buffer */ - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - core_pos = platform_get_core_pos(cpu_mpid); - tftf_wait_for_event(&cpu_has_finished_test[core_pos]); - } -exit_unmap: - VERBOSE("Unmapping NS<->SP shared buffer\n"); - - mmap_remove_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE); -exit: - return result; -} diff --git a/tftf/tests/runtime_services/secure_service/test_secure_service_interrupts.c b/tftf/tests/runtime_services/secure_service/test_secure_service_interrupts.c deleted file mode 100644 index 50c3df6..0000000 --- a/tftf/tests/runtime_services/secure_service/test_secure_service_interrupts.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <assert.h> -#include <debug.h> -#include <mm_svc.h> -#include <secure_partition.h> -#include <smccc.h> -#include <spm_svc.h> -#include <string.h> -#include <test_helpers.h> -#include <tftf_lib.h> -#include <timer.h> -#include <xlat_tables_v2.h> - -static volatile int timer_irq_received; - -/* - * ISR for the timer interrupt. - * Just update a global variable to prove it has been called. - */ -static int timer_handler(void *data) -{ - assert(timer_irq_received == 0); - timer_irq_received = 1; - return 0; -} - - -/* - * @Test_Aim@ Test that non-secure interrupts do not interrupt secure service - * requests. - * - * 1. Register a handler for the non-secure timer interrupt. - * - * 2. Program the non-secure timer to fire in 500 ms. - * - * 3. Make a long-running (> 500 ms) fast secure service request. - * This is achieved by requesting the timer sleep service in Cactus - * with a 1 second sleep delay. - * - * 4. While servicing the timer sleep request, the non-secure timer should - * fire but not interrupt Cactus. - * - * 5. Once back in TFTF, check the response from Cactus, which shows whether the - * secure service indeed ran to completion. - * - * 6. Also check whether the pending non-secure timer interrupt successfully got - * handled in TFTF. - */ -test_result_t test_secure_partition_interrupt_by_ns(void) -{ - secure_partition_request_info_t *sps_request; - test_result_t result = TEST_RESULT_FAIL; - - SKIP_TEST_IF_MM_VERSION_LESS_THAN(1, 0); - - VERBOSE("Mapping NS<->SP shared buffer\n"); - - int rc = mmap_add_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE, - MT_MEMORY | MT_RW | MT_NS); - if (rc != 0) { - tftf_testcase_printf("%d: mmap_add_dynamic_region() = %d\n", - __LINE__, rc); - return TEST_RESULT_FAIL; - } - - timer_irq_received = 0; - tftf_timer_register_handler(timer_handler); - - NOTICE("Programming the timer...\n"); - rc = tftf_program_timer(500); - if (rc < 0) { - tftf_testcase_printf("Failed to program timer (%d)\n", rc); - goto exit_test; - } - - INFO("Sending MM_COMMUNICATE_AARCH64 to Cactus\n"); - - uint8_t timer_delay = 1; - sps_request = create_sps_request(SPS_TIMER_SLEEP, - &timer_delay, sizeof(timer_delay)); - smc_args mm_communicate_smc = { - MM_COMMUNICATE_AARCH64, - 0, /* cookie, MBZ */ - (uintptr_t) sps_request, - 0 - }; - - smc_ret_values smc_ret = tftf_smc(&mm_communicate_smc); - - INFO("Returned from Cactus, MM_COMMUNICATE_AARCH64 handling complete\n"); - - /* - * If MM_COMMUNICATE gets interrupted, SPM will return SPM_QUEUED, which - * is normally not a valid return value for MM_COMMUNICATE. - */ - if ((uint32_t) smc_ret.ret0 != SPM_SUCCESS) { - tftf_testcase_printf("Cactus returned: 0x%x\n", - (uint32_t) smc_ret.ret0); - goto exit_test; - } - - uint32_t cactus_response; - memcpy(&cactus_response, sps_request->data, sizeof(cactus_response)); - if (cactus_response != CACTUS_FAST_REQUEST_SUCCESS) { - tftf_testcase_printf("Error code from the timer secure service: 0x%x\n", - cactus_response); - goto exit_test; - } - - /* - * If the timer interrupt is still pending, make sure it is taken right - * now. - */ - isb(); - - if (timer_irq_received == 1) - result = TEST_RESULT_SUCCESS; - -exit_test: - tftf_cancel_timer(); - tftf_timer_unregister_handler(); - - VERBOSE("Unmapping NS<->SP shared buffer\n"); - - mmap_remove_dynamic_region(ARM_SECURE_SERVICE_BUFFER_BASE, - ARM_SECURE_SERVICE_BUFFER_SIZE); - - return result; -} diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk index 3d664fd..69a8e49 100644 --- a/tftf/tests/tests-spm.mk +++ b/tftf/tests/tests-spm.mk @@ -6,7 +6,4 @@ TESTS_SOURCES += \ $(addprefix tftf/tests/runtime_services/secure_service/, \ - secure_service_helpers.c \ - test_secure_service_handle.c \ - test_secure_service_interrupts.c \ ) diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml index ff3ff44..69636c1 100644 --- a/tftf/tests/tests-spm.xml +++ b/tftf/tests/tests-spm.xml @@ -8,14 +8,9 @@ <testsuites> - <testsuite name="SPM tests" + <testsuite name="Secure Partition Manager" description="Test SPM APIs"> - <testcase name="SPM NS interrupts test" - function="test_secure_partition_interrupt_by_ns" /> - <testcase name="SPM secondary CPUs sequential test" - function="test_secure_partition_secondary_cores_seq" /> - <testcase name="SPM secondary CPUs simultaneous test" - function="test_secure_partition_secondary_cores_sim" /> + </testsuite> </testsuites> |