FF-A: map normal world rx/tx buffers to the SPMC

The SPMC can receive an FF-A RXTX map request to register
the NWd Hypervisor or OS kernel rx/tx buffers. In the SPMC
this request comes from the physical FF-A interface.
The buffers are mapped non-secure in the SPMC S-EL2 Stage-1
translation regime.

Change-Id: I65947f081b55e125edfd81e5e540a09dc8f915d9
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/src/api.c b/src/api.c
index b55ae09..c33d9eb 100644
--- a/src/api.c
+++ b/src/api.c
@@ -9,6 +9,7 @@
 #include "hf/api.h"
 
 #include "hf/arch/cpu.h"
+#include "hf/arch/mm.h"
 #include "hf/arch/tee.h"
 #include "hf/arch/timer.h"
 
@@ -759,6 +760,7 @@
 				    struct vm_locked vm_locked,
 				    paddr_t pa_send_begin, paddr_t pa_send_end,
 				    paddr_t pa_recv_begin, paddr_t pa_recv_end,
+				    uint32_t extra_attributes,
 				    struct mpool *local_page_pool)
 {
 	bool ret;
@@ -766,7 +768,7 @@
 	/* Map the send page as read-only in the hypervisor address space. */
 	vm_locked.vm->mailbox.send =
 		mm_identity_map(mm_stage1_locked, pa_send_begin, pa_send_end,
-				MM_MODE_R, local_page_pool);
+				MM_MODE_R | extra_attributes, local_page_pool);
 	if (!vm_locked.vm->mailbox.send) {
 		/* TODO: partial defrag of failed range. */
 		/* Recover any memory consumed in failed mapping. */
@@ -780,7 +782,7 @@
 	 */
 	vm_locked.vm->mailbox.recv =
 		mm_identity_map(mm_stage1_locked, pa_recv_begin, pa_recv_end,
-				MM_MODE_W, local_page_pool);
+				MM_MODE_W | extra_attributes, local_page_pool);
 	if (!vm_locked.vm->mailbox.recv) {
 		/* TODO: partial defrag of failed range. */
 		/* Recover any memory consumed in failed mapping. */
@@ -833,6 +835,7 @@
 	paddr_t pa_recv_end;
 	uint32_t orig_send_mode;
 	uint32_t orig_recv_mode;
+	uint32_t extra_attributes;
 
 	/* We only allow these to be setup once. */
 	if (vm_locked.vm->mailbox.send || vm_locked.vm->mailbox.recv) {
@@ -904,9 +907,12 @@
 		goto fail_undo_send;
 	}
 
+	/* Get extra send/recv pages mapping attributes for the given VM ID. */
+	extra_attributes = arch_mm_extra_attributes_from_vm(vm_locked.vm->id);
+
 	if (!api_vm_configure_stage1(mm_stage1_locked, vm_locked, pa_send_begin,
 				     pa_send_end, pa_recv_begin, pa_recv_end,
-				     local_page_pool)) {
+				     extra_attributes, local_page_pool)) {
 		goto fail_undo_send_and_recv;
 	}