fix: check ff-a version for functionality support

The SP must be at least FF-A v1.1 to support:
- Receiving/Sending indirect messages.
- Binding its own notifications.

Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I86aff3641235264620f8e648ed1e0e2467d1ae7a
diff --git a/src/api.c b/src/api.c
index 8efa5c0..95a2810 100644
--- a/src/api.c
+++ b/src/api.c
@@ -4192,6 +4192,14 @@
 		return ffa_error(FFA_INVALID_PARAMETERS);
 	}
 
+	if (receiver_locked.vm->ffa_version < FFA_VERSION_1_1) {
+		dlog_verbose(
+			"%s: caller (%x) version should be GE to FF-A v1.1.\n",
+			__func__, receiver_locked.vm->id);
+		ret = ffa_error(FFA_NOT_SUPPORTED);
+		goto out;
+	}
+
 	if (!vm_locked_are_notifications_enabled(receiver_locked)) {
 		dlog_verbose("Notifications are not enabled.\n");
 		ret = ffa_error(FFA_NOT_SUPPORTED);
diff --git a/src/arch/aarch64/plat/ffa/spmc.c b/src/arch/aarch64/plat/ffa/spmc.c
index 0a56f31..717fda8 100644
--- a/src/arch/aarch64/plat/ffa/spmc.c
+++ b/src/arch/aarch64/plat/ffa/spmc.c
@@ -159,6 +159,8 @@
 
 static void plat_ffa_vm_init(struct mpool *ppool)
 {
+	struct vm *other_world = vm_find(HF_OTHER_WORLD_ID);
+
 	/* Init NWd VMs structures for use of Notifications interfaces. */
 	for (uint32_t i = 0; i < nwd_vms_size; i++) {
 		/*
@@ -172,6 +174,9 @@
 		nwd_vms[i].id = HF_INVALID_VM_ID;
 		nwd_vms[i].vcpu_count = MAX_CPUS;
 		vm_notifications_init(&nwd_vms[i], MAX_CPUS, ppool);
+
+		/* Give them the same version as the Hypervisor. */
+		nwd_vms[i].ffa_version = other_world->ffa_version;
 	}
 }
 
@@ -657,6 +662,22 @@
 	 * check if they are allowed to send indirect messages, but it's not a
 	 * security threat.
 	 */
+	if (sender_vm->ffa_version < FFA_VERSION_1_1) {
+		dlog_verbose(
+			"Sender %x FF-A version (%x) doesn't support Indirect "
+			"Message. FF-A v1.1 is needed.\n",
+			sender_vm->id, sender_vm->ffa_version);
+		return false;
+	}
+
+	if (receiver_vm->ffa_version < FFA_VERSION_1_1) {
+		dlog_verbose(
+			"Receiver %x FF-A version (%x) doesn't support "
+			"Indirect Message. FF-A v1.1 is needed.\n",
+			receiver_vm->id, receiver_vm->ffa_version);
+		return false;
+	}
+
 	if (vm_id_is_current_world(sender_vm->id)) {
 		if (!vm_supports_messaging_method(sender_vm,
 						  FFA_PARTITION_INDIRECT_MSG)) {