VFIO updates for v4.19

- Mark switch fall throughs (Gustavo A. R. Silva)
 
  - Disable binding SR-IOV enabled PFs (Alex Williamson)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJbdaKVAAoJECObm247sIsipVMQAIIVa7zDQ1NoRooJOvy/pnYb
 OSkb0oQ+tnqjHcjOF0bJWfrH/cEmVs9qngS+mSBm1jnX9eD5PMugRXGu67pTOMOM
 4Z84KAKJKNaDaVFvMLRqNH1vU1ekF9fgcvG6e8lR9tOfNpaL02umxa8oIbyPXyrm
 tg8EzpXG/ENjKnPOXLGFz7tLwCPinElYk2aP6hHj5bwv50roE8aQFsQszSF+q8AU
 wJe8nXI6+ChqiLt3OulC5vPZzlyCMWOVslEvNSHQL3IDelx4UronoTIJ4N+Oq1Lr
 YD9jU1ec9KFAG9j13Ivls8OLF+w6jLfDT9TzentEcRMW4iWjPgyaAjiBF/eZKTE0
 L8GhmhWB1OOoltg7ibEV5mi+GmTApzHpiEBT5REWCoZbTq7tGqxw7NyAVM1+IB83
 dy02M7dbB/FztkxkgoN3r+R+jdvEi1ZvqKzYv6Di4eJA2v/5anzJCsLsImuY52iI
 +lgDrKZOcFncxebIrLJN8A/Fd3fe3MWg+A7PwqOmp5uZtn1bQDVdn+HcE6jmD0c7
 HmT/vfBNLkOWLchApacqEbJXyW6MQkNb/kPL1W2LKCyrhUZWp94dv9tTtyQibVUv
 As4bgLJRKjpmxOV2frW78eBVSWsBYIsSlrnEeEFrR2NtH3ElX2CyMQgdp1TC59F8
 PTk50WP4sJWlrjagFoKQ
 =Zb1v
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2018-08-16 10:34:05 -07:00
commit b6d6a3076a
2 changed files with 15 additions and 1 deletions

View File

@ -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;

View File

@ -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;