diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-16 20:34:05 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-16 20:34:05 +0300 |
commit | b6d6a3076ac4eecb2d9cbcf17730fc160b94cadc (patch) | |
tree | 812bc521bf1aaaed0cfb140e6743ac9208407696 /drivers/vfio | |
parent | d01e12dd3f4227f1be5d7c5bffa7b8240787bec1 (diff) | |
parent | 0dd0e297f0ec780b6b3484ba38b27d18c8ca7af9 (diff) | |
download | linux-b6d6a3076ac4eecb2d9cbcf17730fc160b94cadc.tar.xz |
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
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/pci/vfio_pci.c | 15 | ||||
-rw-r--r-- | drivers/vfio/vfio_iommu_type1.c | 1 |
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, case VFIO_PCI_ERR_IRQ_INDEX: if (pci_is_pcie(vdev->pdev)) break; - /* pass thru to return error */ + /* fall through */ default: return -EINVAL; } @@ -1192,6 +1192,19 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) return -EINVAL; + /* + * Prevent binding to PFs with VFs enabled, this too easily allows + * userspace instance with VFs and PFs from the same device, which + * cannot work. Disabling SR-IOV here would initiate removing the + * VFs, which would unbind the driver, which is prone to blocking + * if that VF is also in use by vfio-pci. Just reject these PFs + * and let the user sort it out. + */ + if (pci_num_vf(pdev)) { + pci_warn(pdev, "Cannot bind to PF with SR-IOV enabled\n"); + return -EBUSY; + } + group = vfio_iommu_group_get(&pdev->dev); if (!group) 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) break; case VFIO_TYPE1_NESTING_IOMMU: iommu->nesting = true; + /* fall through */ case VFIO_TYPE1v2_IOMMU: iommu->v2 = true; break; |