aboutsummaryrefslogtreecommitdiff
path: root/tftf
diff options
context:
space:
mode:
authorOlivier Deprez <olivier.deprez@arm.com>2021-01-21 09:51:46 +0000
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2021-01-21 09:51:46 +0000
commit52387275bd4ab47aecaf101526e683134e0440fb (patch)
treec18ba143f8645d87d99e3c3f846b6eee4366503c /tftf
parent8ff475d61c03bfbca18fcfa6135de777daaf3ac8 (diff)
parentae95ac96aa21b40d70efa29d0bc1372ecba1bb42 (diff)
downloadtf-a-tests-52387275bd4ab47aecaf101526e683134e0440fb.tar.gz
Merge changes from topic "sp_to_sp_comm"
* changes: TFTF: SP-to-SP direct messaging deadlock test cactus: testing deadlock by FF-A direct message TFTF: trigger direct messaging between SPs cactus: handle 'CACTUS_REQ_ECHO_CMD' and 'CACTUS_ECHO_CMD' cactus: add commands CACTUS_ECHO_CMD and CACTUS_REQ_ECHO_CMD
Diffstat (limited to 'tftf')
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c112
-rw-r--r--tftf/tests/tests-spm.xml22
2 files changed, 111 insertions, 23 deletions
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
index d00793abe..aeeb19b10 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
@@ -5,17 +5,27 @@
*/
#include <arch_helpers.h>
-#include <cactus_def.h>
+#include <cactus_test_cmds.h>
+#include <debug.h>
+#include <ffa_endpoints.h>
#include <platform.h>
#include <smccc.h>
#include <ffa_helpers.h>
#include <ffa_svc.h>
#include <test_helpers.h>
+#define ECHO_VAL1 U(0xa0a0a0a0)
+#define ECHO_VAL2 U(0xb0b0b0b0)
+#define ECHO_VAL3 U(0xc0c0c0c0)
+
#define DIRECT_MSG_TEST_PATTERN1 (0xaaaa0000)
#define DIRECT_MSG_TEST_PATTERN2 (0xbbbb0000)
#define DIRECT_MSG_TEST_PATTERN3 (0xcccc0000)
+static const struct ffa_uuid expected_sp_uuids[] = {
+ {PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}
+ };
+
static test_result_t send_receive_direct_msg(unsigned int sp_id,
unsigned int test_pattern)
{
@@ -50,21 +60,9 @@ test_result_t test_ffa_direct_messaging(void)
test_result_t result;
/**********************************************************************
- * Verify that FFA is there and that it has the correct version.
+ * Check SPMC has ffa_version and expected FFA endpoints are deployed.
**********************************************************************/
- SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
-
- /* Check if SPMC is OP-TEE at S-EL1 */
- if (check_spmc_execution_level()) {
- /* Direct messaging is successfully verified for OP-TEE */
- return TEST_RESULT_SUCCESS;
- }
-
- /*
- * From this point assume SPMC runs at S-EL2 and two Cactus instances
- * are loaded at S-EL1.
- *
- */
+ CHECK_HAFNIUM_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids);
/**********************************************************************
* Send a message to SP1 through direct messaging
@@ -89,3 +87,87 @@ test_result_t test_ffa_direct_messaging(void)
return result;
}
+
+/**
+ * The 'send_cactus_req_echo_cmd' sends a CACTUS_REQ_ECHO_CMD to a cactus SP.
+ * Handling this command, cactus should then send CACTUS_ECHO_CMD to
+ * the specified SP according to 'echo_dest'. If the CACTUS_ECHO_CMD is resolved
+ * successfully, cactus will reply to tftf with CACTUS_SUCCESS, or CACTUS_ERROR
+ * otherwise.
+ * For the CACTUS_SUCCESS response, the test returns TEST_RESULT_SUCCESS.
+ */
+static test_result_t send_cactus_req_echo_cmd(ffa_vm_id_t sender,
+ ffa_vm_id_t dest,
+ ffa_vm_id_t echo_dest,
+ uint64_t value)
+{
+ smc_ret_values ret;
+
+ ret = CACTUS_REQ_ECHO_SEND_CMD(sender, dest, echo_dest, value);
+
+ if (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %lx\n",
+ ret.ret2);
+ return TEST_RESULT_FAIL;
+ }
+
+ if (CACTUS_GET_RESPONSE(ret) == CACTUS_ERROR) {
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+test_result_t test_ffa_sp_to_sp_direct_messaging(void)
+{
+ test_result_t result;
+
+ CHECK_HAFNIUM_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids);
+
+ result = send_cactus_req_echo_cmd(HYP_ID, SP_ID(1), SP_ID(2),
+ ECHO_VAL1);
+ if (result != TEST_RESULT_SUCCESS) {
+ return result;
+ }
+
+ /*
+ * The following the tests are intended to test the handling of a
+ * direct message request with a VM's ID as a the sender.
+ */
+ result = send_cactus_req_echo_cmd(HYP_ID + 1, SP_ID(2), SP_ID(3),
+ ECHO_VAL2);
+ if (result != TEST_RESULT_SUCCESS) {
+ return result;
+ }
+
+ result = send_cactus_req_echo_cmd(HYP_ID + 2, SP_ID(3), SP_ID(1),
+ ECHO_VAL3);
+
+ return result;
+}
+
+test_result_t test_ffa_sp_to_sp_deadlock(void)
+{
+ smc_ret_values ret;
+
+ /**********************************************************************
+ * Check SPMC has ffa_version and expected FFA endpoints are deployed.
+ **********************************************************************/
+ CHECK_HAFNIUM_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids);
+
+ ret = CACTUS_REQ_DEADLOCK_SEND_CMD(HYP_ID, SP_ID(1), SP_ID(2),
+ SP_ID(3));
+
+ if (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %lx\n",
+ ret.ret2);
+ return TEST_RESULT_FAIL;
+ }
+
+ if (CACTUS_GET_RESPONSE(ret) == CACTUS_ERROR) {
+ ERROR("cactus SP response is CACTUS_ERROR!\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 5e10f5338..14be8ca5a 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -22,14 +22,6 @@
</testsuite>
- <testsuite name="FF-A Direct messaging"
- description="Test FF-A Direct messaging ABI" >
-
- <testcase name="FF-A direct messaging API"
- function="test_ffa_direct_messaging" />
-
- </testsuite>
-
<testsuite name="FF-A RXTX Mapping"
description="Test to FF-A RXTX mapping ABI" >
<testcase name="FF-A RXTX Map API success"
@@ -38,6 +30,20 @@
function="test_ffa_rxtx_map_fail" />
</testsuite>
+ <testsuite name="FF-A Direct messaging"
+ description="Test FF-A Direct messaging" >
+
+ <testcase name="FF-A direct messaging"
+ function="test_ffa_direct_messaging" />
+
+ <testcase name="FF-A Request SP-to-SP direct messaging"
+ function="test_ffa_sp_to_sp_direct_messaging" />
+
+ <testcase name="FF-A Request SP-to-SP direct messaging deadlock"
+ function="test_ffa_sp_to_sp_deadlock" />
+
+ </testsuite>
+
<testsuite name="FF-A Memory Sharing"
description="Test FF-A Memory Sharing ABIs" >
<testcase name="Lend Memory to Secure World"