diff options
author | Maksims Svecovs <maksims.svecovs@arm.com> | 2021-12-14 12:01:45 +0000 |
---|---|---|
committer | Maksims Svecovs <maksims.svecovs@arm.com> | 2022-01-14 12:43:53 +0000 |
commit | 61740652496f48c7cf91db4aea1e5e4e761bda5b (patch) | |
tree | fca6e8f208feee65f41b9280e1415dcca90fcf6b | |
parent | a65a907146dd93557ac7aa2584cd2e6f626dd975 (diff) |
test(ff-a): test SP to NS-endpoint mem lend/share
Memory sharing/lending from SP to NS-endpoint is not allowed. Checks
that the said operations are denied by SPMC.
Signed-off-by: Maksims Svecovs <maksims.svecovs@arm.com>
Change-Id: I86f3bd637711735b40de9a169e2b3c934d32f1be
-rw-r--r-- | spm/cactus/cactus_tests/cactus_test_memory_sharing.c | 4 | ||||
-rw-r--r-- | tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c | 48 | ||||
-rw-r--r-- | tftf/tests/tests-spm.xml | 4 |
3 files changed, 54 insertions, 2 deletions
diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c index 0248437..ebca665 100644 --- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c +++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c @@ -168,9 +168,9 @@ CACTUS_CMD_HANDLER(req_mem_send_cmd, CACTUS_REQ_MEM_SEND_CMD) * If returned an invalid handle, we should break the test. */ if (handle == FFA_MEMORY_HANDLE_INVALID) { - ERROR("Received an invalid FF-A memory Handle!\n"); + VERBOSE("Received an invalid FF-A memory Handle!\n"); return cactus_error_resp(vm_id, source, - CACTUS_ERROR_TEST); + ffa_error_code(ffa_ret)); } ffa_ret = cactus_mem_send_cmd(vm_id, receiver, mem_func, handle); 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 8c257b2..e28c652 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 @@ -148,12 +148,48 @@ static test_result_t test_req_mem_send_sp_to_sp(uint32_t mem_func, } if (cactus_get_response(ret) == CACTUS_ERROR) { + ERROR("Failed sharing memory between SPs. Error code: %d\n", + cactus_error_code(ret)); return TEST_RESULT_FAIL; } return TEST_RESULT_SUCCESS; } +/* + * Test requests a memory send operation from SP to VM. + * The tests expects cactus to reply CACTUS_ERROR, providing FF-A error code of + * the last memory send FF-A call that cactus performed. + */ +static test_result_t test_req_mem_send_sp_to_vm(uint32_t mem_func, + ffa_id_t sender_sp, + ffa_id_t receiver_vm) +{ + smc_ret_values ret; + + /********************************************************************** + * Check if SPMC's ffa_version and presence of expected FF-A endpoints. + *********************************************************************/ + CHECK_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids); + + ret = cactus_req_mem_send_send_cmd(HYP_ID, sender_sp, mem_func, + receiver_vm); + + if (!is_ffa_direct_response(ret)) { + return TEST_RESULT_FAIL; + } + + if (cactus_get_response(ret) == CACTUS_ERROR && + cactus_error_code(ret) == FFA_ERROR_DENIED) { + return TEST_RESULT_SUCCESS; + } + + tftf_testcase_printf("Did not get the expected error, " + "mem send returned with %d\n", + cactus_get_response(ret)); + return TEST_RESULT_FAIL; +} + test_result_t test_req_mem_share_sp_to_sp(void) { return test_req_mem_send_sp_to_sp(FFA_MEM_SHARE_SMC32, SP_ID(3), @@ -171,3 +207,15 @@ test_result_t test_req_mem_donate_sp_to_sp(void) return test_req_mem_send_sp_to_sp(FFA_MEM_DONATE_SMC32, SP_ID(1), SP_ID(3)); } + +test_result_t test_req_mem_share_sp_to_vm(void) +{ + return test_req_mem_send_sp_to_vm(FFA_MEM_SHARE_SMC32, SP_ID(1), + HYP_ID); +} + +test_result_t test_req_mem_lend_sp_to_vm(void) +{ + return test_req_mem_send_sp_to_vm(FFA_MEM_LEND_SMC32, SP_ID(2), + HYP_ID); +} diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml index cfc7914..9cf2ddc 100644 --- a/tftf/tests/tests-spm.xml +++ b/tftf/tests/tests-spm.xml @@ -78,6 +78,10 @@ function="test_req_mem_lend_sp_to_sp" /> <testcase name="Request Donate Memory SP-to-SP" function="test_req_mem_donate_sp_to_sp" /> + <testcase name="Request Share Memory SP-to-VM" + function="test_req_mem_share_sp_to_vm" /> + <testcase name="Request Lend Memory SP-to-VM" + function="test_req_mem_lend_sp_to_vm" /> </testsuite> <testsuite name="SIMD,SVE Registers context" |