From 0e26711a6692b118b3148a45f9576e9b3c8b8e3a Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Mon, 19 Oct 2009 11:20:42 -0200 Subject: [PATCH] use handle_io upstream version. We can use upstream version of handle_io, there called kvm_handle_io() Signed-off-by: Glauber Costa Signed-off-by: Marcelo Tosatti --- 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 0a8aa4c27b..5e03cd944d 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 b58a45729d..9f2a153ab0 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); -- 2.11.4.GIT