Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 370

kvm-83-164.el5_5.9.src.rpm

From 383ffc11656fb3658c8ad0f5c691ab3175f1631c Mon Sep 17 00:00:00 2001
From: mtosatti@redhat.com <mtosatti@redhat.com>
Date: Tue, 14 Apr 2009 14:47:14 -0300
Subject: [PATCH 3/6] KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked

commit b583d189ac975fec22b139b39f8985dea2bb8745
Author: Avi Kivity <avi@redhat.com>
Date:   Sun Jan 4 18:06:06 2009 +0200

    KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked

    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>
    (cherry picked from commit 4780c65904f0fc4e312ee2da9383eacbe04e61ea)

Message-Id: <20090414174837.859025796@amt.cnet>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com
Bugzilla: 500263
RH-Upstream-status: applied(kvm/master)
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Zachary Amsden <zamsden@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 arch/x86/kvm/i8254.c |   15 +++++++++++++++
 arch/x86/kvm/i8254.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 69d1bbf..c13bb92 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -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);
diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h
index 76959c4..6acbe4b 100644
--- a/arch/x86/kvm/i8254.h
+++ b/arch/x86/kvm/i8254.h
@@ -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
-- 
1.6.3.rc4.29.g8146