Re: qemu-kvm requires apic initialized before vcpu main loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 09, 2009 at 10:01:36PM +0100, Jan Kiszka wrote:
> Gleb Natapov wrote:
> > On Wed, Dec 09, 2009 at 09:09:54PM +0100, Jan Kiszka wrote:
> >> Gleb Natapov wrote:
> >>> 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 <mtosatti@xxxxxxxxxx>
> >>>>>
> >>>>> 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,
> >>> Write back of mp state there is a bug and introduce races. Do write back
> >>> of the whole APIC state there looks like a recipe for disaster.
> >> Please read the full suggestion: We will only write-back if we were
> >> going through a reset or vmload before. That removes the ugly kvm hooks
> >> from generic code and ensures proper ordering /wrt other write-backs.
> >> IMHO, anything else will continue to cause headache like the above to us.
> >>
> > We can't postpone APIC loading till vmrun. This will race with
> > devices/other vcpus sending interrupts to the vcpu. APIC state of all
> > vcpus should be up-to-date _before_ any vcpu or main loop starts
> > running.
> 
> Simple to solve, just add another write-back point: vm_start.
> 
So what's the point to have write-back for APIC in vmrun? It is always
wrong to do it there.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux