Patchwork [HACK] make vmmouse work with KVM

login
register
mail settings
Submitter Reimar Döffinger
Date Aug. 17, 2009, 2:47 p.m.
Message ID <20090817144754.GA31553@1und1.de>
Download mbox | patch
Permalink /patch/31522/
State Superseded
Headers show

Comments

Reimar Döffinger - Aug. 17, 2009, 2:47 p.m.
Hello,
vmmouse uses a giant hack: it uses io ports (in instruction) but passes
data via registers.
This currently does not work since the qemu CPU registers are
(understandably) not kept in sync with the real KVM registers for this
operation.
Attached patch detects access to the vmmouse port and loads/stores CPU
registers into/from the QEMU state.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Anthony Liguori - Aug. 17, 2009, 3:11 p.m.
Reimar Döffinger wrote:
> Hello,
> vmmouse uses a giant hack: it uses io ports (in instruction) but passes
> data via registers.
> This currently does not work since the qemu CPU registers are
> (understandably) not kept in sync with the real KVM registers for this
> operation.
> Attached patch detects access to the vmmouse port and loads/stores CPU
> registers into/from the QEMU state.
>   

Should use cpu_synchronize_state() in vmport.c

> Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
>   

Regards,

Anthony Liguori

Patch

diff --git a/kvm-all.c b/kvm-all.c
index f669c3a..207378b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -611,11 +611,21 @@  int kvm_cpu_exec(CPUState *env)
         switch (run->exit_reason) {
         case KVM_EXIT_IO:
             dprintf("handle_io\n");
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+            // HACK to make vmport/vmmouse work
+            if (run->io.port == 0x5658)
+                kvm_arch_get_registers(env);
+#endif
             ret = kvm_handle_io(env, run->io.port,
                                 (uint8_t *)run + run->io.data_offset,
                                 run->io.direction,
                                 run->io.size,
                                 run->io.count);
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+            // HACK to make vmport/vmmouse work
+            if (run->io.port == 0x5658)
+                kvm_arch_put_registers(env);
+#endif
             break;
         case KVM_EXIT_MMIO:
             dprintf("handle_mmio\n");