aboutsummaryrefslogtreecommitdiff
path: root/tftf
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2020-11-02 17:28:20 +0000
committerJ-Alves <joao.alves@arm.com>2020-12-10 18:06:50 +0000
commitf1126f2b7ea4327b70957719de74c4af6fea72df (patch)
tree29393cf3417d2cd5ae5f1d3f6d2a4d1b5a268556 /tftf
parentc031cc08ebd9948bb8b42423c13f9257cd4bafb9 (diff)
downloadtf-a-tests-f1126f2b7ea4327b70957719de74c4af6fea72df.tar.gz
SPM: RXTX map test on TFTF
Some FF-A interfaces use RXTX buffers to exchange information with SPMC. To avoid repetition of RXTX mapping across the spm-related tests, and prevent allocation of multiple pages for RXTX buffers within TFTF runtime: - Implemented test helpers that hold address of RXTX buffers; - Implemented test to FFA_RXTX_MAP ABI, that also sets value of RXTX buffers; - Cleaned up memory sharing tests that previously implemented RXTX mapping. Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: I4a67982d3d185bf83809156e4fce03c6edb967d9
Diffstat (limited to 'tftf')
-rw-r--r--tftf/tests/common/test_helpers.c21
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c26
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c67
-rw-r--r--tftf/tests/tests-spm.mk1
-rw-r--r--tftf/tests/tests-spm.xml8
5 files changed, 103 insertions, 20 deletions
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index 8fdfdedc..b1868cd4 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,19 @@ 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;
+}
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 0ae8a8d3..6e73161f 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,7 @@ 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;
/**********************************************************************
* Verify that FFA is there and that it has the correct version.
@@ -54,16 +44,14 @@ 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.
**********************************************************************/
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 00000000..5251dc40
--- /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 ee339b5a..c6b304ad 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 85001f22..981ce715 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"