Skip to content

Commit

Permalink
vfio: add a singleton check for vfio_group_pin_pages
Browse files Browse the repository at this point in the history
[ Upstream commit 7ef32e5 ]

Page pinning is used both to translate and pin device mappings for DMA
purpose, as well as to indicate to the IOMMU backend to limit the dirty
page scope to those pages that have been pinned, in the case of an IOMMU
backed device.
To support this, the vfio_pin_pages() interface limits itself to only
singleton groups such that the IOMMU backend can consider dirty page
scope only at the group level.  Implement the same requirement for the
vfio_group_pin_pages() interface.

Fixes: 95fc87b ("vfio: Selective dirty page tracking if IOMMU backed device pins pages")
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
yanzhao56 authored and gregkh committed Oct 29, 2020
1 parent 7e4f15f commit b40bd0d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,9 @@ int vfio_group_pin_pages(struct vfio_group *group,
if (!group || !user_iova_pfn || !phys_pfn || !npage)
return -EINVAL;

if (group->dev_counter > 1)
return -EINVAL;

if (npage > VFIO_PIN_PAGES_MAX_ENTRIES)
return -E2BIG;

Expand Down

0 comments on commit b40bd0d

Please sign in to comment.