aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2021-02-11 15:17:42 +0000
committerJ-Alves <joao.alves@arm.com>2021-03-11 09:29:16 +0000
commit06373c564bbdca87b0043f8f0a4b0f047d6a7457 (patch)
tree87322ef74cf4dfb6f2411050339223adff307b19
parent035b7d06c41d2eaf69ea86b1b23ee9fedddc4187 (diff)
downloadtf-a-tests-06373c564bbdca87b0043f8f0a4b0f047d6a7457.tar.gz
FF-A: Check FF-A return is a valid direct response
Added a helper function to check if return of FFA_MSG_SEND_DIRECT_REQ is FFA_MSG_SEND_DIRECT_RESP. This is intended to make it easier to maintain cactus test commands framework. Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: Ia43e88908aa3cbdd529a8835bffe43dee3e04a76
-rw-r--r--include/runtime_services/ffa_helpers.h6
-rw-r--r--spm/cactus/cactus_main.c9
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c6
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c4
-rw-r--r--tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c2
5 files changed, 15 insertions, 12 deletions
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 2422abbf..17587b3b 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -396,6 +396,12 @@ smc_ret_values ffa_msg_send_direct_resp64_5args(ffa_vm_id_t source_id,
uint64_t arg3,
uint64_t arg4);
+static inline bool is_ffa_direct_response(smc_ret_values ret)
+{
+ return (ffa_func_id(ret) == FFA_MSG_SEND_DIRECT_RESP_SMC32) ||
+ (ffa_func_id(ret) == FFA_MSG_SEND_DIRECT_RESP_SMC64);
+}
+
smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id);
smc_ret_values ffa_version(uint32_t input_version);
smc_ret_values ffa_id_get(void);
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 11d7b995..cb83d876 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -134,8 +134,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
ffa_ret = cactus_mem_send_cmd(vm_id, receiver, mem_func,
handle);
- if (ffa_func_id(ffa_ret) !=
- FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ffa_ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ffa_ret));
ffa_ret = cactus_error_resp(vm_id, source);
@@ -207,8 +206,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
ffa_ret = cactus_echo_send_cmd(vm_id, echo_dest,
echo_val);
- if (ffa_func_id(ffa_ret) !=
- FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ffa_ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ffa_ret));
success = false;
@@ -259,8 +257,7 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
* request chain.
*/
bool is_returning_from_deadlock =
- (ffa_func_id(ffa_ret) ==
- FFA_MSG_SEND_DIRECT_RESP_SMC32)
+ (is_ffa_direct_response(ffa_ret))
&&
(cactus_get_response(ffa_ret) == CACTUS_SUCCESS);
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 12954426..50e85825 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
@@ -38,7 +38,7 @@ static test_result_t send_receive_direct_msg(unsigned int sp_id,
* Return responses may be FFA_MSG_SEND_DIRECT_RESP or FFA_INTERRUPT,
* but only expect the former. Expect SMC32 convention from SP.
*/
- if (ffa_func_id(ret_values) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret_values)) {
tftf_testcase_printf("ffa_msg_send_direct_req returned %x\n",
ffa_func_id(ret_values));
return TEST_RESULT_FAIL;
@@ -105,7 +105,7 @@ static test_result_t send_cactus_req_echo_cmd(ffa_vm_id_t sender,
ret = cactus_req_echo_send_cmd(sender, dest, echo_dest, value);
- if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ret));
return TEST_RESULT_FAIL;
@@ -157,7 +157,7 @@ test_result_t test_ffa_sp_to_sp_deadlock(void)
ret = cactus_req_deadlock_send_cmd(HYP_ID, SP_ID(1), SP_ID(2), SP_ID(3));
- if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ret));
return TEST_RESULT_FAIL;
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 05a8b591..67ffb53b 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
@@ -79,7 +79,7 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
ret = cactus_mem_send_cmd(SENDER, RECEIVER, mem_func, handle);
- if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ret));
return TEST_RESULT_FAIL;
@@ -144,7 +144,7 @@ static test_result_t test_req_mem_send_sp_to_sp(uint32_t mem_func,
ret = cactus_req_mem_send_send_cmd(HYP_ID, sender_sp, mem_func,
receiver_sp);
- if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ret));
return TEST_RESULT_FAIL;
diff --git a/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c b/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
index c6470c14..8ce4cc3b 100644
--- a/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
+++ b/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
@@ -55,7 +55,7 @@ test_result_t test_simd_vectors_preserved(void)
smc_ret_values ret = cactus_req_simd_fill_send_cmd(SENDER, RECEIVER);
- if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ if (!is_ffa_direct_response(ret)) {
ERROR("Failed to send message. error: %x\n",
ffa_error_code(ret));
return TEST_RESULT_FAIL;