From patchwork Wed Feb 3 08:53:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 76639 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 o138saOZ011671 for ; Wed, 3 Feb 2010 08:54:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755643Ab0BCIyd (ORCPT ); Wed, 3 Feb 2010 03:54:33 -0500 Received: from thoth.sbs.de ([192.35.17.2]:21187 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756091Ab0BCIy3 (ORCPT ); Wed, 3 Feb 2010 03:54:29 -0500 Received: from mail3.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id o138rwLA025996; Wed, 3 Feb 2010 09:53:58 +0100 Received: from localhost.localdomain ([139.25.173.28]) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o138rkCK012112; Wed, 3 Feb 2010 09:53:58 +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 v2 19/21] qemu-kvm: Clean up KVM's APIC hooks Date: Wed, 3 Feb 2010 09:53:44 +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]); Wed, 03 Feb 2010 08:54:36 +0000 (UTC) diff --git a/hw/apic.c b/hw/apic.c index 092c61e..d8c4f7c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -24,8 +24,6 @@ #include "host-utils.h" #include "kvm.h" -#include "qemu-kvm.h" - //#define DEBUG_APIC /* APIC Local Vector Table */ @@ -951,36 +949,22 @@ static void kvm_kernel_lapic_load_from_user(APICState *s) #endif -void qemu_kvm_load_lapic(CPUState *env) +void kvm_load_lapic(CPUState *env) { #ifdef KVM_CAP_IRQCHIP - if (kvm_enabled() && kvm_vcpu_inited(env) && kvm_irqchip_in_kernel()) { - kvm_kernel_lapic_load_from_user(env->apic_state); - } -#endif -} - -static void apic_pre_save(void *opaque) -{ -#ifdef KVM_CAP_IRQCHIP - APICState *s = (void *)opaque; - if (kvm_enabled() && kvm_irqchip_in_kernel()) { - kvm_kernel_lapic_save_to_user(s); + kvm_kernel_lapic_load_from_user(env->apic_state); } #endif } -static int apic_post_load(void *opaque, int version_id) +void kvm_save_lapic(CPUState *env) { #ifdef KVM_CAP_IRQCHIP - APICState *s = opaque; - if (kvm_enabled() && kvm_irqchip_in_kernel()) { - kvm_kernel_lapic_load_from_user(s); + kvm_kernel_lapic_save_to_user(env->apic_state); } #endif - return 0; } /* This function is only used for old state version 1 and 2 */ @@ -1019,9 +1003,6 @@ static int apic_load_old(QEMUFile *f, void *opaque, int version_id) if (version_id >= 2) qemu_get_timer(f, s->timer); - - qemu_kvm_load_lapic(s->cpu_env); - return 0; } @@ -1052,9 +1033,7 @@ static const VMStateDescription vmstate_apic = { VMSTATE_INT64(next_time, APICState), VMSTATE_TIMER(timer, APICState), VMSTATE_END_OF_LIST() - }, - .pre_save = apic_pre_save, - .post_load = apic_post_load, + } }; static void apic_reset(void *opaque) @@ -1077,7 +1056,6 @@ static void apic_reset(void *opaque) */ s->lvt[APIC_LVT_LINT0] = 0x700; } - qemu_kvm_load_lapic(s->cpu_env); } static CPUReadMemoryFunc * const apic_mem_read[3] = { @@ -1121,11 +1099,6 @@ int apic_init(CPUState *env) vmstate_register(s->idx, &vmstate_apic, s); qemu_register_reset(apic_reset, s); - /* apic_reset must be called before the vcpu threads are initialized and load - * registers, in qemu-kvm. - */ - apic_reset(s); - local_apics[s->idx] = s; return 0; } diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index e5040c9..5cfeb6a 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -984,6 +984,7 @@ void kvm_arch_load_regs(CPUState *env, int level) if (level >= KVM_PUT_RESET_STATE) { kvm_arch_load_mpstate(env); + kvm_load_lapic(env); } if (kvm_irqchip_in_kernel()) { /* Avoid deadlock: no user space IRQ will ever clear it. */ @@ -1150,6 +1151,7 @@ void kvm_arch_save_regs(CPUState *env) } } kvm_arch_save_mpstate(env); + kvm_save_lapic(env); kvm_get_vcpu_events(env); } @@ -1223,8 +1225,6 @@ int kvm_arch_init_vcpu(CPUState *cenv) CPUState copy; uint32_t i, j, limit; - qemu_kvm_load_lapic(cenv); - kvm_arch_reset_vcpu(cenv); #ifdef KVM_CPUID_SIGNATURE diff --git a/qemu-kvm.h b/qemu-kvm.h index 4c009c9..9917569 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -864,9 +864,8 @@ static inline void kvm_inject_x86_mce(CPUState *cenv, int bank, int kvm_main_loop(void); int kvm_init_ap(void); int kvm_vcpu_inited(CPUState *env); -void kvm_apic_init(CPUState *env); -/* called from vcpu initialization */ -void qemu_kvm_load_lapic(CPUState *env); +void kvm_save_lapic(CPUState *env); +void kvm_load_lapic(CPUState *env); void kvm_hpet_enable_kpit(void); void kvm_hpet_disable_kpit(void);