fix(memory share): share operation and instruction permissions

Avoid setting the NX permissions for the memory region in
memory sharing, that it is not cross-world.
The NX permission was being set in memory region descriptor to be saved
in hafnium tracking the operation, which would then be included in the
borrower's memory retrieve response. This copy of the memory region
would be used for forwarding to the SPMC in memory share from NWd
to SWd. However, the spec dictates the instruction should be left
unspecified from the sender. The SPMC would find the NX bit set
and fail operation with FFA_ERROR.

Change-Id: Ib7adbbd3ad2c99e1a93225c8c856a904e0e533c1
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 51a8636..61d3812 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -1534,10 +1534,14 @@
 			 * copy that we store, ready to be returned to the
 			 * retriever.
 			 */
-			ffa_set_instruction_access_attr(
-				&permissions, FFA_INSTRUCTION_ACCESS_NX);
-			memory_region->receivers[i]
-				.receiver_permissions.permissions = permissions;
+			if (vm_id_is_current_world(receiver_id)) {
+				ffa_set_instruction_access_attr(
+					&permissions,
+					FFA_INSTRUCTION_ACCESS_NX);
+				memory_region->receivers[i]
+					.receiver_permissions.permissions =
+					permissions;
+			}
 		}
 		if (share_func == FFA_MEM_LEND_32 &&
 		    data_access == FFA_DATA_ACCESS_NOT_SPECIFIED) {