From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: [PATCH 02/10] drop kvm_mmio_read and write Date: Fri, 9 Oct 2009 15:03:10 -0300 Message-ID: <1255111398-15251-3-git-send-email-glommer@redhat.com> References: <1255111398-15251-1-git-send-email-glommer@redhat.com> <1255111398-15251-2-git-send-email-glommer@redhat.com> Cc: avi@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47741 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761193AbZJISDv (ORCPT ); Fri, 9 Oct 2009 14:03:51 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n99I3PYW025519 for ; Fri, 9 Oct 2009 14:03:25 -0400 In-Reply-To: <1255111398-15251-2-git-send-email-glommer@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: they are just a tiny wrapper around qemu memory functions. Drop' em Signed-off-by: Glauber Costa --- qemu-kvm-x86.c | 7 +------ qemu-kvm.c | 24 ++++-------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index a44ae67..e8ec59d 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, 1); 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 6bda694..4ad6856 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -111,18 +111,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); @@ -891,7 +879,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state) static int 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; @@ -899,10 +886,8 @@ static int handle_mmio(kvm_vcpu_context_t vcpu) if ((addr > 0xa0000 - 4 && addr <= 0xa0000) && kvm_run->mmio.len == 3) return 0; - 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); + return 0; } int handle_io_window(kvm_context_t kvm) @@ -994,10 +979,9 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env) 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, + cpu_physical_memory_rw(ring->coalesced_mmio[ring->first].phys_addr, &ring->coalesced_mmio[ring->first].data[0], - ring->coalesced_mmio[ring->first].len); + ring->coalesced_mmio[ring->first].len, 1); smp_wmb(); ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX; } -- 1.6.2.5