fix(memory share): memory attributes on FFA_MEM_RETRIEVE_REQ
Validate that the memory attributes provided in memory region
descriptor when invoking FFA_MEM_RETRIEVE_REQ are those supported by
Hafnium, only if those are specified. If memory attributes are not
specified, skip validation, as the caller expects to receive them in the
FFA_MEM_RETRIEVE_RESP response.
Implemented test to validate that memory can be shared if no memory
type attributes are specified, and that the response contain the
attributes expected to be implemented by hafnium.
Change-Id: Id64489923d8bd58e4ba2a20767b4111f0a4b36ff
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 1cd8c5e..048cca9 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -2467,14 +2467,18 @@
"be checked before this point.");
}
- /*
- * Ensure receiver's attributes are compatible with how Hafnium maps
- * memory: Normal Memory, Inner shareable, Write-Back Read-Allocate
- * Write-Allocate Cacheable.
- */
- ret = ffa_memory_attributes_validate(retrieve_request->attributes);
- if (ret.func != FFA_SUCCESS_32) {
- goto out;
+ if (ffa_get_memory_type_attr(retrieve_request->attributes) !=
+ FFA_MEMORY_NOT_SPECIFIED_MEM) {
+ /*
+ * Ensure receiver's attributes are compatible with how Hafnium
+ * maps memory: Normal Memory, Inner shareable, Write-Back
+ * Read-Allocate Write-Allocate Cacheable.
+ */
+ ret = ffa_memory_attributes_validate(
+ retrieve_request->attributes);
+ if (ret.func != FFA_SUCCESS_32) {
+ goto out;
+ }
}
memory_to_attributes = ffa_memory_permissions_to_mode(