fix(spm): instruction permissions on memory sharing
- FFA_MEM_SHARE the instruction access to be used shall be NX,
however both sender and the borrower should leave it not specified.
- FFA_MEM_LEND/FFA_MEM_DONATE the lender must specify the instruction
permissions it wishes to receive on the retrieve request.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I0c6e49c30cbbca513644b592695f853bbdf1994b
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index c1b3698..9e7f1e6 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -119,7 +119,7 @@
bool memory_retrieve(struct mailbox_buffers *mb,
struct ffa_memory_region **retrieved, uint64_t handle,
ffa_id_t sender, ffa_id_t receiver,
- ffa_memory_region_flags_t flags);
+ ffa_memory_region_flags_t flags, uint32_t mem_func);
/**
* Helper to conduct a memory relinquish. The caller is usually the receiver,
diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
index 715433e..d9467b4 100644
--- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
+++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
@@ -83,7 +83,7 @@
bool non_secure = cactus_mem_send_get_non_secure(*args);
expect(memory_retrieve(mb, &m, handle, source, vm_id,
- retrv_flags), true);
+ retrv_flags, mem_func), true);
composite = ffa_memory_region_get_composite(m, 0);
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 43357a2..5c44bd9 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "ffa_helpers.h"
#include <cactus_test_cmds.h>
#include <debug.h>
#include <ffa_endpoints.h>
@@ -208,12 +209,17 @@
bool memory_retrieve(struct mailbox_buffers *mb,
struct ffa_memory_region **retrieved, uint64_t handle,
ffa_id_t sender, ffa_id_t receiver,
- ffa_memory_region_flags_t flags)
+ ffa_memory_region_flags_t flags,
+ uint32_t mem_func)
{
struct ffa_value ret;
uint32_t fragment_size;
uint32_t total_size;
uint32_t descriptor_size;
+ const enum ffa_instruction_access inst_access =
+ (mem_func == FFA_MEM_SHARE_SMC32)
+ ? FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED
+ : FFA_INSTRUCTION_ACCESS_NX;
if (retrieved == NULL || mb == NULL) {
ERROR("Invalid parameters!\n");
@@ -223,7 +229,7 @@
descriptor_size = ffa_memory_retrieve_request_init(
mb->send, handle, sender, receiver, 0, flags,
FFA_DATA_ACCESS_RW,
- FFA_INSTRUCTION_ACCESS_NX,
+ inst_access,
FFA_MEMORY_NORMAL_MEM,
FFA_MEMORY_CACHE_WRITE_BACK,
FFA_MEMORY_INNER_SHAREABLE);