feat(notifications): bitmap create at vm load
Hypervisor call FFA_NOTIFICATION_BITMAP_CREATE when loading VMs, to
request SPMC to create bitmap for NWd VMs.
If Hafnium built as SPMC the referred call at load is bypassed.
Adding this to Hypervisor's initialization will allow full notifications
signaling flow with a testing set-up including Hypervisor and SPMC.
Change-Id: I14abd59202ff1246280642262984ca91801ae4bc
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 2baf272..0fd8d55 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -85,6 +85,13 @@
ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count);
/**
+ * Issues a FFA_NOTIFICATION_BITMAP_CREATE.
+ */
+bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
+ ffa_vcpu_count_t vcpu_count,
+ struct ffa_value *ret);
+
+/**
* Destroys the notifications bitmap for the given VM ID.
*/
struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id);
diff --git a/src/arch/aarch64/plat/ffa/absent.c b/src/arch/aarch64/plat/ffa/absent.c
index bb41c7b..e9a10e6 100644
--- a/src/arch/aarch64/plat/ffa/absent.c
+++ b/src/arch/aarch64/plat/ffa/absent.c
@@ -138,6 +138,15 @@
return ffa_error(FFA_NOT_SUPPORTED);
}
+bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
+ ffa_vcpu_count_t vcpu_count)
+{
+ (void)vm_id;
+ (void)vcpu_count;
+
+ return false;
+}
+
struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id)
{
(void)vm_id;
diff --git a/src/arch/aarch64/plat/ffa/hypervisor.c b/src/arch/aarch64/plat/ffa/hypervisor.c
index 158cd37..ba9ae23 100644
--- a/src/arch/aarch64/plat/ffa/hypervisor.c
+++ b/src/arch/aarch64/plat/ffa/hypervisor.c
@@ -262,7 +262,6 @@
struct ffa_value plat_ffa_notifications_bitmap_create(
ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count)
{
- /* TODO: Forward call to the SPMC */
(void)vm_id;
(void)vcpu_count;
@@ -271,12 +270,25 @@
struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id)
{
- /* TODO: Forward call to the SPMC */
(void)vm_id;
return ffa_error(FFA_NOT_SUPPORTED);
}
+bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
+ ffa_vcpu_count_t vcpu_count,
+ struct ffa_value *ret)
+{
+ CHECK(ret != NULL);
+ *ret = arch_other_world_call((struct ffa_value){
+ .func = FFA_NOTIFICATION_BITMAP_CREATE_32,
+ .arg1 = vm_id,
+ .arg2 = vcpu_count,
+ });
+
+ return true;
+}
+
struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id)
{
if (vm_id_is_current_world(vm_id) || vm_id == HF_OTHER_WORLD_ID) {
diff --git a/src/arch/aarch64/plat/ffa/spmc.c b/src/arch/aarch64/plat/ffa/spmc.c
index dded83c..d2eb754 100644
--- a/src/arch/aarch64/plat/ffa/spmc.c
+++ b/src/arch/aarch64/plat/ffa/spmc.c
@@ -384,6 +384,15 @@
return ret;
}
+bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
+ ffa_vcpu_count_t vcpu_count)
+{
+ (void)vm_id;
+ (void)vcpu_count;
+
+ return false;
+}
+
struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id)
{
struct ffa_value ret = {.func = FFA_SUCCESS_32};
diff --git a/src/load.c b/src/load.c
index 1e6031b..e7f3085 100644
--- a/src/load.c
+++ b/src/load.c
@@ -11,6 +11,7 @@
#include <stdbool.h>
#include "hf/arch/other_world.h"
+#include "hf/arch/plat/ffa.h"
#include "hf/arch/vm.h"
#include "hf/api.h"
@@ -137,6 +138,8 @@
vm_locked.vm->uuid = manifest_vm->partition.uuid;
if (manifest_vm->is_ffa_partition) {
+ struct ffa_value bitmap_create_res;
+
/* Link rxtx buffers to mailbox */
if (manifest_vm->partition.rxtx.available) {
if (!link_rxtx_to_mailbox(stage1_locked, vm_locked,
@@ -162,6 +165,20 @@
/* TODO: Enable in accordance to VM's manifest. */
vm_locked.vm->notifications.enabled = true;
+
+ /* TODO: check if notifications is enabled for the given vm */
+ if (plat_ffa_notifications_bitmap_create_call(
+ vm_locked.vm->id, vm_locked.vm->vcpu_count,
+ &bitmap_create_res)) {
+ if (bitmap_create_res.func == FFA_ERROR_32) {
+ dlog_verbose(
+ "Failed to create notifications bitmap "
+ "to VM: %#x; error: %#x.\n",
+ vm_locked.vm->id,
+ ffa_error_code(bitmap_create_res));
+ return false;
+ }
+ }
}
/* Initialize architecture-specific features. */