Skip to content

Commit b6d6a30

Browse files
committed
Merge tag 'vfio-v4.19-rc1' of git://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - mark switch fall-through cases (Gustavo A. R. Silva) - disable binding SR-IOV enabled PFs (Alex Williamson) * tag 'vfio-v4.19-rc1' of git://github.com/awilliam/linux-vfio: vfio-pci: Disable binding to PFs with SR-IOV enabled vfio: Mark expected switch fall-throughs
2 parents d01e12d + 0dd0e29 commit b6d6a30

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ static long vfio_pci_ioctl(void *device_data,
789789
case VFIO_PCI_ERR_IRQ_INDEX:
790790
if (pci_is_pcie(vdev->pdev))
791791
break;
792-
/* pass thru to return error */
792+
/* fall through */
793793
default:
794794
return -EINVAL;
795795
}
@@ -1192,6 +1192,19 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
11921192
if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL)
11931193
return -EINVAL;
11941194

1195+
/*
1196+
* Prevent binding to PFs with VFs enabled, this too easily allows
1197+
* userspace instance with VFs and PFs from the same device, which
1198+
* cannot work. Disabling SR-IOV here would initiate removing the
1199+
* VFs, which would unbind the driver, which is prone to blocking
1200+
* if that VF is also in use by vfio-pci. Just reject these PFs
1201+
* and let the user sort it out.
1202+
*/
1203+
if (pci_num_vf(pdev)) {
1204+
pci_warn(pdev, "Cannot bind to PF with SR-IOV enabled\n");
1205+
return -EBUSY;
1206+
}
1207+
11951208
group = vfio_iommu_group_get(&pdev->dev);
11961209
if (!group)
11971210
return -EINVAL;

drivers/vfio/vfio_iommu_type1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
16011601
break;
16021602
case VFIO_TYPE1_NESTING_IOMMU:
16031603
iommu->nesting = true;
1604+
/* fall through */
16041605
case VFIO_TYPE1v2_IOMMU:
16051606
iommu->v2 = true;
16061607
break;

0 commit comments

Comments
 (0)