aboutsummaryrefslogtreecommitdiffstats
path: root/target-i386/hax-all.c
diff options
context:
space:
mode:
authorJiang, Yunhong <yunhong.jiang@intel.com>2012-04-01 10:01:33 +0800
committerJiang, Yunhong <yunhong.jiang@intel.com>2012-04-07 22:47:58 +0800
commitfba19d9f0bf94a11e87dd09e230b621025436b76 (patch)
tree12996af5393acadd815968018969e365939c1b9d /target-i386/hax-all.c
parent8a539eaab40dc7a8047dbf97c081467029e6c518 (diff)
downloadexternal_qemu-fba19d9f0bf94a11e87dd09e230b621025436b76.zip
external_qemu-fba19d9f0bf94a11e87dd09e230b621025436b76.tar.gz
external_qemu-fba19d9f0bf94a11e87dd09e230b621025436b76.tar.bz2
Add fast mmio support
In HAXM 1.0, HAXM driver utilizes QEMU to decode and emulate MMIO accesses. This simplified the HAXM driver implementation. However, decoding in QEMU is slow because QEMU needs to sync with the HAXM driver regarding the vCPU state, guest page tables, etc. Newer HAXM driver will decode some MMIO instructions, and QEMU will get the decoded instruction information like the physical address, access direction etc, and then invoke the MMIO handler directly. This boosts MMIO handling performance significantly, thus performance of 2D/3D games because they performance very frequent MMIO access for GLES commands to the host translator. Change-Id: Ida308b2e6da3697ee37a1b28a9645916e104d9ff 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>
Diffstat (limited to 'target-i386/hax-all.c')
-rw-r--r--target-i386/hax-all.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c
index 2c13250..2540f54 100644
--- a/target-i386/hax-all.c
+++ b/target-i386/hax-all.c
@@ -120,7 +120,7 @@ hax_fd hax_vcpu_get_fd(CPUState *env)
}
/* Current version */
-uint32_t hax_cur_version = 0x1;
+uint32_t hax_cur_version = 0x2;
/* Least HAX kernel version */
uint32_t hax_lest_version = 0x1;
@@ -395,6 +395,31 @@ error:
return ret;
}
+int hax_handle_fastmmio(CPUState *env, struct hax_fastmmio *hft)
+{
+ uint64_t buf = 0;
+
+ /*
+ * With fast MMIO, QEMU need not sync vCPU state with HAXM
+ * driver because it will only invoke MMIO handler
+ * However, some MMIO operations utilize virtual address like qemu_pipe
+ * Thus we need to sync the CR0, CR3 and CR4 so that QEMU
+ * can translate the guest virtual address to guest physical
+ * address
+ */
+ env->cr[0] = hft->_cr0;
+ env->cr[2] = hft->_cr2;
+ env->cr[3] = hft->_cr3;
+ env->cr[4] = hft->_cr4;
+
+ buf = hft->value;
+ cpu_physical_memory_rw(hft->gpa, &buf, hft->size, hft->direction);
+ if (hft->direction == 0)
+ hft->value = buf;
+
+ return 0;
+}
+
int hax_handle_io(CPUState *env, uint32_t df, uint16_t port, int direction,
int size, int count, void *buffer)
{
@@ -542,6 +567,10 @@ static int hax_vcpu_hax_exec(CPUState *env)
case HAX_EXIT_MMIO:
ret = HAX_EMUL_ONE;
break;
+ case HAX_EXIT_FAST_MMIO:
+ ret = hax_handle_fastmmio(env,
+ (struct hax_fastmmio *)vcpu->iobuf);
+ break;
case HAX_EXIT_REAL:
ret = HAX_EMUL_REAL;
break;