aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Boulby <daniel.boulby@arm.com>2021-07-07 11:14:39 +0100
committerDaniel Boulby <daniel.boulby@arm.com>2021-08-04 17:10:42 +0100
commite06029001c18262bae8d3ef4ef8b3e66e2e3f3a1 (patch)
tree3e91db43de6ce8d00d61e1fa38d178ab161060ae
parent4ac6ab2dd092ba9e4ff61245f6974cea078838b4 (diff)
downloadtf-a-tests-e06029001c18262bae8d3ef4ef8b3e66e2e3f3a1.tar.gz
test(ff-a): add tests for the FFA_RXTX_UNMAP ABI
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com> Change-Id: Id4d8cfd2f94ff15201de70a13eececf444d5e66e
-rw-r--r--include/runtime_services/ffa_helpers.h1
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c17
-rw-r--r--tftf/tests/runtime_services/secure_service/spm_common.c2
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c69
-rw-r--r--tftf/tests/tests-spm.xml11
5 files changed, 89 insertions, 11 deletions
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index a17f115b1..c3f6294bd 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -414,6 +414,7 @@ smc_ret_values ffa_features(uint32_t feature);
smc_ret_values ffa_partition_info_get(const struct ffa_uuid uuid);
smc_ret_values ffa_rx_release(void);
smc_ret_values ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages);
+smc_ret_values ffa_rxtx_unmap(void);
smc_ret_values ffa_mem_donate(uint32_t descriptor_length,
uint32_t fragment_length);
smc_ret_values ffa_mem_lend(uint32_t descriptor_length,
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 8d043a1fb..2660edbaa 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -393,6 +393,23 @@ smc_ret_values ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages)
return tftf_smc(&args);
}
+/* Unmap the RXTX buffer allocated by the given FF-A component */
+smc_ret_values ffa_rxtx_unmap(void)
+{
+ smc_args args = {
+ .fid = FFA_RXTX_UNMAP,
+ .arg1 = FFA_PARAM_MBZ,
+ .arg2 = FFA_PARAM_MBZ,
+ .arg3 = FFA_PARAM_MBZ,
+ .arg4 = FFA_PARAM_MBZ,
+ .arg5 = FFA_PARAM_MBZ,
+ .arg6 = FFA_PARAM_MBZ,
+ .arg7 = FFA_PARAM_MBZ
+ };
+
+ return tftf_smc(&args);
+}
+
/* Donate memory to another partition */
smc_ret_values ffa_mem_donate(uint32_t descriptor_length,
uint32_t fragment_length)
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 7aa4861af..e3c786278 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -252,7 +252,7 @@ static const struct ffa_features_test ffa_feature_test_target[] = {
{"FFA_RX_RELEASE_32 check", FFA_RX_RELEASE, FFA_SUCCESS_SMC32},
{"FFA_RXTX_MAP_32 check", FFA_RXTX_MAP_SMC32, FFA_ERROR},
{"FFA_RXTX_MAP_64 check", FFA_RXTX_MAP_SMC64, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
+ {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_SUCCESS_SMC32},
{"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
{"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
{"FFA_SPM_ID_GET_32 check", FFA_SPM_ID_GET, FFA_SUCCESS_SMC32,
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
index 572db9859..990728453 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
@@ -222,18 +222,10 @@ static test_result_t test_ffa_rxtx_map(uint32_t expected_return)
/**
* 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;
+ return test_ffa_rxtx_map(FFA_SUCCESS_SMC32);
}
/**
@@ -245,6 +237,63 @@ test_result_t test_ffa_rxtx_map_fail(void)
return test_ffa_rxtx_map(FFA_ERROR);
}
+static test_result_t test_ffa_rxtx_unmap(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;
+ }
+
+ ret = ffa_rxtx_unmap();
+ if (!is_expected_ffa_return(ret, expected_return)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/**
+ * Test unmapping RXTX buffers from NWd.
+ */
+test_result_t test_ffa_rxtx_unmap_success(void)
+{
+ return test_ffa_rxtx_unmap(FFA_SUCCESS_SMC32);
+}
+
+/**
+ * Test to verify that 2nd call to FFA_RXTX_UNMAP should fail.
+ */
+test_result_t test_ffa_rxtx_unmap_fail(void)
+{
+ INFO("This test expects error log.\n");
+ return test_ffa_rxtx_unmap(FFA_ERROR);
+}
+
+/**
+ * Test mapping RXTX buffers that have been previously unmapped 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_unmapped_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;
+}
/******************************************************************************
* FF-A SPM_ID_GET ABI Tests
******************************************************************************/
@@ -308,4 +357,4 @@ test_result_t test_ffa_partition_info(void)
}
return TEST_RESULT_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 360e32d70..3e6c72c61 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -21,10 +21,21 @@
<testcase name="Smaller FFA version than SPM"
function="test_ffa_version_smaller" />
+ <!--
+ The ordering of the RXTX Buffer tests must be maintained.
+ With test_ffa_rxtx_map_unmapped_success coming last as the
+ mailbox for the remaining tftf tests is set here.
+ -->
<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" />
+ <testcase name="FF-A RXTX Unmap API success"
+ function="test_ffa_rxtx_unmap_success" />
+ <testcase name="FF-A RXTX Unmap API consecutive"
+ function="test_ffa_rxtx_unmap_fail" />
+ <testcase name="FF-A RXTX remap unmapped region success"
+ function="test_ffa_rxtx_map_unmapped_success" />
<testcase name="Test FFA_SPM_ID_GET"
function="test_ffa_spm_id_get" />