[PATCH 09/12] Fix missing spin_lock in PIT timer.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changes to the irq_ack variable in the pit_state must be
protected by the inject_lock spinlock; otherwise, we can
erroneously inject a timer interrupt into a guest.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 arch/x86/kvm/i8254.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index dc6eff4..ece7e12 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -606,10 +606,13 @@ void kvm_pit_reset(struct kvm_pit *pit)
 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);
+	unsigned long flags;
 
 	if (!mask) {
+		spin_lock_irqsave(&pit->pit_state.inject_lock, flags);
 		atomic_set(&pit->pit_state.pit_timer.pending, 0);
 		pit->pit_state.irq_ack = 1;
+		spin_unlock_irqrestore(&pit->pit_state.inject_lock, flags);
 	}
 }
 
-- 
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux