Skip to content

Commit

Permalink
KVM: ioapic: reinject pending interrupts on KVM_SET_IRQCHIP
Browse files Browse the repository at this point in the history
After the previous patches, an interrupt whose bit is set in the IRR
register will never be in the LAPIC's IRR and has never been injected
on the migration source.  So inject it on the destination.

This fixes migration of Windows guests without HPET (they use the RTC
to trigger the scheduler tick, and lose it after migration).

Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Mar 21, 2014
1 parent 44847de commit 673f7b4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion virt/kvm/ioapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ static int ioapic_set_irq(struct kvm_ioapic *ioapic, unsigned int irq,
return ret;
}

static void kvm_ioapic_inject_all(struct kvm_ioapic *ioapic, unsigned long irr)
{
u32 idx;

rtc_irq_eoi_tracking_reset(ioapic);
for_each_set_bit(idx, &irr, IOAPIC_NUM_PINS)
ioapic_set_irq(ioapic, idx, 1, true);

kvm_rtc_eoi_tracking_restore_all(ioapic);
}


static void update_handled_vectors(struct kvm_ioapic *ioapic)
{
DECLARE_BITMAP(handled_vectors, 256);
Expand Down Expand Up @@ -612,9 +624,10 @@ int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)

spin_lock(&ioapic->lock);
memcpy(ioapic, state, sizeof(struct kvm_ioapic_state));
ioapic->irr = 0;
update_handled_vectors(ioapic);
kvm_vcpu_request_scan_ioapic(kvm);
kvm_rtc_eoi_tracking_restore_all(ioapic);
kvm_ioapic_inject_all(ioapic, state->irr);
spin_unlock(&ioapic->lock);
return 0;
}

0 comments on commit 673f7b4

Please sign in to comment.