On Wed, Dec 09, 2009 at 04:25:45PM -0200, Glauber Costa wrote:
> On Wed, Dec 09, 2009 at 03:46:54PM -0200, 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 <[email protected]>
> >
> > 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);
> > +
> But by doing this, the system-wide reset will re-reset the apic, possibly
> losing
> some other information.
The information is the same. vcpu did not run (so did not change any
information) between apic_reset and system wide reset.
> Also, system_reset happens before we signal system_ready (or at least should).
Not in qemu-kvm.c. Even if it did, it is too late (by that time vcpu
thread will have loaded APIC base of 0).
qemu-kvm.c should be updated to call system_reset, I believe, similarly
to what has been done to vl.c.
> This means the vcpus should not be running and producing anything useful yet.
> So how does it happen, in the first place?
The initialization of env->apic_base must happen before the vcpu thread calls
kvm_arch_load_regs in qemu-kvm.c.
Otherwise the vcpu thread initializes env->apic_base with value of
"0", and that in turn will result in the kernel's "apic_hw_enabled()"
returning false, so interrupt injections in that period are lost, for
one problem.
Its similar issue that this comment on hw/pc.c refers to:
/* kvm needs this to run after the apic is initialized. Otherwise,
* it can access invalid state and crash.
*/
qemu_init_vcpu(env);
return env;
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html