From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: qemu-kvm requires apic initialized before vcpu main loop Date: Wed, 9 Dec 2009 18:02:27 -0200 Message-ID: <20091209200227.GA28264@amt.cnet> References: <20091209174654.GA28056@amt.cnet> <4B1FEB2A.3090906@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Glauber de Oliveira Costa , kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63609 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757654AbZLIUOS (ORCPT ); Wed, 9 Dec 2009 15:14:18 -0500 Content-Disposition: inline In-Reply-To: <4B1FEB2A.3090906@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 09, 2009 at 07:23:38PM +0100, Jan Kiszka wrote: > Marcelo Tosatti wrote: > > Otherwise a zero apic base is loaded into KVM, which results > > in interrupts being lost until a proper apic base with enabled > > bit set is loaded. > > > > Fixes WinXP migration in qemu-kvm origin/next. > > > > Signed-off-by: Marcelo Tosatti > > > > diff --git a/hw/apic.c b/hw/apic.c > > index 627ff98..45a4d2b 100644 > > --- a/hw/apic.c > > +++ b/hw/apic.c > > @@ -1131,6 +1131,11 @@ 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; > > } > > Heals the issue I saw with Win2003 Server as well. > > Looks all a bit messy though. Hope we can establish a more regular and > less fragile model on the midterm. I wonder if it wouldn't be better to > do write-back of the local APIC state along with the register state on > vmrun (and only there!). The same would apply to things like mpstate, > TSC MSR, or the guest debugging state. The reset/vmloading/hw-emulation > code would only declare what kind of write-back it wishes: register > state only, partial (excluding everything that touches continuously > running timers), full. Well, basically the model I suggested for proper > mpstate write-back, just even more generalized. I suppose that works, but "regs_modified" needs to be broken down. Something similar to kvm_register_write / kvm_register_read in the kernel.