aboutsummaryrefslogtreecommitdiff
path: root/tftf/tests
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2021-02-22 12:21:44 +0000
committerJ-Alves <joao.alves@arm.com>2021-03-12 14:28:28 +0000
commit43887ec0836c35feb433c02f00678085d1513782 (patch)
tree82e110273cf355761943588bd624f2452c7303e5 /tftf/tests
parentecd307465ef642a8ab9f2bfcc56c2580e6d66a86 (diff)
downloadtf-a-tests-43887ec0836c35feb433c02f00678085d1513782.tar.gz
SPM: Helpers for error logging after FF-A calls
Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: I7c4cb416baf6eb024eb134edb4bbb62d8746629f
Diffstat (limited to 'tftf/tests')
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c2
-rw-r--r--tftf/tests/runtime_services/secure_service/spm_common.c51
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c10
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c7
-rw-r--r--tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c2
5 files changed, 54 insertions, 18 deletions
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 41dd94b11..8e7b58c6f 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -3,8 +3,6 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-
-#include <debug.h>
#include <smccc.h>
#include <ffa_endpoints.h>
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 7e54a3add..12b70a9a2 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -13,6 +13,52 @@
#define STR(x) __STR(x)
#define SIMD_TWO_VECTORS_BYTES_STR (2 * SIMD_VECTOR_LEN_BYTES)
+/**
+ * Helper to log errors after FF-A calls.
+ */
+bool is_ffa_call_error(smc_ret_values ret)
+{
+ if (ffa_func_id(ret) == FFA_ERROR) {
+ ERROR("FF-A call returned error (%x): %d\n",
+ ffa_func_id(ret), ffa_error_code(ret));
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Helper to verify return of FF-A call is an FFA_MSG_SEND_DIRECT_RESP.
+ * Should be used after FFA_MSG_SEND_DIRECT_REQ, or after sending a test command
+ * to an SP.
+ */
+bool is_ffa_direct_response(smc_ret_values ret)
+{
+ if ((ffa_func_id(ret) == FFA_MSG_SEND_DIRECT_RESP_SMC32) ||
+ (ffa_func_id(ret) == FFA_MSG_SEND_DIRECT_RESP_SMC64)) {
+ return true;
+ }
+
+ ERROR("%x is not FF-A response.\n", ffa_func_id(ret));
+ /* To log error in case it is FFA_ERROR*/
+ is_ffa_call_error(ret);
+
+ return false;
+}
+
+/**
+ * Helper to check the return value of FF-A call is as expected.
+ */
+bool is_expected_ffa_return(smc_ret_values ret, uint32_t func_id)
+{
+ if (ffa_func_id(ret) == func_id) {
+ return true;
+ }
+
+ ERROR("Expecting %x, FF-A return was %x\n", func_id, ffa_func_id(ret));
+
+ return false;
+}
+
void fill_simd_vector_regs(const simd_vector_t v[SIMD_NUM_VECTORS])
{
#ifdef __aarch64__
@@ -275,9 +321,8 @@ ffa_memory_handle_t memory_send(
return FFA_MEMORY_HANDLE_INVALID;
}
- if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
- ERROR("Failed to send memory to %x, error: %x.\n",
- receiver, ffa_error_code(ret));
+ if (is_ffa_call_error(ret)) {
+ ERROR("Failed to send message to: %x\n", receiver);
return FFA_MEMORY_HANDLE_INVALID;
}
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 72daae46f..83510b063 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
@@ -29,9 +29,11 @@ static test_result_t send_cactus_echo_cmd(ffa_vm_id_t sender,
smc_ret_values ret;
ret = cactus_echo_send_cmd(sender, dest, value);
+ /*
+ * Return responses may be FFA_MSG_SEND_DIRECT_RESP or FFA_INTERRUPT,
+ * but only expect the former. Expect SMC32 convention from SP.
+ */
if (!is_ffa_direct_response(ret)) {
- ERROR("Failed to send message. error: %x\n",
- ffa_error_code(ret));
return TEST_RESULT_FAIL;
}
@@ -95,8 +97,6 @@ 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 (!is_ffa_direct_response(ret)) {
- ERROR("Failed to send message. error: %x\n",
- ffa_error_code(ret));
return TEST_RESULT_FAIL;
}
@@ -147,8 +147,6 @@ 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 (!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 61b6edd5e..f126c57d6 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
@@ -10,6 +10,7 @@
#include <ffa_endpoints.h>
#include <test_helpers.h>
#include <tftf_lib.h>
+#include <spm_common.h>
#include <xlat_tables_defs.h>
#define MAILBOX_SIZE PAGE_SIZE
@@ -80,8 +81,6 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
ret = cactus_mem_send_cmd(SENDER, RECEIVER, mem_func, handle);
if (!is_ffa_direct_response(ret)) {
- ERROR("Failed to send message. error: %x\n",
- ffa_error_code(ret));
return TEST_RESULT_FAIL;
}
@@ -103,7 +102,7 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
(void)ptr;
if (mem_func != FFA_MEM_DONATE_SMC32 &&
- ffa_mem_reclaim(handle, 0).ret0 == FFA_ERROR) {
+ is_ffa_call_error(ffa_mem_reclaim(handle, 0))) {
tftf_testcase_printf("Couldn't reclaim memory\n");
return TEST_RESULT_FAIL;
}
@@ -145,8 +144,6 @@ static test_result_t test_req_mem_send_sp_to_sp(uint32_t mem_func,
receiver_sp);
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 8ce4cc3b4..f57fa243b 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
@@ -56,8 +56,6 @@ test_result_t test_simd_vectors_preserved(void)
smc_ret_values ret = cactus_req_simd_fill_send_cmd(SENDER, RECEIVER);
if (!is_ffa_direct_response(ret)) {
- ERROR("Failed to send message. error: %x\n",
- ffa_error_code(ret));
return TEST_RESULT_FAIL;
}