From patchwork Wed Jul 29 17:49:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 38200 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 n6THnTAm032593 for ; Wed, 29 Jul 2009 17:49:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751655AbZG2RtY (ORCPT ); Wed, 29 Jul 2009 13:49:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751620AbZG2RtY (ORCPT ); Wed, 29 Jul 2009 13:49:24 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57763 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbZG2RtV (ORCPT ); Wed, 29 Jul 2009 13:49:21 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6THnMHV032736 for ; Wed, 29 Jul 2009 13:49:22 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6THnLQB027913; Wed, 29 Jul 2009 13:49:21 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6THnJhm017691; Wed, 29 Jul 2009 13:49:20 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 2/9] remove kvm_mmio_read and kvm_mmio_write Date: Wed, 29 Jul 2009 13:49:12 -0400 Message-Id: <1248889759-25063-3-git-send-email-glommer@redhat.com> In-Reply-To: <1248889759-25063-2-git-send-email-glommer@redhat.com> References: <1248889759-25063-1-git-send-email-glommer@redhat.com> <1248889759-25063-2-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org all they did was to call a qemu function. Call this function instead. Signed-off-by: Glauber Costa --- qemu-kvm-x86.c | 7 +------ qemu-kvm.c | 34 ++++++++-------------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 40a90bf..76c7631 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -364,7 +364,6 @@ void kvm_show_code(kvm_vcpu_context_t vcpu) unsigned char code; char code_str[SHOW_CODE_LEN * 3 + 1]; unsigned long rip; - kvm_context_t kvm = vcpu->kvm; r = ioctl(fd, KVM_GET_SREGS, &sregs); if (r == -1) { @@ -384,11 +383,7 @@ void kvm_show_code(kvm_vcpu_context_t vcpu) for (n = -back_offset; n < SHOW_CODE_LEN-back_offset; ++n) { if (n == 0) strcat(code_str, " -->"); - r = kvm_mmio_read(kvm->opaque, rip + n, &code, 1); - if (r < 0) { - strcat(code_str, " xx"); - continue; - } + cpu_physical_memory_rw(rip + n, &code, 1, 0); sprintf(code_str + strlen(code_str), " %02x", code); } fprintf(stderr, "code:%s\n", code_str); diff --git a/qemu-kvm.c b/qemu-kvm.c index 8c36eac..65042d2 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -97,18 +97,6 @@ static int kvm_debug(void *opaque, void *data, } #endif -int kvm_mmio_read(void *opaque, uint64_t addr, uint8_t *data, int len) -{ - cpu_physical_memory_rw(addr, data, len, 0); - return 0; -} - -int kvm_mmio_write(void *opaque, uint64_t addr, uint8_t *data, int len) -{ - cpu_physical_memory_rw(addr, data, len, 1); - return 0; -} - static int handle_unhandled(uint64_t reason) { fprintf(stderr, "kvm: unhandled exit %"PRIx64"\n", reason); @@ -879,23 +867,17 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state) } #endif -static int handle_mmio(kvm_vcpu_context_t vcpu) +static void handle_mmio(kvm_vcpu_context_t vcpu) { unsigned long addr = vcpu->run->mmio.phys_addr; - kvm_context_t kvm = vcpu->kvm; struct kvm_run *kvm_run = vcpu->run; void *data = kvm_run->mmio.data; /* hack: Red Hat 7.1 generates these weird accesses. */ if ((addr > 0xa0000-4 && addr <= 0xa0000) && kvm_run->mmio.len == 3) - return 0; + return; - if (kvm_run->mmio.is_write) - return kvm_mmio_write(kvm->opaque, addr, data, - kvm_run->mmio.len); - else - return kvm_mmio_read(kvm->opaque, addr, data, - kvm_run->mmio.len); + cpu_physical_memory_rw(addr, data, kvm_run->mmio.len, kvm_run->mmio.is_write); } int handle_io_window(kvm_context_t kvm) @@ -980,10 +962,9 @@ again: struct kvm_coalesced_mmio_ring *ring = (void *)run + kvm_state->coalesced_mmio * PAGE_SIZE; while (ring->first != ring->last) { - kvm_mmio_write(kvm->opaque, - ring->coalesced_mmio[ring->first].phys_addr, - &ring->coalesced_mmio[ring->first].data[0], - ring->coalesced_mmio[ring->first].len); + cpu_physical_memory_rw(ring->coalesced_mmio[ring->first].phys_addr, + &ring->coalesced_mmio[ring->first].data[0], + ring->coalesced_mmio[ring->first].len, 1); smp_wmb(); ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX; @@ -1020,7 +1001,8 @@ again: r = handle_debug(vcpu, env); break; case KVM_EXIT_MMIO: - r = handle_mmio(vcpu); + r = 0; + handle_mmio(vcpu); break; case KVM_EXIT_HLT: r = handle_halt(vcpu);