* [PATCH v2] vfio: add a singleton check for vfio_group_pin_pages
@ 2020-09-16 2:28 Yan Zhao
0 siblings, 0 replies; only message in thread
From: Yan Zhao @ 2020-09-16 2:28 UTC (permalink / raw)
To: alex.williamson, cohuck; +Cc: kvm, linux-kernel, Yan Zhao
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>
---
v2:
1. updated the commit message to declare the issue clearly. (Alex)
2. updated the format of the Fixes: line.
---
drivers/vfio/vfio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 5e6e0511b5aa..2f0fa272ebf2 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -2053,6 +2053,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;
--
2.17.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-16 2:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 2:28 [PATCH v2] vfio: add a singleton check for vfio_group_pin_pages Yan Zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®