From patchwork Tue Feb 2 08:18:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 76319 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o128JmrA030581 for ; Tue, 2 Feb 2010 08:19:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755098Ab0BBITr (ORCPT ); Tue, 2 Feb 2010 03:19:47 -0500 Received: from goliath.siemens.de ([192.35.17.28]:18344 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754883Ab0BBITn (ORCPT ); Tue, 2 Feb 2010 03:19:43 -0500 Received: from mail2.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o128JCv2013831; Tue, 2 Feb 2010 09:19:12 +0100 Received: from localhost.localdomain ([139.25.173.39]) by mail2.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o128J7sP008551; Tue, 2 Feb 2010 09:19:12 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Anthony Liguori , Alexander Graf , Glauber Costa , qemu-devel@nongnu.org Subject: [PATCH 09/21] qemu-kvm: Use upstream kvm_pit_in_kernel Date: Tue, 2 Feb 2010 09:18:55 +0100 Message-Id: X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 08:19:49 +0000 (UTC) diff --git a/hw/i8254.c b/hw/i8254.c index db9e94a..1add08e 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -491,7 +491,7 @@ void hpet_disable_pit(void) { PITChannelState *s = &pit_state.channels[0]; - if (kvm_enabled() && qemu_kvm_pit_in_kernel()) { + if (kvm_enabled() && kvm_pit_in_kernel()) { if (qemu_kvm_has_pit_state2()) { kvm_hpet_disable_kpit(); } else { @@ -515,7 +515,7 @@ void hpet_enable_pit(void) PITState *pit = &pit_state; PITChannelState *s = &pit->channels[0]; - if (kvm_enabled() && qemu_kvm_pit_in_kernel()) { + if (kvm_enabled() && kvm_pit_in_kernel()) { if (qemu_kvm_has_pit_state2()) { kvm_hpet_enable_kpit(); } else { diff --git a/hw/pc.c b/hw/pc.c index dac373e..7a7dfa7 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -951,7 +951,7 @@ static void pc_init1(ram_addr_t ram_size, ioapic_irq_hack = isa_irq; } #ifdef CONFIG_KVM_PIT - if (kvm_enabled() && qemu_kvm_pit_in_kernel()) + if (kvm_enabled() && kvm_pit_in_kernel()) pit = kvm_pit_init(0x40, isa_reserve_irq(0)); else #endif diff --git a/hw/pcspk.c b/hw/pcspk.c index 128836b..fb5f763 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -56,7 +56,7 @@ static void kvm_get_pit_ch2(PITState *pit, { struct kvm_pit_state pit_state; - if (kvm_enabled() && qemu_kvm_pit_in_kernel()) { + if (kvm_enabled() && kvm_pit_in_kernel()) { kvm_get_pit(kvm_context, &pit_state); pit->channels[2].mode = pit_state.channels[2].mode; pit->channels[2].count = pit_state.channels[2].count; @@ -71,7 +71,7 @@ static void kvm_get_pit_ch2(PITState *pit, static void kvm_set_pit_ch2(PITState *pit, struct kvm_pit_state *inkernel_state) { - if (kvm_enabled() && qemu_kvm_pit_in_kernel()) { + if (kvm_enabled() && kvm_pit_in_kernel()) { inkernel_state->channels[2].mode = pit->channels[2].mode; inkernel_state->channels[2].count = pit->channels[2].count; inkernel_state->channels[2].count_load_time = diff --git a/kvm-all.c b/kvm-all.c index e7fa605..6cbca97 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -164,13 +164,13 @@ int kvm_irqchip_in_kernel(void) return kvm_state->irqchip_in_kernel; } -#ifdef KVM_UPSTREAM int kvm_pit_in_kernel(void) { return kvm_state->pit_in_kernel; } +#ifdef KVM_UPSTREAM int kvm_init_vcpu(CPUState *env) { KVMState *s = kvm_state; diff --git a/kvm.h b/kvm.h index 189a5d4..253b45d 100644 --- a/kvm.h +++ b/kvm.h @@ -68,10 +68,10 @@ int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr, target_ulong len, int type); void kvm_remove_all_breakpoints(CPUState *current_env); int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap); +#endif /* KVM_UPSTREAM */ int kvm_pit_in_kernel(void); int kvm_irqchip_in_kernel(void); -#endif /* KVM_UPSTREAM */ /* internal API */ diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 0457a6e..074b510 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; @@ -311,14 +311,14 @@ int kvm_set_lapic(CPUState *env, 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_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_pit_in_kernel()) return 0; return kvm_vm_ioctl(kvm_state, KVM_SET_PIT, s); } @@ -326,14 +326,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_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_pit_in_kernel()) return 0; return kvm_vm_ioctl(kvm_state, KVM_SET_PIT2, ps2); } diff --git a/qemu-kvm.c b/qemu-kvm.c index 12442a7..3ad0ec7 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1040,11 +1040,6 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset) return r; } -int kvm_pit_in_kernel(kvm_context_t kvm) -{ - return kvm->pit_in_kernel; -} - int kvm_inject_nmi(CPUState *env) { #ifdef KVM_CAP_USER_NMI diff --git a/qemu-kvm.h b/qemu-kvm.h index 7b75fdd..4c687ce 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -64,8 +64,6 @@ struct kvm_context { int irqchip_inject_ioctl; /// do not create in-kernel pit if set int no_pit_creation; - /// in-kernel pit status - int pit_in_kernel; #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; @@ -563,13 +561,6 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, int abort_on_error); /*! - * \brief Query wheather in kernel pit is used - * - * \param kvm Pointer to the current kvm_context - */ -int kvm_pit_in_kernel(kvm_context_t kvm); - -/*! * \brief Initialize coalesced MMIO * * Check for coalesced MMIO capability and store in context @@ -1014,7 +1005,6 @@ int kvm_arch_halt(CPUState *env); int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip, int is_write); -#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context) #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) @@ -1022,7 +1012,6 @@ int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip, void kvm_load_tsc(CPUState *env); #else #define kvm_nested 0 -#define qemu_kvm_pit_in_kernel() (0) #define qemu_kvm_has_gsi_routing() (0) #ifdef TARGET_I386 #define qemu_kvm_has_pit_state2() (0) @@ -1055,7 +1044,6 @@ static inline int kvm_set_migration_log(int enable) } -int kvm_irqchip_in_kernel(void); #ifdef CONFIG_KVM typedef struct KVMSlot { @@ -1080,6 +1068,7 @@ struct KVMState { QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; #endif int irqchip_in_kernel; + int pit_in_kernel; struct kvm_context kvm_context; };