Skip to contentSkip to conversation

vfio: Fix PCI 2.3 shared interrupt

PATCH Applied Alex Williamson 2 participants 2 messages Nov 3, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: Fix PCI 2.3 shared interrupt

Trying to be too clever with setting the irq_disabled flag. PCI 2.3 disabled devices can still share IRQs, which can lead to clearing the irq_disabled flag, preventing the EOI from registering, and leaving the device without interrupts. Interrupt handler should only ever set irq_disabled and we can exit earlier to avoid the config space access if we know we're disabled.

---

 drivers/vfio/vfio_intrs.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/vfio/vfio_intrs.c +8 -1
index 604082c..73e3deb 100644
@@ -57,6 +57,12 @@ irqreturn_t vfio_interrupt(int irq, void *dev_id)
 
 	spin_lock_irq(&vdev->irqlock);
 
+	/* INTX disabled interrupts can still be shared */
+	if (vdev->irq_disabled) {
+		spin_unlock_irq(&vdev->irqlock);
+		return ret;
+	}
+
 	if (vdev->pci_2_3) {
 		pci_block_user_cfg_access(pdev);
 
@@ -87,7 +93,8 @@ done:
 		ret = IRQ_HANDLED;
 	}
 
-	vdev->irq_disabled = (ret == IRQ_HANDLED);
+	if (ret == IRQ_HANDLED)
+		vdev->irq_disabled = true;
 
 	spin_unlock_irq(&vdev->irqlock);
 
Applied
#1 lore raw

Applied.

Quoted 39 lines · Alex Williamson

Trying to be too clever with setting the irq_disabled flag. PCI 2.3 disabled devices can still share IRQs, which can lead to clearing the irq_disabled flag, preventing the EOI from registering, and leaving the device without interrupts. Interrupt handler should only ever set irq_disabled and we can exit earlier to avoid the config space access if we know we're disabled.

---

 drivers/vfio/vfio_intrs.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/vfio/vfio_intrs.c +8 -1
index 604082c..73e3deb 100644
@@ -57,6 +57,12 @@ irqreturn_t vfio_interrupt(int irq, void *dev_id)
 
 	spin_lock_irq(&vdev->irqlock);
 
+	/* INTX disabled interrupts can still be shared */
+	if (vdev->irq_disabled) {
+		spin_unlock_irq(&vdev->irqlock);
+		return ret;
+	}
+
 	if (vdev->pci_2_3) {
 		pci_block_user_cfg_access(pdev);
 
@@ -87,7 +93,8 @@ done:
 		ret = IRQ_HANDLED;
 	}
 
-	vdev->irq_disabled = (ret == IRQ_HANDLED);
+	if (ret == IRQ_HANDLED)
+		vdev->irq_disabled = true;
 
 	spin_unlock_irq(&vdev->irqlock);