FF-A: map whole system memory to Hypervisor VM

The "Hypervisor VM" is an abstract representation of the NWd
(Hypervisor or OS kernel if no EL2 present) from the perspective
of the SPMC. vCPUs for such VM (or SP) are never scheduled.
Therefore the corresponding page tables are never rooted into
any physical PE. For any FF-A call from NWd to SWd, the SPMC
is resumed from ffa_handler_loop. At this stage the "current"
vCPU passed to the ffa_handler is one of the "Hypervisor VM"
of FF-A id 0. This serves different purposes (non-exhaustively):
tracking NWd to SWd mem share operations, mapping of Hypervisor
RX/TX buffers, partition info get forwarded from NWd to SWd.
There is the same concept of "TEE VM" from the perspective of
the Hypervisor in NWd. The "Hypervisor VM" is the similar concept
extended to the SWd.

Change-Id: I2d2e77c41825ef1a59a320e75d6b647c43966135
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/src/load.c b/src/load.c
index 871c94f..f820204 100644
--- a/src/load.c
+++ b/src/load.c
@@ -10,6 +10,7 @@
 
 #include <stdbool.h>
 
+#include "hf/arch/other_world.h"
 #include "hf/arch/vm.h"
 
 #include "hf/api.h"
@@ -650,26 +651,10 @@
 	return true;
 }
 
-/*
- * Loads alls VMs from the manifest.
- */
-bool load_vms(struct mm_stage1_locked stage1_locked,
-	      const struct manifest *manifest, const struct memiter *cpio,
-	      const struct boot_params *params,
-	      struct boot_params_update *update, struct mpool *ppool)
+static bool init_other_world_vm(struct mpool *ppool)
 {
-	struct vm *primary;
 	struct vm *other_world_vm;
-	struct mem_range mem_ranges_available[MAX_MEM_RANGES];
-	struct vm_locked primary_vm_locked;
 	size_t i;
-	bool success = true;
-
-	if (!load_primary(stage1_locked, &manifest->vm[HF_PRIMARY_VM_INDEX],
-			  cpio, params, ppool)) {
-		dlog_error("Unable to load primary VM.\n");
-		return false;
-	}
 
 	/*
 	 * Initialise the dummy VM which represents the opposite world:
@@ -686,6 +671,33 @@
 		vcpu->cpu = cpu;
 	}
 
+	return arch_other_world_vm_init(other_world_vm, ppool);
+}
+
+/*
+ * Loads alls VMs from the manifest.
+ */
+bool load_vms(struct mm_stage1_locked stage1_locked,
+	      const struct manifest *manifest, const struct memiter *cpio,
+	      const struct boot_params *params,
+	      struct boot_params_update *update, struct mpool *ppool)
+{
+	struct vm *primary;
+	struct mem_range mem_ranges_available[MAX_MEM_RANGES];
+	struct vm_locked primary_vm_locked;
+	size_t i;
+	bool success = true;
+
+	if (!load_primary(stage1_locked, &manifest->vm[HF_PRIMARY_VM_INDEX],
+			  cpio, params, ppool)) {
+		dlog_error("Unable to load primary VM.\n");
+		return false;
+	}
+
+	if (!init_other_world_vm(ppool)) {
+		return false;
+	}
+
 	static_assert(
 		sizeof(mem_ranges_available) == sizeof(params->mem_ranges),
 		"mem_range arrays must be the same size for memcpy.");