]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked
authorAvi Kivity <avi@redhat.com>
Sun, 4 Jan 2009 16:06:06 +0000 (18:06 +0200)
committerAvi Kivity <avi@redhat.com>
Tue, 24 Mar 2009 09:03:03 +0000 (11:03 +0200)
While the PIT is masked the guest cannot ack the irq, so the reinject logic
will never allow the interrupt to be injected.

Fix by resetting the reinjection counters on unmask.

Unbreaks Xen.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/i8254.c
arch/x86/kvm/i8254.h

index 69d1bbff3fd3f5028245249f1637574bf8bdfaab..c13bb92d3157708a52e211b1992a71f45554ffbb 100644 (file)
@@ -539,6 +539,16 @@ void kvm_pit_reset(struct kvm_pit *pit)
        pit->pit_state.irq_ack = 1;
 }
 
+static void pit_mask_notifer(struct kvm_irq_mask_notifier *kimn, bool mask)
+{
+       struct kvm_pit *pit = container_of(kimn, struct kvm_pit, mask_notifier);
+
+       if (!mask) {
+               atomic_set(&pit->pit_state.pit_timer.pending, 0);
+               pit->pit_state.irq_ack = 1;
+       }
+}
+
 struct kvm_pit *kvm_create_pit(struct kvm *kvm)
 {
        struct kvm_pit *pit;
@@ -586,6 +596,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm)
 
        kvm_pit_reset(pit);
 
+       pit->mask_notifier.func = pit_mask_notifer;
+       kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier);
+
        return pit;
 }
 
@@ -594,6 +607,8 @@ void kvm_free_pit(struct kvm *kvm)
        struct hrtimer *timer;
 
        if (kvm->arch.vpit) {
+               kvm_unregister_irq_mask_notifier(kvm, 0,
+                                              &kvm->arch.vpit->mask_notifier);
                mutex_lock(&kvm->arch.vpit->pit_state.lock);
                timer = &kvm->arch.vpit->pit_state.pit_timer.timer;
                hrtimer_cancel(timer);
index 76959c4b500e5b46dbb39fff8e1ad717cf5779b8..6acbe4b505d5faad09d6b7d69e2cc64e870965cc 100644 (file)
@@ -46,6 +46,7 @@ struct kvm_pit {
        struct kvm *kvm;
        struct kvm_kpit_state pit_state;
        int irq_source_id;
+       struct kvm_irq_mask_notifier mask_notifier;
 };
 
 #define KVM_PIT_BASE_ADDRESS       0x40