From patchwork Mon Oct 19 13:20:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 54779 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9JDLI30016282 for ; Mon, 19 Oct 2009 13:21:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756161AbZJSNUq (ORCPT ); Mon, 19 Oct 2009 09:20:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756080AbZJSNUp (ORCPT ); Mon, 19 Oct 2009 09:20:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16824 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756151AbZJSNUo (ORCPT ); Mon, 19 Oct 2009 09:20:44 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9JDKmEs020292 for ; Mon, 19 Oct 2009 09:20:49 -0400 Received: from localhost.localdomain (vpn-12-73.rdu.redhat.com [10.11.12.73]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9JDKjZn029555; Mon, 19 Oct 2009 09:20:47 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 1/3] use handle_io upstream version. Date: Mon, 19 Oct 2009 11:20:42 -0200 Message-Id: <1255958444-18259-2-git-send-email-glommer@redhat.com> In-Reply-To: <1255958444-18259-1-git-send-email-glommer@redhat.com> References: <1255958444-18259-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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);