From patchwork Wed Jul 29 17:49:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 38208 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 n6THnbPn032673 for ; Wed, 29 Jul 2009 17:49:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbZG2Rte (ORCPT ); Wed, 29 Jul 2009 13:49:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751887AbZG2Rtd (ORCPT ); Wed, 29 Jul 2009 13:49:33 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57765 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751474AbZG2RtX (ORCPT ); Wed, 29 Jul 2009 13:49:23 -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 n6THnNgN032746 for ; Wed, 29 Jul 2009 13:49:23 -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 n6THnMw8027921; Wed, 29 Jul 2009 13:49:22 -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 n6THnJho017691; Wed, 29 Jul 2009 13:49:21 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 4/9] remove opaque field from kvm_context Date: Wed, 29 Jul 2009 13:49:14 -0400 Message-Id: <1248889759-25063-5-git-send-email-glommer@redhat.com> In-Reply-To: <1248889759-25063-4-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> <1248889759-25063-3-git-send-email-glommer@redhat.com> <1248889759-25063-4-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 use vcpu->env whenever possible. It does lead to some strange things like kvm_arch_pre_kvm_run(env, env), but I'm not fixing it here so as to not mix things up. Will do that in a separate patch in the future. Signed-off-by: Glauber Costa --- qemu-kvm.c | 36 +++++++++++++++--------------------- qemu-kvm.h | 1 - 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index ba937ca..47846b3 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -376,7 +376,6 @@ int kvm_init(int smp_cpus) kvm_state->fd = fd; kvm_state->vmfd = -1; - kvm_context->opaque = cpu_single_env; kvm_context->dirty_pages_log_all = 0; kvm_context->no_irqchip_creation = 0; kvm_context->no_pit_creation = 0; @@ -754,7 +753,6 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) static int handle_io(kvm_vcpu_context_t vcpu) { struct kvm_run *run = vcpu->run; - kvm_context_t kvm = vcpu->kvm; uint16_t addr = run->io.port; int i; void *p = (void *)run + run->io.data_offset; @@ -764,13 +762,13 @@ static int handle_io(kvm_vcpu_context_t vcpu) case KVM_EXIT_IO_IN: switch (run->io.size) { case 1: - *(uint8_t *)p = cpu_inb(kvm->opaque, addr); + *(uint8_t *)p = cpu_inb(vcpu->env, addr); break; case 2: - *(uint16_t *)p = cpu_inw(kvm->opaque, addr); + *(uint16_t *)p = cpu_inw(vcpu->env, addr); break; case 4: - *(uint32_t *)p = cpu_inl(kvm->opaque, addr); + *(uint32_t *)p = cpu_inl(vcpu->env, addr); break; default: fprintf(stderr, "bad I/O size %d\n", run->io.size); @@ -780,13 +778,13 @@ static int handle_io(kvm_vcpu_context_t vcpu) case KVM_EXIT_IO_OUT: switch (run->io.size) { case 1: - cpu_outb(kvm->opaque, addr, *(uint8_t *)p); + cpu_outb(vcpu->env, addr, *(uint8_t *)p); break; case 2: - cpu_outw(kvm->opaque, addr, *(uint16_t *)p); + cpu_outw(vcpu->env, addr, *(uint16_t *)p); break; case 4: - cpu_outl(kvm->opaque, addr, *(uint32_t *)p); + cpu_outl(vcpu->env, addr, *(uint32_t *)p); break; default: fprintf(stderr, "bad I/O size %d\n", run->io.size); @@ -808,9 +806,8 @@ int handle_debug(kvm_vcpu_context_t vcpu, void *env) { #ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_run *run = vcpu->run; - kvm_context_t kvm = vcpu->kvm; - return kvm_debug(kvm->opaque, env, &run->debug.arch); + return kvm_debug(vcpu->env, env, &run->debug.arch); #else return 0; #endif @@ -888,7 +885,7 @@ int handle_io_window(kvm_context_t kvm) int handle_halt(kvm_vcpu_context_t vcpu) { - return kvm_arch_halt(vcpu->kvm->opaque, vcpu); + return kvm_arch_halt(vcpu->env, vcpu); } int handle_shutdown(kvm_context_t kvm, CPUState *env) @@ -900,22 +897,15 @@ int handle_shutdown(kvm_context_t kvm, CPUState *env) return 1; } -static inline void push_nmi(kvm_context_t kvm) -{ -#ifdef KVM_CAP_USER_NMI - kvm_arch_push_nmi(kvm->opaque); -#endif /* KVM_CAP_USER_NMI */ -} - void post_kvm_run(kvm_context_t kvm, CPUState *env) { pthread_mutex_lock(&qemu_mutex); - kvm_arch_post_kvm_run(kvm->opaque, env); + kvm_arch_post_kvm_run(env, env); } int pre_kvm_run(kvm_context_t kvm, CPUState *env) { - kvm_arch_pre_kvm_run(kvm->opaque, env); + kvm_arch_pre_kvm_run(env, env); pthread_mutex_unlock(&qemu_mutex); return 0; @@ -939,7 +929,11 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env) kvm_context_t kvm = vcpu->kvm; again: - push_nmi(kvm); + +#ifdef KVM_CAP_USER_NMI + kvm_arch_push_nmi(vcpu->env); +#endif /* KVM_CAP_USER_NMI */ + #if !defined(__s390__) if (!kvm_state->irqchip_in_kernel) run->request_interrupt_window = kvm_arch_try_push_interrupts(env); diff --git a/qemu-kvm.h b/qemu-kvm.h index 440afba..3f14f13 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -52,7 +52,6 @@ extern int kvm_abi; */ struct kvm_context { - void *opaque; /// is dirty pages logging enabled for all regions or not int dirty_pages_log_all; /// do not create in-kernel irqchip if set