diff options
author | Yan Zhao <yan.y.zhao@intel.com> | 2020-09-16 04:28:33 +0200 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2020-09-21 22:50:51 +0200 |
commit | 7ef32e52368f62a4e041a4f0abefb4fb64e7fd4a (patch) | |
tree | 8702ce03061238f7d5cb2ce95eed525d56fac02b | |
parent | Linux 5.9-rc6 (diff) | |
download | linux-7ef32e52368f62a4e041a4f0abefb4fb64e7fd4a.tar.xz linux-7ef32e52368f62a4e041a4f0abefb4fb64e7fd4a.zip |
vfio: add a singleton check for vfio_group_pin_pages
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: 95fc87b44104 ("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>
-rw-r--r-- | drivers/vfio/vfio.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 262ab0efd06c..532bcaf28c11 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -2051,6 +2051,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; |