feat(notifications): receipt support enabled in partition manifest

Change-Id: I2d1310fb9fa6acd6a59b429a5b6e23f3652a8c43
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 99e9f6f..a4d0dc5 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -133,10 +133,11 @@
 
 /**
  * Issues a FFA_NOTIFICATION_BITMAP_CREATE.
+ * Returns true if the call goes well, and false if call returns with
+ * FFA_ERROR_32.
  */
 bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
-					       ffa_vcpu_count_t vcpu_count,
-					       struct ffa_value *ret);
+					       ffa_vcpu_count_t vcpu_count);
 
 /**
  * Destroys the notifications bitmap for the given VM ID.
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index 800d2d2..97364b7 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -142,6 +142,8 @@
 	uint8_t messaging_method;
 	/** optional */
 	bool managed_exit;
+	/** optional - receipt of notifications. */
+	bool notification_support;
 	/** optional */
 	bool has_primary_scheduler;
 	/** optional - preemptible / run to completion */
diff --git a/src/arch/aarch64/plat/ffa/hypervisor.c b/src/arch/aarch64/plat/ffa/hypervisor.c
index 86407c2..2cdc3cc 100644
--- a/src/arch/aarch64/plat/ffa/hypervisor.c
+++ b/src/arch/aarch64/plat/ffa/hypervisor.c
@@ -330,16 +330,22 @@
 }
 
 bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
-					       ffa_vcpu_count_t vcpu_count,
-					       struct ffa_value *ret)
+					       ffa_vcpu_count_t vcpu_count)
 {
-	CHECK(ret != NULL);
-	*ret = arch_other_world_call((struct ffa_value){
+	struct ffa_value ret = arch_other_world_call((struct ffa_value){
 		.func = FFA_NOTIFICATION_BITMAP_CREATE_32,
 		.arg1 = vm_id,
 		.arg2 = vcpu_count,
 	});
 
+	if (ret.func == FFA_ERROR_32) {
+		dlog_error(
+			"Failed to create notifications bitmap "
+			"to VM: %#x; error: %#x.\n",
+			vm_id, ffa_error_code(ret));
+		return false;
+	}
+
 	return true;
 }
 
@@ -390,11 +396,12 @@
 	}
 
 	/*
-	 * The count of ids should be at least the number of lists, to encompass
-	 * for at least the ids of the FF-A endpoints.
-	 * List sizes will be between 0 and 3, and relates to the counting of
+	 * The count of ids should be at least the number of lists, to
+	 * encompass for at least the ids of the FF-A endpoints. List
+	 * sizes will be between 0 and 3, and relates to the counting of
 	 * vCPU of the endpoint that have pending notifications.
-	 * If `lists_count` is already ids_count_max, each list size must be 0.
+	 * If `lists_count` is already ids_count_max, each list size
+	 * must be 0.
 	 */
 	*ids_count = *lists_count;
 
@@ -403,17 +410,17 @@
 			ffa_notification_info_get_list_size(ret, i + 1);
 
 		/*
-		 * ... sum the counting of each list size that are part of the
-		 * main list.
+		 * ... sum the counting of each list size that are part
+		 * of the main list.
 		 */
 		*ids_count += local_lists_sizes[i];
 	}
 
 	/*
-	 * Sanity check returned `lists_count` and determined `ids_count`.
-	 * If something wrong, reset arguments to 0 such that hypervisor's
-	 * handling of FFA_NOTIFICATION_INFO_GET can proceed without SPMC's
-	 * values.
+	 * Sanity check returned `lists_count` and determined
+	 * `ids_count`. If something wrong, reset arguments to 0 such
+	 * that hypervisor's handling of FFA_NOTIFICATION_INFO_GET can
+	 * proceed without SPMC's values.
 	 */
 	if (*ids_count > ids_count_max) {
 		*ids_count = 0;
@@ -508,8 +515,8 @@
 	(void)next;
 
 	/*
-	 * SPMD uses FFA_INTERRUPT ABI to convey secure interrupt to SPMC.
-	 * Execution should not reach hypervisor with this ABI.
+	 * SPMD uses FFA_INTERRUPT ABI to convey secure interrupt to
+	 * SPMC. Execution should not reach hypervisor with this ABI.
 	 */
 	CHECK(false);
 
diff --git a/src/arch/aarch64/plat/ffa/spmc.c b/src/arch/aarch64/plat/ffa/spmc.c
index 7f4c4e1..128574c 100644
--- a/src/arch/aarch64/plat/ffa/spmc.c
+++ b/src/arch/aarch64/plat/ffa/spmc.c
@@ -480,14 +480,12 @@
 }
 
 bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
-					       ffa_vcpu_count_t vcpu_count,
-					       struct ffa_value *ret)
+					       ffa_vcpu_count_t vcpu_count)
 {
 	(void)vm_id;
 	(void)vcpu_count;
-	(void)ret;
 
-	return false;
+	return true;
 }
 
 struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id)
diff --git a/src/load.c b/src/load.c
index 28e886c..4d5fe30 100644
--- a/src/load.c
+++ b/src/load.c
@@ -187,8 +187,6 @@
 	dlog_verbose("VM has %d physical interrupts defined in manifest.\n", k);
 
 	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,
@@ -207,26 +205,18 @@
 		vm_locked.vm->managed_exit =
 			manifest_vm->partition.managed_exit;
 
+		vm_locked.vm->notifications.enabled =
+			manifest_vm->partition.notification_support;
+
 		vm_locked.vm->boot_order = manifest_vm->partition.boot_order;
 
 		/* Updating boot list according to boot_order */
 		vm_update_boot(vm_locked.vm);
 
-		/* 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;
-			}
+		if (vm_are_notifications_enabled(vm_locked) &&
+		    !plat_ffa_notifications_bitmap_create_call(
+			    vm_locked.vm->id, vm_locked.vm->vcpu_count)) {
+			return false;
 		}
 	}
 
diff --git a/src/manifest.c b/src/manifest.c
index 6f366e2..5ac2c0f 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -630,6 +630,15 @@
 	dlog_verbose("  Messaging method %u\n", vm->partition.messaging_method);
 
 	TRY(read_bool(&root, "managed-exit", &vm->partition.managed_exit));
+	if (vm->partition.managed_exit) {
+		dlog_verbose("  Managed Exit Supported\n");
+	}
+
+	TRY(read_bool(&root, "notification-support",
+		      &vm->partition.notification_support));
+	if (vm->partition.notification_support) {
+		dlog_verbose("  Notifications Receipt Supported\n");
+	}
 
 	/* Parse memory-regions */
 	ffa_node = root;
diff --git a/test/vmapi/ffa_secure_partitions/partition_manifest_nwd_primary.dts b/test/vmapi/ffa_secure_partitions/partition_manifest_nwd_primary.dts
index 4f7159a..07567d9 100644
--- a/test/vmapi/ffa_secure_partitions/partition_manifest_nwd_primary.dts
+++ b/test/vmapi/ffa_secure_partitions/partition_manifest_nwd_primary.dts
@@ -22,4 +22,5 @@
 	entrypoint-offset = <0x1000>;
 	xlat-granule = <0>; /* 4KiB */
 	messaging-method = <0>; /* Direct messaging only */
+	notification-support; /* Receipt of notifications. */
 };
diff --git a/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts b/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
index ed375de..fa755ff 100644
--- a/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
+++ b/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
@@ -23,4 +23,5 @@
 	xlat-granule = <0>; /* 4KiB */
 	messaging-method = <0>; /* Direct messaging only */
 	boot-order = <2>; /* This should be the highest priority partition */
+	notification-support; /* Receipt of notifications. */
 };