diff options
author | Maksims Svecovs <maksims.svecovs@arm.com> | 2021-12-10 13:08:41 +0000 |
---|---|---|
committer | Maksims Svecovs <maksims.svecovs@arm.com> | 2022-01-14 12:43:11 +0000 |
commit | a65a907146dd93557ac7aa2584cd2e6f626dd975 (patch) | |
tree | ee5608c767d3bed7f63bd9011480ed92f47deba4 | |
parent | 911fa6ba32e6284814845632e62f69b41473d81e (diff) |
refactor(ff-a): mem share helper change to test error returns
In order to test FF-A memory sharing operations in faulty cases we need
to be able to get the details of smc call failure in tftf and cactus.
Passes smc_ret_value in the relevant memory management test helpers.
Signed-off-by: Maksims Svecovs <maksims.svecovs@arm.com>
Change-Id: I81059b77cbb01fe9427905adbe262ba8d0670cee
4 files changed, 15 insertions, 14 deletions
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h index 58569d5..4ec71fc 100644 --- a/include/runtime_services/spm_common.h +++ b/include/runtime_services/spm_common.h @@ -140,13 +140,13 @@ bool memory_relinquish(struct ffa_mem_relinquish *m, uint64_t handle, ffa_memory_handle_t memory_send( struct ffa_memory_region *memory_region, uint32_t mem_func, - uint32_t fragment_length, uint32_t total_length); + uint32_t fragment_length, uint32_t total_length, smc_ret_values *ret); ffa_memory_handle_t memory_init_and_send( struct ffa_memory_region *memory_region, size_t memory_region_max_size, ffa_id_t sender, ffa_id_t receiver, const struct ffa_memory_region_constituent* constituents, - uint32_t constituents_count, uint32_t mem_func); + uint32_t constituents_count, uint32_t mem_func, smc_ret_values *ret); bool ffa_partition_info_helper(struct mailbox_buffers *mb, const struct ffa_uuid uuid, diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c index 21df55b..0248437 100644 --- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c +++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c @@ -162,7 +162,7 @@ CACTUS_CMD_HANDLER(req_mem_send_cmd, CACTUS_REQ_MEM_SEND_CMD) handle = memory_init_and_send( (struct ffa_memory_region *)mb->send, PAGE_SIZE, vm_id, receiver, constituents, - constituents_count, mem_func); + constituents_count, mem_func, &ffa_ret); /* * If returned an invalid handle, we should break the test. diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c index f6800ce..5dc1eec 100644 --- a/tftf/tests/runtime_services/secure_service/spm_common.c +++ b/tftf/tests/runtime_services/secure_service/spm_common.c @@ -439,15 +439,15 @@ bool memory_relinquish(struct ffa_mem_relinquish *m, uint64_t handle, /** * Helper to call memory send function whose func id is passed as a parameter. * Returns a valid handle in case of successful operation or - * FFA_MEMORY_HANDLE_INVALID if something goes wrong. + * FFA_MEMORY_HANDLE_INVALID if something goes wrong. Populates *ret with a + * resulting smc value to handle the error higher in the test chain. * * TODO: Do memory send with 'ffa_memory_region' taking multiple segments */ ffa_memory_handle_t memory_send( struct ffa_memory_region *memory_region, uint32_t mem_func, - uint32_t fragment_length, uint32_t total_length) + uint32_t fragment_length, uint32_t total_length, smc_ret_values *ret) { - smc_ret_values ret; ffa_id_t receiver = memory_region->receivers[0].receiver_permissions.receiver; @@ -459,25 +459,26 @@ ffa_memory_handle_t memory_send( switch (mem_func) { case FFA_MEM_SHARE_SMC32: - ret = ffa_mem_share(total_length, fragment_length); + *ret = ffa_mem_share(total_length, fragment_length); break; case FFA_MEM_LEND_SMC32: - ret = ffa_mem_lend(total_length, fragment_length); + *ret = ffa_mem_lend(total_length, fragment_length); break; case FFA_MEM_DONATE_SMC32: - ret = ffa_mem_donate(total_length, fragment_length); + *ret = ffa_mem_donate(total_length, fragment_length); break; default: + *ret = (smc_ret_values){0}; ERROR("TFTF - Invalid func id %x!\n", mem_func); return FFA_MEMORY_HANDLE_INVALID; } - if (is_ffa_call_error(ret)) { + if (is_ffa_call_error(*ret)) { ERROR("Failed to send message to: %x\n", receiver); return FFA_MEMORY_HANDLE_INVALID; } - return ffa_mem_success_handle(ret); + return ffa_mem_success_handle(*ret); } /** @@ -489,7 +490,7 @@ ffa_memory_handle_t memory_init_and_send( struct ffa_memory_region *memory_region, size_t memory_region_max_size, ffa_id_t sender, ffa_id_t receiver, const struct ffa_memory_region_constituent *constituents, - uint32_t constituents_count, uint32_t mem_func) + uint32_t constituents_count, uint32_t mem_func, smc_ret_values *ret) { uint32_t remaining_constituent_count; uint32_t total_length; @@ -517,7 +518,7 @@ ffa_memory_handle_t memory_init_and_send( } return memory_send(memory_region, mem_func, fragment_length, - total_length); + total_length, ret); } /** 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 46a7349..8c257b2 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 @@ -67,7 +67,7 @@ static test_result_t test_memory_send_sp(uint32_t mem_func) handle = memory_init_and_send((struct ffa_memory_region *)mb.send, MAILBOX_SIZE, SENDER, RECEIVER, constituents, constituents_count, - mem_func); + mem_func, &ret); if (handle == FFA_MEMORY_HANDLE_INVALID) { return TEST_RESULT_FAIL; |