feat(notifications): bind and unbind
Handle bind and unbind interfaces. The bind interface is intended for a
given receiver to enable a sender to set the specified notifications.
The unbind interface revokes the sender's ability to set the specified
notifications.
Bindings are tracked per notification in the receiver's vm structure.
This patch adds handling to FFA_NOTIFICATION_BIND and
FFA_NOTIFICATION_UNBIND, functions to validate the bindings,
as well as to make any bindings updates.
Change-Id: I7c70fe4e1285d6f58738d0229568666ce2075d12
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 75441c4..be3903d 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -101,3 +101,8 @@
struct vcpu *current);
struct ffa_value api_ffa_notification_bitmap_destroy(ffa_vm_id_t vm_id,
struct vcpu *current);
+
+struct ffa_value api_ffa_notification_update_bindings(
+ ffa_vm_id_t sender_vm_id, ffa_vm_id_t receiver_vm_id, uint32_t flags,
+ ffa_notifications_bitmap_t notifications, bool is_bind,
+ struct vcpu *current);
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 57ce170..a1eea5f 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -10,6 +10,7 @@
#include "hf/ffa.h"
#include "hf/vcpu.h"
+#include "hf/vm.h"
/** Returns the SPMC ID. */
struct ffa_value plat_ffa_spmc_id_get(void);
@@ -27,6 +28,11 @@
struct ffa_value *ret);
bool plat_ffa_is_notifications_create_valid(struct vcpu *current,
ffa_vm_id_t vm_id);
+
+bool plat_ffa_is_notifications_bind_valid(struct vcpu *current,
+ ffa_vm_id_t sender_id,
+ ffa_vm_id_t receiver_id);
+
/**
* Checks whether managed exit is supported by given SP.
*/
@@ -70,3 +76,14 @@
* Destroys the notifications bitmap for the given VM ID.
*/
struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id);
+
+/**
+ * Helper to get the struct notifications, depending on the sender's id.
+ */
+struct notifications *plat_ffa_vm_get_notifications_senders_world(
+ struct vm_locked vm_locked, ffa_vm_id_t sender_id);
+
+/**
+ * Helper to check if FF-A ID is a VM ID.
+ */
+bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id);
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index 6174289..201d61f 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -231,3 +231,18 @@
void vm_notifications_init_bindings(struct notifications *n);
bool vm_are_notifications_pending(struct vm_locked vm_locked, bool from_vm,
ffa_notifications_bitmap_t notifications);
+bool vm_are_notifications_enabled(struct vm_locked vm_locked);
+bool vm_notifications_validate_per_vcpu(struct vm_locked vm_locked,
+ bool is_from_vm, bool is_per_vcpu,
+ ffa_notifications_bitmap_t notif);
+bool vm_notifications_validate_bound_sender(
+ struct vm_locked vm_locked, bool is_from_vm, ffa_vm_id_t sender_id,
+ ffa_notifications_bitmap_t notifications);
+bool vm_notifications_validate_binding(struct vm_locked vm_locked,
+ bool is_from_vm, ffa_vm_id_t sender_id,
+ ffa_notifications_bitmap_t notifications,
+ bool is_per_vcpu);
+void vm_notifications_update_bindings(struct vm_locked vm_locked,
+ bool is_from_vm, ffa_vm_id_t sender_id,
+ ffa_notifications_bitmap_t notifications,
+ bool is_per_vcpu);
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index cb0e0e9..af2b756 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -399,6 +399,12 @@
#define MAX_FFA_NOTIFICATIONS 64U
/**
+ * Flag for notification bind and set, to specify call is about per-vCPU
+ * notifications.
+ */
+#define FFA_NOTIFICATION_FLAG_PER_VCPU UINT32_C(1 << 0)
+
+/**
* Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo
* and hi.
* Helpful as FF-A specification defines that the notifications interfaces