]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked
authorAvi Kivity <avi@redhat.com>
Fri, 17 Apr 2009 22:40:09 +0000 (19:40 -0300)
committerChris Wright <chrisw@sous-sol.org>
Mon, 27 Apr 2009 17:37:03 +0000 (10:37 -0700)
upstream commit: 4780c65904f0fc4e312ee2da9383eacbe04e61ea

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>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
arch/x86/kvm/i8254.c
arch/x86/kvm/i8254.h

index 72bd275a9b5cee632b393448e325f371610f860b..3dceaefefa3b397df80074a486e997b5e7d837fe 100644 (file)
@@ -536,6 +536,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;
@@ -584,6 +594,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;
 }
 
@@ -592,6 +605,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 4178022b97aac8d66b4f3cfb535102b8bd47140d..0dfb936877ed684e4eddd0686f42742e23bb9e24 100644 (file)
@@ -45,6 +45,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