[PATCH 1/3] use handle_io upstream version.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can use upstream version of handle_io, there called kvm_handle_io()

Signed-off-by: Glauber Costa <glommer@xxxxxxxxxx>
---
 kvm-all.c  |    2 ++
 qemu-kvm.c |   58 +++++-----------------------------------------------------
 2 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 5ea999e..5a7be5b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -520,6 +520,7 @@ err:
 
     return ret;
 }
+#endif
 
 static int kvm_handle_io(uint16_t port, void *data, int direction, int size,
                          uint32_t count)
@@ -560,6 +561,7 @@ static int kvm_handle_io(uint16_t port, void *data, int direction, int size,
     return 1;
 }
 
+#ifdef KVM_UPSTREAM
 static void kvm_run_coalesced_mmio(CPUState *env, struct kvm_run *run)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 91cfc32..ad00560 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -751,58 +751,6 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip)
 
 #endif
 
-static int handle_io(CPUState *env)
-{
-    struct kvm_run *run = env->kvm_run;
-    uint16_t addr = run->io.port;
-    int i;
-    void *p = (void *) run + run->io.data_offset;
-
-    for (i = 0; i < run->io.count; ++i) {
-        switch (run->io.direction) {
-        case KVM_EXIT_IO_IN:
-            switch (run->io.size) {
-            case 1:
-                *(uint8_t *) p = cpu_inb(addr);
-                break;
-            case 2:
-                *(uint16_t *) p = cpu_inw(addr);
-                break;
-            case 4:
-                *(uint32_t *) p = cpu_inl(addr);
-                break;
-            default:
-                fprintf(stderr, "bad I/O size %d\n", run->io.size);
-                return -EMSGSIZE;
-            }
-            break;
-        case KVM_EXIT_IO_OUT:
-            switch (run->io.size) {
-            case 1:
-                cpu_outb(addr, *(uint8_t *) p);
-                break;
-            case 2:
-                cpu_outw(addr, *(uint16_t *) p);
-                break;
-            case 4:
-                cpu_outl(addr, *(uint32_t *) p);
-                break;
-            default:
-                fprintf(stderr, "bad I/O size %d\n", run->io.size);
-                return -EMSGSIZE;
-            }
-            break;
-        default:
-            fprintf(stderr, "bad I/O direction %d\n", run->io.direction);
-            return -EPROTO;
-        }
-
-        p += run->io.size;
-    }
-
-    return 0;
-}
-
 static int handle_debug(CPUState *env)
 {
 #ifdef KVM_CAP_SET_GUEST_DEBUG
@@ -994,7 +942,11 @@ int kvm_run(CPUState *env)
             abort();
             break;
         case KVM_EXIT_IO:
-            r = handle_io(env);
+            r = kvm_handle_io(run->io.port,
+                                (uint8_t *)run + run->io.data_offset,
+                                run->io.direction,
+                                run->io.size,
+                                run->io.count);
             break;
         case KVM_EXIT_DEBUG:
             r = handle_debug(env);
-- 
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux