feat(memory share): retrieve request from NWd

If the SPMC is allocator of a given memory handle, it is
expected to keep track of the on going memory region operations.
In the case a VM is retrieving a memory region that is shared with
an SP, it might attempt to retrieve the memory.
The hypervisor issues a retrieve req for the SPMC to pass it
the recorded memory region descriptor, such that it can
validate the retrieve request from the VM and then
update the VM's S2 memory mapping.

The SPMC doesn't expect to receive a request whose memory handle
was allocated by the hypervisor. Return FFA_INVALID_PARAMETERS
in such case.

Change-Id: Id86069cfb263c6a2efc4202ad9e3c5e53cdf1e65
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/api.c b/src/api.c
index a11fd1a..88d809e 100644
--- a/src/api.c
+++ b/src/api.c
@@ -3014,9 +3014,14 @@
 		goto out;
 	}
 
-	ret = ffa_memory_retrieve(to_locked, retrieve_request, length,
-				  &api_page_pool);
-
+	if (plat_ffa_memory_handle_allocated_by_current_world(
+		    retrieve_request->handle)) {
+		ret = ffa_memory_retrieve(to_locked, retrieve_request, length,
+					  &api_page_pool);
+	} else {
+		ret = plat_ffa_other_world_mem_retrieve(
+			to_locked, retrieve_request, length, &api_page_pool);
+	}
 out:
 	vm_unlock(&to_locked);
 	return ret;