diff options
Diffstat (limited to 'tftf')
-rw-r--r-- | tftf/tests/common/test_helpers.c | 51 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c | 29 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c | 67 | ||||
-rw-r--r-- | tftf/tests/tests-spm.mk | 1 | ||||
-rw-r--r-- | tftf/tests/tests-spm.xml | 8 |
5 files changed, 135 insertions, 21 deletions
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c index 8fdfdedc0..9861070f9 100644 --- a/tftf/tests/common/test_helpers.c +++ b/tftf/tests/common/test_helpers.c @@ -1,16 +1,19 @@ /* - * Copyright (c) 2018, Arm Limited. All rights reserved. + * Copyright (c) 2020, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <arch_helpers.h> +#include <ffa_helpers.h> #include <plat_topology.h> #include <platform.h> #include <power_management.h> #include <test_helpers.h> #include <tftf_lib.h> +static struct mailbox_buffers test_mb = {.send = NULL, .recv = NULL}; + int is_sys_suspend_state_ready(void) { int aff_info; @@ -128,3 +131,49 @@ test_result_t map_test_unmap(const map_args_unmap_t *args, return test_ret; } + +void set_tftf_mailbox(const struct mailbox_buffers *mb) +{ + if (mb != NULL) { + test_mb = *mb; + } +} + +bool get_tftf_mailbox(struct mailbox_buffers *mb) +{ + if ((test_mb.recv != NULL) && (test_mb.send != NULL)) { + *mb = test_mb; + return true; + } + return false; +} + +test_result_t check_hafnium_spmc_testing_set_up( + uint32_t ffa_version_major, uint32_t ffa_version_minor, + const struct ffa_uuid *ffa_uuids, size_t ffa_uuids_size) +{ + struct mailbox_buffers mb; + + if (ffa_uuids == NULL) { + ERROR("Invalid parameter ffa_uuids!\n"); + return TEST_RESULT_FAIL; + } + + SKIP_TEST_IF_FFA_VERSION_LESS_THAN(ffa_version_major, + ffa_version_minor); + + /********************************************************************** + * If OP-TEE is SPMC skip the current test. + **********************************************************************/ + if (check_spmc_execution_level()) { + VERBOSE("OPTEE as SPMC at S-EL1. Skipping test!\n"); + return TEST_RESULT_SKIPPED; + } + + GET_TFTF_MAILBOX(mb); + + for (unsigned int i = 0U; i < ffa_uuids_size; i++) + SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(*mb, ffa_uuids[i].uuid); + + return TEST_RESULT_SUCCESS; +} diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c index 0ae8a8d30..fded19988 100644 --- a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c +++ b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c @@ -20,17 +20,6 @@ /* Memory section to be sent over mem management ABIs */ static __aligned(PAGE_SIZE) uint8_t share_page[PAGE_SIZE]; -static __aligned(PAGE_SIZE) uint8_t send_page[PAGE_SIZE]; -static __aligned(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE]; - -/* Within the same test the RXTX Buffers only need to be shared once */ -static bool rxtx_mapped; - -static struct mailbox_buffers mb = { - .recv = (void *)recv_page, - .send = (void *)send_page, - }; - static test_result_t test_memory_send_sp(uint32_t mem_func) { smc_ret_values ret; @@ -40,6 +29,8 @@ static test_result_t test_memory_send_sp(uint32_t mem_func) uint32_t sent_length; ffa_memory_handle_t handle; uint32_t *ptr; + struct mailbox_buffers mb; + const uint32_t primary_uuid[] = PRIMARY_UUID; /********************************************************************** * Verify that FFA is there and that it has the correct version. @@ -54,20 +45,18 @@ static test_result_t test_memory_send_sp(uint32_t mem_func) return TEST_RESULT_SKIPPED; } - if (!rxtx_mapped) { - ret = ffa_rxtx_map((uintptr_t)mb.send, (uintptr_t)mb.recv, 1); - - if (ret.ret0 != FFA_SUCCESS_SMC32) { - ERROR("ffa_rxtx_map failed (%lx)\n", ret.ret0); - return TEST_RESULT_FAIL; - } - rxtx_mapped = true; + if (!get_tftf_mailbox(&mb)) { + ERROR("Mailbox not configured!\n This test relies on" + " test suite \"FF-A RXTX Mapping\" to map/configure" + " RXTX buffers\n"); + return TEST_RESULT_FAIL; } + /********************************************************************** * Verify that cactus primary SP is deployed in the system. **********************************************************************/ - SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, PRIMARY_UUID); + SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, primary_uuid); struct ffa_memory_region_constituent constituents[] = { {(void *)share_page, 1, 0} diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c new file mode 100644 index 000000000..5251dc404 --- /dev/null +++ b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <debug.h> +#include <ffa_helpers.h> +#include <test_helpers.h> +#include <xlat_tables_defs.h> + +static struct mailbox_buffers mb; + +static test_result_t test_ffa_rxtx_map(uint32_t expected_return) +{ + smc_ret_values ret; + + /********************************************************************** + * Verify that FFA is there and that it has the correct version. + **********************************************************************/ + SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0); + + /********************************************************************** + * If OP-TEE is SPMC skip this test. + **********************************************************************/ + if (check_spmc_execution_level()) { + VERBOSE("OP-TEE as SPMC at S-EL1. Skipping test!\n"); + return TEST_RESULT_SKIPPED; + } + + /* + * Declare RXTX buffers, assign them to the mailbox and call + * FFA_RXTX_MAP. + */ + CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret); + if (ret.ret0 != expected_return) { + ERROR("Failed to map RXTX buffers %lx!\n", ret.ret2); + return TEST_RESULT_FAIL; + } + + return TEST_RESULT_SUCCESS; +} + +/** + * Test mapping RXTX buffers from NWd. + * This test also sets the Mailbox for other SPM related tests that need to use + * RXTX buffers. + */ +test_result_t test_ffa_rxtx_map_success(void) +{ + test_result_t ret = test_ffa_rxtx_map(FFA_SUCCESS_SMC32); + + if (ret == TEST_RESULT_SUCCESS) { + INFO("Set RXTX Mailbox for remaining spm tests!\n"); + set_tftf_mailbox(&mb); + } + return ret; +} + +/** + * Test to verify that 2nd call to FFA_RXTX_MAP should fail. + */ +test_result_t test_ffa_rxtx_map_fail(void) +{ + INFO("This test expects error log.\n"); + return test_ffa_rxtx_map(FFA_ERROR); +} diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk index ee339b5a4..c6b304adb 100644 --- a/tftf/tests/tests-spm.mk +++ b/tftf/tests/tests-spm.mk @@ -11,4 +11,5 @@ TESTS_SOURCES += \ test_ffa_version.c \ test_ffa_features.c \ test_ffa_memory_sharing.c \ + test_ffa_rxtx_map.c \ ) diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml index 85001f22a..981ce7154 100644 --- a/tftf/tests/tests-spm.xml +++ b/tftf/tests/tests-spm.xml @@ -30,6 +30,14 @@ </testsuite> + <testsuite name="FF-A RXTX Mapping" + description="Test to FF-A RXTX mapping ABI" > + <testcase name="FF-A RXTX Map API success" + function="test_ffa_rxtx_map_success" /> + <testcase name="FF-A RXTX Map API consecutive" + function="test_ffa_rxtx_map_fail" /> + </testsuite> + <testsuite name="FF-A Memory Sharing" description="Test FF-A Memory Sharing ABIs" > <testcase name="Lend Memory to Secure World" |