diff options
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c | 86 | ||||
-rw-r--r-- | tftf/tests/tests-spm.xml | 19 |
2 files changed, 82 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..7484cc7ca 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,61 @@ 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; +} diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml index 5e10f5338..d665b5a3a 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,17 @@ 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" /> + + </testsuite> + <testsuite name="FF-A Memory Sharing" description="Test FF-A Memory Sharing ABIs" > <testcase name="Lend Memory to Secure World" |