feat(memory sharing): include NS bit in S-EL0 mappings

Set NS bit for S-EL0 memory mappings on memory retrieve, in the
case memory is being shared from the NWd.

Change-Id: I2243d782d48dfa485e2adcd8b51cc6645efd6137
Signed-off-by: J-Alves <joao.alves@arm.com>
Signed-off-by: Davidson K <davidson.kumaresan@arm.com>
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 774239f..62e219a 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -2150,6 +2150,19 @@
 
 		memory_to_attributes = ffa_memory_permissions_to_mode(
 			permissions, share_state->sender_orig_mode);
+
+		if (to_locked.vm->el0_partition) {
+			/*
+			 * Get extra mapping attributes for the given VM ID.
+			 * If the memory is shared by a VM executing in non
+			 * secure world, attribute MM_MODE_NS has to be set
+			 * while mapping that in a SP executing in secure world.
+			 */
+			memory_to_attributes |=
+				arch_mm_extra_attributes_from_vm(
+					retrieve_request->sender);
+		}
+
 		ret = ffa_retrieve_check_update(
 			to_locked, memory_region->sender,
 			share_state->fragments,