From patchwork Fri Feb 19 18:22:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 45871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5F753B7D01 for ; Sat, 20 Feb 2010 05:39:37 +1100 (EST) Received: from localhost ([127.0.0.1]:39261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiXjc-0002iM-H2 for incoming@patchwork.ozlabs.org; Fri, 19 Feb 2010 13:37:52 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NiXUx-0006za-Pz for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:43 -0500 Received: from [199.232.76.173] (port=44327 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiXUx-0006zS-8G for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:43 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NiXUm-00006H-HL for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:43 -0500 Received: from goliath.siemens.de ([192.35.17.28]:22319) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NiXUl-000059-0Y for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:31 -0500 Received: from mail3.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMTFH003829; Fri, 19 Feb 2010 19:22:29 +0100 Received: from localhost.localdomain (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMRGC025400; Fri, 19 Feb 2010 19:22:29 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Fri, 19 Feb 2010 19:22:25 +0100 Message-Id: <0846616f4c83c2c3b78a1baad0d98e2b270af50a.1266603744.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Anthony Liguori , qemu-devel@nongnu.org, kvm@vger.kernel.org, Gleb Natapov Subject: [Qemu-devel] [PATCH 7/9] qemu-kvm: Use upstream kvm_pit_in_kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Drop private version in favor of recently added upstream service and track it state directly in KVMState. Signed-off-by: Jan Kiszka --- hw/i8254.c | 4 ++-- hw/pc.c | 2 +- hw/pcspk.c | 4 ++-- kvm-all.c | 2 +- kvm.h | 2 +- qemu-kvm-x86.c | 12 ++++++------ qemu-kvm.c | 5 ----- qemu-kvm.h | 13 +------------ 8 files changed, 14 insertions(+), 30 deletions(-) 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 55df58d..7add660 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -950,7 +950,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 b9c1553..2237239 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -167,13 +167,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 7f32f95..2f97c64 100644 --- a/kvm.h +++ b/kvm.h @@ -61,10 +61,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 a7bf446..2b36c22 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 5c4f6e6..9821fc5 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1049,11 +1049,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 967162c..17017c4 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) @@ -1052,7 +1041,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; };