From a381ef07088ce479610129e37bfef42538f397da Mon Sep 17 00:00:00 2001 From: Jun Nakajima Date: Sat, 17 Dec 2011 19:13:25 -0800 Subject: 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 Signed-off-by: Xin, Xiaohui Signed-off-by: Jiang Yunhong Signed-off-by: Nakajima, Jun --- exec.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'exec.c') 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 @@ -2379,6 +2380,10 @@ void cpu_register_physical_memory_log(target_phys_addr_t start_addr, 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 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, 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); -- cgit v1.1