From patchwork Tue Feb 2 08:19:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 76326 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 o128KHYC032259 for ; Tue, 2 Feb 2010 08:20:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983Ab0BBITo (ORCPT ); Tue, 2 Feb 2010 03:19:44 -0500 Received: from thoth.sbs.de ([192.35.17.2]:20602 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754623Ab0BBITh (ORCPT ); Tue, 2 Feb 2010 03:19:37 -0500 Received: from mail2.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id o128JH2p010342; Tue, 2 Feb 2010 09:19:17 +0100 Received: from localhost.localdomain ([139.25.173.39]) by mail2.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o128J7sZ008551; Tue, 2 Feb 2010 09:19:16 +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 19/21] qemu-kvm: Clean up KVM's APIC hooks Date: Tue, 2 Feb 2010 09:19:05 +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:20:17 +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 4b78570..9de018e 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -974,6 +974,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); } kvm_put_vcpu_events(env, level); @@ -1134,6 +1135,7 @@ void kvm_arch_save_regs(CPUState *env) } } kvm_arch_save_mpstate(env); + kvm_save_lapic(env); kvm_get_vcpu_events(env); } @@ -1207,8 +1209,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 2af206c..fea23a4 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);