aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Deprez <olivier.deprez@arm.com>2021-03-11 10:25:39 +0100
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2021-03-11 10:25:39 +0100
commiteb426de964d74d12d7fe85edb448430753819fda (patch)
tree9f8f201b56113dbcf13685d267d996d61ac99e8f
parentf804cbb00c29feadd7a37d092965074ccd4df4b7 (diff)
parent6cb21d985c25383baf105afbd17d52d43006990d (diff)
downloadtf-a-tests-eb426de964d74d12d7fe85edb448430753819fda.tar.gz
Merge "FF-A: Accessors for arguments from FF-A calls"
-rw-r--r--include/runtime_services/ffa_helpers.h17
-rw-r--r--spm/cactus/cactus_ffa_tests.c25
-rw-r--r--spm/cactus/cactus_main.c61
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c6
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c18
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_features.c16
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c11
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c4
-rw-r--r--tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c5
9 files changed, 93 insertions, 70 deletions
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index caeaa9e0..02a956e8 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -39,6 +39,14 @@ struct ffa_partition_info {
uint32_t properties;
};
+static inline uint32_t ffa_func_id(smc_ret_values val) {
+ return (uint32_t) val.ret0;
+}
+
+static inline int32_t ffa_error_code(smc_ret_values val) {
+ return (int32_t) val.ret2;
+}
+
enum ffa_data_access {
FFA_DATA_ACCESS_NOT_SPECIFIED,
FFA_DATA_ACCESS_RO,
@@ -366,8 +374,15 @@ ffa_memory_handle_t ffa_memory_init_and_send(
const struct ffa_memory_region_constituent* constituents,
uint32_t constituents_count, uint32_t mem_func);
+static inline ffa_vm_id_t ffa_dir_msg_dest(smc_ret_values val) {
+ return (ffa_vm_id_t)val.ret1 & U(0xFFFF);
+}
+
+static inline ffa_vm_id_t ffa_dir_msg_source(smc_ret_values val) {
+ return (ffa_vm_id_t)(val.ret1 >> 16U);
+}
+
smc_ret_values ffa_msg_send_direct_req(uint32_t source_id, uint32_t dest_id, uint32_t message);
-smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id, uint64_t message);
smc_ret_values ffa_msg_send_direct_req64_5args(uint32_t source_id, uint32_t dest_id,
uint64_t arg0, uint64_t arg1,
uint64_t arg2, uint64_t arg3,
diff --git a/spm/cactus/cactus_ffa_tests.c b/spm/cactus/cactus_ffa_tests.c
index 8e9605d5..032d2e2e 100644
--- a/spm/cactus/cactus_ffa_tests.c
+++ b/spm/cactus/cactus_ffa_tests.c
@@ -59,9 +59,9 @@ static void ffa_features_test(void)
announce_test_start(ffa_feature_test_target[i].test_name);
ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
- expect(ffa_ret.ret0, ffa_feature_test_target[i].expected_ret);
+ expect(ffa_func_id(ffa_ret), ffa_feature_test_target[i].expected_ret);
if (ffa_feature_test_target[i].expected_ret == FFA_ERROR) {
- expect(ffa_ret.ret2, FFA_ERROR_NOT_SUPPORTED);
+ expect(ffa_error_code(ffa_ret), FFA_ERROR_NOT_SUPPORTED);
}
announce_test_end(ffa_feature_test_target[i].test_name);
@@ -76,7 +76,7 @@ static void ffa_partition_info_helper(struct mailbox_buffers *mb, const uint32_t
{
smc_ret_values ret = ffa_partition_info_get(uuid);
unsigned int i;
- expect(ret.ret0, FFA_SUCCESS_SMC32);
+ expect(ffa_func_id(ret), FFA_SUCCESS_SMC32);
struct ffa_partition_info *info = (struct ffa_partition_info *)(mb->recv);
for (i = 0U; i < expected_size; i++) {
@@ -86,7 +86,7 @@ static void ffa_partition_info_helper(struct mailbox_buffers *mb, const uint32_t
}
ret = ffa_rx_release();
- expect(ret.ret0, FFA_SUCCESS_SMC32);
+ expect(ffa_func_id(ret), FFA_SUCCESS_SMC32);
}
static void ffa_partition_info_wrong_test(void)
@@ -97,8 +97,8 @@ static void ffa_partition_info_wrong_test(void)
announce_test_start(test_wrong_uuid);
smc_ret_values ret = ffa_partition_info_get(uuid);
- expect(ret.ret0, FFA_ERROR);
- expect(ret.ret2, FFA_ERROR_INVALID_PARAMETER);
+ expect(ffa_func_id(ret), FFA_ERROR);
+ expect(ffa_error_code(ret), FFA_ERROR_INVALID_PARAMETER);
announce_test_end(test_wrong_uuid);
}
@@ -209,7 +209,7 @@ bool ffa_memory_retrieve_test(struct mailbox_buffers *mb,
ret = ffa_mem_retrieve_req(descriptor_size, descriptor_size);
- if (ret.ret0 != FFA_MEM_RETRIEVE_RESP) {
+ if (ffa_func_id(ret) != FFA_MEM_RETRIEVE_RESP) {
ERROR("Couldn't retrieve the memory page. Error: %lx\n",
ret.ret2);
return false;
@@ -254,10 +254,13 @@ bool ffa_memory_relinquish_test(struct ffa_mem_relinquish *m,
uint64_t handle,
ffa_vm_id_t id)
{
- ffa_mem_relinquish_init(m, handle, 0, id);
+ smc_ret_values ret;
- if (ffa_mem_relinquish().ret0 != FFA_SUCCESS_SMC32) {
- ERROR("%s failed to relinquish memory!\n", __func__);
+ ffa_mem_relinquish_init(m, handle, 0, id);
+ ret = ffa_mem_relinquish();
+ if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
+ ERROR("%s failed to relinquish memory! error: %x\n",
+ __func__, ffa_error_code(ret));
return false;
}
@@ -331,7 +334,7 @@ void ffa_memory_management_test(struct mailbox_buffers *mb, ffa_vm_id_t vm_id,
true);
}
- expect(ffa_rx_release().ret0, FFA_SUCCESS_SMC32);
+ expect(ffa_func_id(ffa_rx_release()), FFA_SUCCESS_SMC32);
announce_test_section_end(test_ffa);
}
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 87ef8371..11d7b995 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -57,27 +57,27 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
ffa_ret = ffa_msg_wait();
for (;;) {
- VERBOSE("Woke up with func id: %lx\n", ffa_ret.ret0);
+ VERBOSE("Woke up with func id: %x\n", ffa_func_id(ffa_ret));
- if (ffa_ret.ret0 == FFA_ERROR) {
- ERROR("Error: %lx\n", ffa_ret.ret2);
+ if (ffa_func_id(ffa_ret) == FFA_ERROR) {
+ ERROR("Error: %x\n", ffa_error_code(ffa_ret));
break;
}
- if (ffa_ret.ret0 != FFA_MSG_SEND_DIRECT_REQ_SMC32 &&
- ffa_ret.ret0 != FFA_MSG_SEND_DIRECT_REQ_SMC64) {
- ERROR("%s(%u) unknown func id 0x%lx\n",
- __func__, vm_id, ffa_ret.ret0);
+ if (ffa_func_id(ffa_ret) != FFA_MSG_SEND_DIRECT_REQ_SMC32 &&
+ ffa_func_id(ffa_ret) != FFA_MSG_SEND_DIRECT_REQ_SMC64) {
+ ERROR("%s(%u) unknown func id 0x%x\n",
+ __func__, vm_id, ffa_func_id(ffa_ret));
break;
}
- destination = ffa_ret.ret1 & U(0xFFFF);
+ destination = ffa_dir_msg_dest(ffa_ret);
- source = ffa_ret.ret1 >> 16;
+ source = ffa_dir_msg_source(ffa_ret);
if (destination != vm_id) {
- ERROR("%s(%u) invalid vm id 0x%lx\n",
- __func__, vm_id, ffa_ret.ret1);
+ ERROR("%s(%u) invalid vm id 0x%x\n",
+ __func__, vm_id, destination);
break;
}
@@ -134,9 +134,10 @@ 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_ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n",
- ffa_ret.ret2);
+ if (ffa_func_id(ffa_ret) !=
+ FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %x\n",
+ ffa_error_code(ffa_ret));
ffa_ret = cactus_error_resp(vm_id, source);
break;
}
@@ -188,9 +189,9 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
{
uint64_t echo_val = cactus_echo_get_val(ffa_ret);
- VERBOSE("Received echo at %x, value %llx.\n",
- destination, echo_val);
- ffa_ret = cactus_response(vm_id, source, echo_val);
+ VERBOSE("Received echo at %x, value %llx from %x.\n",
+ destination, echo_val, source);
+ ffa_ret = cactus_response(destination, source, echo_val);
break;
}
case CACTUS_REQ_ECHO_CMD:
@@ -206,9 +207,10 @@ 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_ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n",
- ffa_ret.ret2);
+ if (ffa_func_id(ffa_ret) !=
+ FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %x\n",
+ ffa_error_code(ffa_ret));
success = false;
}
@@ -248,8 +250,8 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
* an FF-A direct message, to the first partition.
*/
bool is_deadlock_detected =
- (ffa_ret.ret0 == FFA_ERROR) &&
- (ffa_ret.ret2 == FFA_ERROR_BUSY);
+ (ffa_func_id(ffa_ret) == FFA_ERROR) &&
+ (ffa_error_code(ffa_ret) == FFA_ERROR_BUSY);
/*
* Should be true after the deadlock has been detected
@@ -257,13 +259,14 @@ static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
* request chain.
*/
bool is_returning_from_deadlock =
- (ffa_ret.ret0 == FFA_MSG_SEND_DIRECT_RESP_SMC32)
+ (ffa_func_id(ffa_ret) ==
+ FFA_MSG_SEND_DIRECT_RESP_SMC32)
&&
(cactus_get_response(ffa_ret) == CACTUS_SUCCESS);
if (is_deadlock_detected) {
- NOTICE("Attempting dealock but got error %lx\n",
- ffa_ret.ret2);
+ NOTICE("Attempting dealock but got error %x\n",
+ ffa_error_code(ffa_ret));
}
if (is_deadlock_detected ||
@@ -390,7 +393,7 @@ void __dead2 cactus_main(void)
/* Get current FFA id */
smc_ret_values ffa_id_ret = ffa_id_get();
- if (ffa_id_ret.ret0 != FFA_SUCCESS_SMC32) {
+ if (ffa_func_id(ffa_id_ret) != FFA_SUCCESS_SMC32) {
ERROR("FFA_ID_GET failed.\n");
panic();
}
@@ -422,10 +425,10 @@ void __dead2 cactus_main(void)
if (ffa_id == (SPM_VM_ID_FIRST + 2)) {
VERBOSE("Mapping RXTX Region\n");
CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
- if (ret.ret0 != FFA_SUCCESS_SMC32) {
+ if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
ERROR(
- "Failed to map RXTX buffers. Error: %lx\n",
- ret.ret2);
+ "Failed to map RXTX buffers. Error: %x\n",
+ ffa_error_code(ret));
panic();
}
}
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 7d94d278..923ee2c9 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -304,9 +304,9 @@ ffa_memory_handle_t ffa_memory_send(
return FFA_MEMORY_HANDLE_INVALID;
}
- if (ret.ret0 != FFA_SUCCESS_SMC32) {
- ERROR("Failed to send memory to %x, error: %lx.\n",
- receiver, ret.ret2);
+ if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
+ ERROR("Failed to send memory to %x, error: %x.\n",
+ receiver, ffa_error_code(ret));
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 3bdacda9..12954426 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,9 +38,9 @@ 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 (ret_values.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- tftf_testcase_printf("ffa_msg_send_direct_req returned %lx\n",
- (u_register_t)ret_values.ret0);
+ if (ffa_func_id(ret_values) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ tftf_testcase_printf("ffa_msg_send_direct_req returned %x\n",
+ ffa_func_id(ret_values));
return TEST_RESULT_FAIL;
}
@@ -105,9 +105,9 @@ 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 (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n",
- ret.ret2);
+ if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %x\n",
+ ffa_error_code(ret));
return TEST_RESULT_FAIL;
}
@@ -157,9 +157,9 @@ 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 (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n",
- ret.ret2);
+ if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ 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_features.c b/tftf/tests/runtime_services/secure_service/test_ffa_features.c
index beee5d23..e4cd845f 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_features.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_features.c
@@ -25,20 +25,20 @@ test_result_t test_ffa_features(void)
for (i = 0U; i < test_target_size; i++) {
ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
- if (ffa_ret.ret0 != ffa_feature_test_target[i].expected_ret) {
- tftf_testcase_printf("%s returned %lx, expected %x\n",
+ if (ffa_func_id(ffa_ret) != ffa_feature_test_target[i].expected_ret) {
+ tftf_testcase_printf("%s returned %x, expected %x\n",
ffa_feature_test_target[i].test_name,
- ffa_ret.ret0,
+ ffa_func_id(ffa_ret),
ffa_feature_test_target[i].expected_ret);
return TEST_RESULT_FAIL;
}
- if ((ffa_feature_test_target[i].expected_ret == (u_register_t)FFA_ERROR) &&
- (ffa_ret.ret2 != (u_register_t)FFA_ERROR_NOT_SUPPORTED)) {
+ if ((ffa_feature_test_target[i].expected_ret == FFA_ERROR) &&
+ (ffa_error_code(ffa_ret) != FFA_ERROR_NOT_SUPPORTED)) {
tftf_testcase_printf("%s failed for the wrong reason: "
- "returned %lx, expected %lx\n",
+ "returned %x, expected %x\n",
ffa_feature_test_target[i].test_name,
- ffa_ret.ret2,
- (u_register_t)FFA_ERROR_NOT_SUPPORTED);
+ ffa_error_code(ffa_ret),
+ FFA_ERROR_NOT_SUPPORTED);
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 5b59c439..05a8b591 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,9 +79,9 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
ret = cactus_mem_send_cmd(SENDER, RECEIVER, mem_func, handle);
- if (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n",
- ret.ret2);
+ if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %x\n",
+ ffa_error_code(ret));
return TEST_RESULT_FAIL;
}
@@ -144,8 +144,9 @@ 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 (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n", ret.ret2);
+ if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ 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_rxtx_map.c b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
index 1e4c4e06..1b47c5f9 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
@@ -33,8 +33,8 @@ static test_result_t test_ffa_rxtx_map(uint32_t expected_return)
* FFA_RXTX_MAP.
*/
CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
- if (ret.ret0 != expected_return) {
- ERROR("Failed to map RXTX buffers %lx!\n", ret.ret2);
+ if (ffa_func_id(ret) != expected_return) {
+ ERROR("Failed to map RXTX buffers %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 3b3edba8..c6470c14 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,8 +55,9 @@ test_result_t test_simd_vectors_preserved(void)
smc_ret_values ret = cactus_req_simd_fill_send_cmd(SENDER, RECEIVER);
- if (ret.ret0 != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
- ERROR("Failed to send message. error: %lx\n", ret.ret2);
+ if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_RESP_SMC32) {
+ ERROR("Failed to send message. error: %x\n",
+ ffa_error_code(ret));
return TEST_RESULT_FAIL;
}