linux/drivers/vfio
Alex Williamson ae57d1462b vfio/type1: Remove locked page accounting workqueue
commit 0cfef2b741 upstream.

If the mmap_sem is contented then the vfio type1 IOMMU backend will
defer locked page accounting updates to a workqueue task.  This has a
few problems and depending on which side the user tries to play, they
might be over-penalized for unmaps that haven't yet been accounted or
race the workqueue to enter more mappings than they're allowed.  The
original intent of this workqueue mechanism seems to be focused on
reducing latency through the ioctl, but we cannot do so at the cost
of correctness.  Remove this workqueue mechanism and update the
callers to allow for failure.  We can also now recheck the limit under
write lock to make sure we don't exceed it.

vfio_pin_pages_remote() also now necessarily includes an unwind path
which we can jump to directly if the consecutive page pinning finds
that we're exceeding the user's memory limits.  This avoids the
current lazy approach which does accounting and mapping up to the
fault, only to return an error on the next iteration to unwind the
entire vfio_dma.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
[bwh: Backported to 3.16:
 - vfio_lock_acct() always operates on current->mm
 - Drop changes to vfio_{,un}pin_page_external() and
   vfio_iommu_unmap_unpin_reaccount()
 - Drop test of rsvd flag
 - Fix up the disable_hugepages case in vfio_pin_pages()
 - Use down_write() instead of down_write_killable()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-08-26 02:14:31 +01:00
..
pci vfio/pci: Fix integer overflows, bitmask check 2016-11-20 01:17:37 +00:00
Kconfig vfio: always select ANON_INODES 2014-03-27 11:58:58 -06:00
Makefile powerpc/vfio: Implement IOMMU driver for VFIO 2013-06-20 16:55:14 +10:00
vfio.c driver core: dev_set_drvdata can no longer fail 2014-05-27 13:40:51 -07:00
vfio_iommu_spapr_tce.c powerpc/iommu: Update constant names to reflect their hardcoded page size 2013-12-30 14:17:06 +11:00
vfio_iommu_type1.c vfio/type1: Remove locked page accounting workqueue 2017-08-26 02:14:31 +01:00