Skip to content

Commit 899649b

Browse files
committed
vfio: Fix PCI INTx disable consistency
The virq_disabled flag tracks the userspace view of INTx masking across interrupt mode changes, but we're not consistently applying this to the interrupt and masking handler notion of the device. Currently if the user sets DisINTx while in MSI or MSIX mode, then returns to INTx mode (ex. rebooting a qemu guest), the hardware has DisINTx+, but the management of INTx thinks it's enabled, making it impossible to actually clear DisINTx. Fix this by updating the handler state when INTx is re-enabled. Cc: stable@vger.kernel.org Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 9dbdfd2 commit 899649b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/vfio/pci/vfio_pci_intrs.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,17 @@ static int vfio_intx_enable(struct vfio_pci_device *vdev)
366366
return -ENOMEM;
367367

368368
vdev->num_ctx = 1;
369+
370+
/*
371+
* If the virtual interrupt is masked, restore it. Devices
372+
* supporting DisINTx can be masked at the hardware level
373+
* here, non-PCI-2.3 devices will have to wait until the
374+
* interrupt is enabled.
375+
*/
376+
vdev->ctx[0].masked = vdev->virq_disabled;
377+
if (vdev->pci_2_3)
378+
pci_intx(vdev->pdev, !vdev->ctx[0].masked);
379+
369380
vdev->irq_type = VFIO_PCI_INTX_IRQ_INDEX;
370381

371382
return 0;
@@ -419,7 +430,7 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
419430
* disable_irq won't.
420431
*/
421432
spin_lock_irqsave(&vdev->irqlock, flags);
422-
if (!vdev->pci_2_3 && (vdev->ctx[0].masked || vdev->virq_disabled))
433+
if (!vdev->pci_2_3 && vdev->ctx[0].masked)
423434
disable_irq_nosync(pdev->irq);
424435
spin_unlock_irqrestore(&vdev->irqlock, flags);
425436

0 commit comments

Comments
 (0)