From patchwork Wed Jul 29 17:43:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 38199 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 n6THhGHn031754 for ; Wed, 29 Jul 2009 17:43:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751284AbZG2RnN (ORCPT ); Wed, 29 Jul 2009 13:43:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750912AbZG2RnN (ORCPT ); Wed, 29 Jul 2009 13:43:13 -0400 Received: from mx2.redhat.com ([66.187.237.31]:42837 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780AbZG2RnM (ORCPT ); Wed, 29 Jul 2009 13:43:12 -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 n6THhDKD030609 for ; Wed, 29 Jul 2009 13:43:13 -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 n6THhCYS024688; Wed, 29 Jul 2009 13:43:12 -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 n6THhBdY016265; Wed, 29 Jul 2009 13:43:11 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH] use upstream fields for irqchip and pit Date: Wed, 29 Jul 2009 13:43:11 -0400 Message-Id: <1248889391-24935-1-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 Upstream gained fields for irqchip_in_kernel and pit_in_kernel in KVMState. Remove them from kvm_context, and use them. Since we are still copying the KVMState structure, add those fields in our copy too. Signed-off-by: Glauber Costa --- kvm-all.c | 2 ++ qemu-kvm-x86.c | 20 ++++++++++---------- qemu-kvm.c | 24 +++++++----------------- qemu-kvm.h | 14 ++++++-------- 4 files changed, 25 insertions(+), 35 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index f17bf91..5a4184b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -155,6 +155,7 @@ static void kvm_reset_vcpu(void *opaque) abort(); } } +#endif int kvm_irqchip_in_kernel(void) { @@ -166,6 +167,7 @@ int kvm_pit_in_kernel(void) return kvm_state->pit_in_kernel; } +#ifdef KVM_UPSTREAM int kvm_init_vcpu(CPUState *env) { diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 492dbc5..40a90bf 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -119,13 +119,13 @@ static int kvm_create_pit(kvm_context_t kvm) #ifdef KVM_CAP_PIT int r; - kvm->pit_in_kernel = 0; + kvm_state->pit_in_kernel = 0; if (!kvm->no_pit_creation) { r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_PIT); if (r > 0) { r = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT); if (r >= 0) - kvm->pit_in_kernel = 1; + kvm_state->pit_in_kernel = 1; else { fprintf(stderr, "Create kernel PIC irqchip failed\n"); return r; @@ -284,7 +284,7 @@ int kvm_destroy_memory_alias(kvm_context_t kvm, uint64_t phys_start) int kvm_get_lapic(kvm_vcpu_context_t vcpu, struct kvm_lapic_state *s) { int r; - if (!kvm_irqchip_in_kernel(vcpu->kvm)) + if (!kvm_irqchip_in_kernel()) return 0; r = ioctl(vcpu->fd, KVM_GET_LAPIC, s); if (r == -1) { @@ -297,7 +297,7 @@ int kvm_get_lapic(kvm_vcpu_context_t vcpu, struct kvm_lapic_state *s) int kvm_set_lapic(kvm_vcpu_context_t vcpu, struct kvm_lapic_state *s) { int r; - if (!kvm_irqchip_in_kernel(vcpu->kvm)) + if (!kvm_irqchip_in_kernel()) return 0; r = ioctl(vcpu->fd, KVM_SET_LAPIC, s); if (r == -1) { @@ -313,14 +313,14 @@ int kvm_set_lapic(kvm_vcpu_context_t vcpu, struct kvm_lapic_state *s) int kvm_get_pit(kvm_context_t kvm, struct kvm_pit_state *s) { - if (!kvm->pit_in_kernel) + if (!kvm_state->pit_in_kernel) return 0; return kvm_vm_ioctl(kvm_state, KVM_GET_PIT, s); } int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s) { - if (!kvm->pit_in_kernel) + if (!kvm_state->pit_in_kernel) return 0; return kvm_vm_ioctl(kvm_state, KVM_SET_PIT, s); } @@ -328,14 +328,14 @@ int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s) #ifdef KVM_CAP_PIT_STATE2 int kvm_get_pit2(kvm_context_t kvm, struct kvm_pit_state2 *ps2) { - if (!kvm->pit_in_kernel) + if (!kvm_state->pit_in_kernel) return 0; return kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, ps2); } int kvm_set_pit2(kvm_context_t kvm, struct kvm_pit_state2 *ps2) { - if (!kvm->pit_in_kernel) + if (!kvm_state->pit_in_kernel) return 0; return kvm_vm_ioctl(kvm_state, KVM_SET_PIT2, ps2); } @@ -1374,7 +1374,7 @@ int kvm_arch_halt(void *opaque, kvm_vcpu_context_t vcpu) void kvm_arch_pre_kvm_run(void *opaque, CPUState *env) { - if (!kvm_irqchip_in_kernel(kvm_context)) + if (!kvm_irqchip_in_kernel()) kvm_set_cr8(env->kvm_cpu_state.vcpu_ctx, cpu_get_apic_tpr(env)); } @@ -1448,7 +1448,7 @@ void kvm_arch_cpu_reset(CPUState *env) { kvm_arch_load_regs(env); if (!cpu_is_bsp(env)) { - if (kvm_irqchip_in_kernel(kvm_context)) { + if (kvm_irqchip_in_kernel()) { #ifdef KVM_CAP_MP_STATE kvm_reset_mpstate(env->kvm_cpu_state.vcpu_ctx); #endif diff --git a/qemu-kvm.c b/qemu-kvm.c index 32dce4a..352e4cd 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -528,7 +528,7 @@ void kvm_create_irqchip(kvm_context_t kvm) { int r; - kvm->irqchip_in_kernel = 0; + kvm_state->irqchip_in_kernel = 0; #ifdef KVM_CAP_IRQCHIP if (!kvm->no_irqchip_creation) { r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_IRQCHIP); @@ -542,7 +542,7 @@ void kvm_create_irqchip(kvm_context_t kvm) if (r > 0) kvm->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS; #endif - kvm->irqchip_in_kernel = 1; + kvm_state->irqchip_in_kernel = 1; } else fprintf(stderr, "Create kernel PIC irqchip failed\n"); @@ -714,7 +714,7 @@ int kvm_set_irq_level(kvm_context_t kvm, int irq, int level, int *status) struct kvm_irq_level event; int r; - if (!kvm->irqchip_in_kernel) + if (!kvm_state->irqchip_in_kernel) return 0; event.level = level; event.irq = irq; @@ -738,7 +738,7 @@ int kvm_get_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) { int r; - if (!kvm->irqchip_in_kernel) + if (!kvm_state->irqchip_in_kernel) return 0; r = kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, chip); if (r < 0) { @@ -751,7 +751,7 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) { int r; - if (!kvm->irqchip_in_kernel) + if (!kvm_state->irqchip_in_kernel) return 0; r = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, chip); if (r < 0) { @@ -958,7 +958,7 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env) again: push_nmi(kvm); #if !defined(__s390__) - if (!kvm->irqchip_in_kernel) + if (!kvm_state->irqchip_in_kernel) run->request_interrupt_window = kvm_arch_try_push_interrupts(env); #endif r = pre_kvm_run(kvm, env); @@ -1092,16 +1092,6 @@ int kvm_set_signal_mask(kvm_vcpu_context_t vcpu, const sigset_t *sigset) return r; } -int kvm_irqchip_in_kernel(kvm_context_t kvm) -{ - return kvm->irqchip_in_kernel; -} - -int kvm_pit_in_kernel(kvm_context_t kvm) -{ - return kvm->pit_in_kernel; -} - int kvm_has_sync_mmu(void) { int r = 0; @@ -1859,7 +1849,7 @@ static int kvm_main_loop_cpu(CPUState *env) while (1) { int run_cpu = !is_cpu_stopped(env); - if (run_cpu && !kvm_irqchip_in_kernel(kvm_context)) { + if (run_cpu && !kvm_irqchip_in_kernel()) { process_irqchip_events(env); run_cpu = !env->halted; } diff --git a/qemu-kvm.h b/qemu-kvm.h index eb48ff8..40a7a2f 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -57,14 +57,10 @@ struct kvm_context { int dirty_pages_log_all; /// do not create in-kernel irqchip if set int no_irqchip_creation; - /// in-kernel irqchip status - int irqchip_in_kernel; /// ioctl to use to inject interrupts int irqchip_inject_ioctl; /// do not create in-kernel pit if set int no_pit_creation; - /// in-kernel pit status - int pit_in_kernel; /// in-kernel coalesced mmio int coalesced_mmio; #ifdef KVM_CAP_IRQ_ROUTING @@ -553,7 +549,7 @@ int kvm_dirty_pages_log_reset(kvm_context_t kvm); * * \param kvm Pointer to the current kvm_context */ -int kvm_irqchip_in_kernel(kvm_context_t kvm); +int kvm_irqchip_in_kernel(void); #ifdef KVM_CAP_IRQCHIP /*! @@ -637,7 +633,7 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, * * \param kvm Pointer to the current kvm_context */ -int kvm_pit_in_kernel(kvm_context_t kvm); +int kvm_pit_in_kernel(void); /*! * \brief Initialize coalesced MMIO @@ -1099,8 +1095,8 @@ int handle_tpr_access(void *opaque, kvm_vcpu_context_t vcpu, int kvm_has_sync_mmu(void); #define kvm_enabled() (kvm_allowed) -#define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context) -#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context) +#define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel() +#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel() #define qemu_kvm_has_gsi_routing() kvm_has_gsi_routing(kvm_context) #ifdef TARGET_I386 #define qemu_kvm_has_pit_state2() kvm_has_pit_state2(kvm_context) @@ -1202,6 +1198,8 @@ typedef struct KVMState #ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint_head kvm_sw_breakpoints; #endif + int irqchip_in_kernel; + int pit_in_kernel; struct kvm_context kvm_context; } KVMState;