Changes to existing files to add HAX support
HAX (Hardware-based Accelerated eXecution) employes hardware virtualization
technology to boost performance of the Android emulator on Mac OS X or Windows
hosts.
This changeset includes the changes required to the existing files. To pass
the compilation, hax.h is added, but CONFIG_HAX is disabled so that no
real changes added.
Change-Id: Ifa5777e8788e6698747c1ec4cd91315161c2ca0b
Signed-off-by: Zhang, Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Xin, Xiaohui <xiaohui.xin@intel.com>
Signed-off-by: Jiang Yunhong <yunhong.jiang@intel.com>
Signed-off-by: Nakajima, Jun <jun.nakajima@intel.com>
diff --git a/exec.c b/exec.c
index f650a9e..b8a473f 100644
--- a/exec.c
+++ b/exec.c
@@ -39,6 +39,7 @@
#include "hw/hw.h"
#include "osdep.h"
#include "kvm.h"
+#include "hax.h"
#include "qemu-timer.h"
#if defined(CONFIG_USER_ONLY)
#include <qemu.h>
@@ -2379,6 +2380,10 @@
if (kvm_enabled())
kvm_set_phys_mem(start_addr, size, phys_offset);
+#ifdef CONFIG_HAX
+ if (hax_enabled())
+ hax_set_phys_mem(start_addr, size, phys_offset);
+#endif
if (phys_offset == IO_MEM_UNASSIGNED) {
region_offset = start_addr;
@@ -2561,6 +2566,27 @@
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
#else
new_block->host = qemu_vmalloc(size);
+
+#ifdef CONFIG_HAX
+ /*
+ * In HAX, qemu allocates the virtual address, and HAX kernel
+ * module populates the region with physical memory. Currently
+ * we don’t populate guest memory on demand, thus we should
+ * make sure that sufficient amount of memory is available in
+ * advance.
+ */
+ if (hax_enabled())
+ {
+ int ret;
+ ret = hax_populate_ram((uint64_t)new_block->host, size);
+ if (ret < 0)
+ {
+ fprintf(stderr, "Hax failed to populate ram\n");
+ exit(-1);
+ }
+ }
+#endif
+
#endif
#ifdef MADV_MERGEABLE
madvise(new_block->host, size, MADV_MERGEABLE);