fix(memory share): v1.1 emad reserved field check
When checking the values in the endpoint memory access descriptors
during a send transaction during the sanity check we must consider
the version of the sender to know the offset of the reserved field
as it changes between v1.1 and v1.2.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I87a669a7b97cb3bbebabc41f6fa73cd745b12f2f
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 53a605f..e6d167b 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -663,14 +663,42 @@
i);
assert(receiver != NULL);
- if (receiver->reserved_0 != 0) {
- dlog_verbose(
- "Reserved field in the memory access "
- "descriptor must be zero. Currently "
- "reciever %zu has a reserved field "
- "with a value of %lu\n",
- i, receiver->reserved_0);
- return false;
+ if (ffa_version == FFA_VERSION_1_1) {
+ /*
+ * Since the reserved field is at the end of the
+ * Endpoint Memory Access Descriptor we must
+ * cast to ffa_memory_access_v1_0 as they match.
+ * Since all fields except reserved in the
+ * Endpoint Memory Access Descriptor have the
+ * same offsets across all versions this cast is
+ * not required when accessing other fields in
+ * the future.
+ */
+ struct ffa_memory_access_v1_0 *receiver_v1_0 =
+ (struct ffa_memory_access_v1_0 *)
+ receiver;
+ if (receiver_v1_0->reserved_0 != 0) {
+ dlog_verbose(
+ "Reserved field in the memory "
+ "access descriptor must be "
+ "zero. Currently reciever %zu "
+ "has a reserved field with a "
+ "value of %lu\n",
+ i, receiver_v1_0->reserved_0);
+ return false;
+ }
+
+ } else {
+ if (receiver->reserved_0 != 0) {
+ dlog_verbose(
+ "Reserved field in the memory "
+ "access descriptor must be "
+ "zero. Currently reciever %zu "
+ "has a reserved field with a "
+ "value of %lu\n",
+ i, receiver->reserved_0);
+ return false;
+ }
}
}