diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2016-09-12 18:18:35 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-09-13 19:09:44 +0200 |
commit | 78d6a05d2f69cbfa6e95f0a4a24a2c934969913b (patch) | |
tree | 72e2b11bf5889ddd86178c79c27dc57c48a2161a /hw/i386 | |
parent | 0342454f8aa6fc55e515bad26425533e10b58085 (diff) | |
download | qemu-78d6a05d2f69cbfa6e95f0a4a24a2c934969913b.zip qemu-78d6a05d2f69cbfa6e95f0a4a24a2c934969913b.tar.gz qemu-78d6a05d2f69cbfa6e95f0a4a24a2c934969913b.tar.bz2 |
x86/lapic: Load LAPIC state at post_load
Load the LAPIC state during post_load (rather than when the CPU
starts).
This allows an interrupt to be delivered from the ioapic to
the lapic prior to cpu loading, in particular the RTC that starts
ticking as soon as we load it's state.
Fixes a case where Windows hangs after migration due to RTC interrupts
disappearing.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/kvm/apic.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 2bd0de8..5d140b9 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -28,9 +28,8 @@ static inline uint32_t kvm_apic_get_reg(struct kvm_lapic_state *kapic, return *((uint32_t *)(kapic->regs + (reg_id << 4))); } -void kvm_put_apic_state(DeviceState *dev, struct kvm_lapic_state *kapic) +static void kvm_put_apic_state(APICCommonState *s, struct kvm_lapic_state *kapic) { - APICCommonState *s = APIC_COMMON(dev); int i; memset(kapic, 0, sizeof(*kapic)); @@ -125,6 +124,27 @@ static void kvm_apic_vapic_base_update(APICCommonState *s) } } +static void kvm_apic_put(void *data) +{ + APICCommonState *s = data; + struct kvm_lapic_state kapic; + int ret; + + kvm_put_apic_state(s, &kapic); + + ret = kvm_vcpu_ioctl(CPU(s->cpu), KVM_SET_LAPIC, &kapic); + if (ret < 0) { + fprintf(stderr, "KVM_SET_LAPIC failed: %s\n", strerror(ret)); + abort(); + } +} + +static void kvm_apic_post_load(APICCommonState *s) +{ + fprintf(stderr, "%s: Yeh\n", __func__); + run_on_cpu(CPU(s->cpu), kvm_apic_put, s); +} + static void do_inject_external_nmi(void *data) { APICCommonState *s = data; @@ -178,6 +198,8 @@ static void kvm_apic_reset(APICCommonState *s) { /* Not used by KVM, which uses the CPU mp_state instead. */ s->wait_for_sipi = 0; + + run_on_cpu(CPU(s->cpu), kvm_apic_put, s); } static void kvm_apic_realize(DeviceState *dev, Error **errp) @@ -206,6 +228,7 @@ static void kvm_apic_class_init(ObjectClass *klass, void *data) k->set_base = kvm_apic_set_base; k->set_tpr = kvm_apic_set_tpr; k->get_tpr = kvm_apic_get_tpr; + k->post_load = kvm_apic_post_load; k->enable_tpr_reporting = kvm_apic_enable_tpr_reporting; k->vapic_base_update = kvm_apic_vapic_base_update; k->external_nmi = kvm_apic_external_nmi; |