Enable MMU and caching in VM API tests

VM API tests are failing on real hardware because VMs are not seeing
data written by the hypervisor. The reason for this is that Hafnium has
data caching enabled while the test VMs do not. Solve this discrepancy
by enabling data caching in the VMs too, which requires enabling stage-1
MMU translation.

The entire address space is identity-mapped with read-write-execute
permisssions. Only GIC tests currently require custom device mappings.

Implementation shares ptable management code from src/mm.c and
src/arch/mm.c.

Bug: 138985026
Test: ./kokoro/ubuntu/build.sh
Change-Id: Ib9f599c448d70296a6ca869ddbb51abfcc55148d
diff --git a/test/hftest/standalone_main.c b/test/hftest/standalone_main.c
index c1bfa1a..63edf1e 100644
--- a/test/hftest/standalone_main.c
+++ b/test/hftest/standalone_main.c
@@ -19,6 +19,7 @@
 
 #include "hf/fdt.h"
 #include "hf/memiter.h"
+#include "hf/mm.h"
 
 #include "hftest.h"
 #include "hftest_common.h"
@@ -36,6 +37,14 @@
 	struct memiter bootargs_iter;
 	struct memiter command;
 
+	/*
+	 * Initialize the stage-1 MMU and identity-map the entire address space.
+	 */
+	if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) {
+		HFTEST_LOG("Memory initialization failed.");
+		return;
+	}
+
 	hftest_use_list(hftest_begin, hftest_end - hftest_begin);
 
 	if (!fdt_root_node(&n, fdt)) {