aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-08-16 13:34:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-16 13:34:05 -0400
commitb6d6a3076ac4eecb2d9cbcf17730fc160b94cadc (patch)
tree812bc521bf1aaaed0cfb140e6743ac9208407696
parentd01e12dd3f4227f1be5d7c5bffa7b8240787bec1 (diff)
parent0dd0e297f0ec780b6b3484ba38b27d18c8ca7af9 (diff)
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
-rw-r--r--drivers/vfio/pci/vfio_pci.c15
-rw-r--r--drivers/vfio/vfio_iommu_type1.c1
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 3b1083fdb898..cddb453a1ba5 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -789,7 +789,7 @@ static long vfio_pci_ioctl(void *device_data,
789 case VFIO_PCI_ERR_IRQ_INDEX: 789 case VFIO_PCI_ERR_IRQ_INDEX:
790 if (pci_is_pcie(vdev->pdev)) 790 if (pci_is_pcie(vdev->pdev))
791 break; 791 break;
792 /* pass thru to return error */ 792 /* fall through */
793 default: 793 default:
794 return -EINVAL; 794 return -EINVAL;
795 } 795 }
@@ -1192,6 +1192,19 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1192 if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) 1192 if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL)
1193 return -EINVAL; 1193 return -EINVAL;
1194 1194
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
1195 group = vfio_iommu_group_get(&pdev->dev); 1208 group = vfio_iommu_group_get(&pdev->dev);
1196 if (!group) 1209 if (!group)
1197 return -EINVAL; 1210 return -EINVAL;
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 3e5b17710a4f..d9fd3188615d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1601,6 +1601,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
1601 break; 1601 break;
1602 case VFIO_TYPE1_NESTING_IOMMU: 1602 case VFIO_TYPE1_NESTING_IOMMU:
1603 iommu->nesting = true; 1603 iommu->nesting = true;
1604 /* fall through */
1604 case VFIO_TYPE1v2_IOMMU: 1605 case VFIO_TYPE1v2_IOMMU:
1605 iommu->v2 = true; 1606 iommu->v2 = true;
1606 break; 1607 break;