Skip to contentSkip to conversation

vfio-pci: Mask INTx if a device is not capabable of enabling it

PATCH Applied Alexey Kardashevskiy 2 participants 2 messages Dec 7, 2017 – Dec 20, 2017

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

PATCH 1/1 vfio-pci: Mask INTx if a device is not capabable of enabling it

At the moment VFIO rightfully assumes that INTx is supported if the interrupt pin is not set to zero in the device config space. However if that is not the case (the pin is not zero but pdev->irq is), vfio_intx_enable() fails.

In order to prevent the userspace from trying to enable INTx when we know that it cannot work, let's mask the PCI_INTERRUPT_PIN register.

---
 drivers/vfio/pci/vfio_pci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/vfio/pci/vfio_pci.c +3 -0
index 9ed1ecf..505f7a4 100644
@@ -207,6 +207,9 @@ static bool vfio_pci_nointx(struct pci_dev *pdev)
 		}
 	}
 
+	if (!pdev->irq)
+		return true;
+
 	return false;
 }
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 5 lines · On Thu, 7 Dec 2017 12:56:54 +1100 Alexey Kardashevskiy <[email protected]> wrote:

At the moment VFIO rightfully assumes that INTx is supported if the interrupt pin is not set to zero in the device config space. However if that is not the case (the pin is not zero but pdev->irq is), vfio_intx_enable() fails.

Quoted 7 lines

In order to prevent the userspace from trying to enable INTx when we know that it cannot work, let's mask the PCI_INTERRUPT_PIN register.

---
 drivers/vfio/pci/vfio_pci.c | 3 +++
 1 file changed, 3 insertions(+)

Applied to v4.16/vfio. Thanks,

Alex