refactor(indirect message): mailbox state as per FF-A v1.1
The maibox_state structure was refactored to represent
the mailbox state, and achieve ownership rules as defined by
the FF-A v1.1 specification.
The code was changed to reflect the new state transitions.
Kept compatibility with FF-A v1.0 indirect messaging to avoid
breaking legacy tests.
Change-Id: I1f2353f97d5d46436a3f81b5abf4a032f43745e8
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/vm.c b/src/vm.c
index 2b4a3a7..128d850 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -252,6 +252,14 @@
}
/**
+ * Checks if mailbox is currently owned by the other world.
+ */
+bool vm_is_mailbox_other_world_owned(struct vm_locked to)
+{
+ return to.vm->mailbox.state == MAILBOX_STATE_OTHER_WORLD_OWNED;
+}
+
+/**
* Gets the ID of the VM which the given VM's wait entry is for.
*/
ffa_vm_id_t vm_id_for_wait_entry(struct vm *vm, struct wait_entry *entry)
@@ -512,7 +520,16 @@
{
return vm_get_notifications(vm_locked, true)->global.pending != 0ULL ||
vm_get_notifications(vm_locked, false)->global.pending != 0ULL ||
- vm_locked.vm->notifications.framework.pending != 0ULL;
+ vm_are_fwk_notifications_pending(vm_locked);
+}
+
+/**
+ * Currently only RX full notification is supported as framework notification.
+ * Returns true if there is one pending, either from Hypervisor or SPMC.
+ */
+bool vm_are_fwk_notifications_pending(struct vm_locked vm_locked)
+{
+ return vm_locked.vm->notifications.framework.pending != 0ULL;
}
/**
@@ -815,24 +832,12 @@
{
struct vm *vm = vm_locked.vm;
ffa_notifications_bitmap_t framework;
- bool rx_buffer_full;
assert(vm != NULL);
framework = vm_notifications_state_get_pending(
&vm->notifications.framework);
- /*
- * By retrieving an RX buffer full notification the buffer state
- * transitions from RECEIVED to READ; the VM is now the RX buffer
- * owner, can read it and is allowed to release it.
- */
- rx_buffer_full = is_ffa_spm_buffer_full_notification(framework) ||
- is_ffa_hyp_buffer_full_notification(framework);
- if (rx_buffer_full && vm->mailbox.state == MAILBOX_STATE_RECEIVED) {
- vm->mailbox.state = MAILBOX_STATE_READ;
- }
-
return framework;
}