History

Merge tag 'vfio-v5.12-rc1' of git://github.com/awilliam/linux-vfio

Pull VFIO updatesfrom Alex Williamson: - Virtual address update handling (Steve Sistare) - s390/zpci fixes and cleanups (Max Gurtovoy) - Fixes for dirty bitmap handling, non-mdev page pinning, and improved pinned dirty scope tracking (Keqian Zhu) - Batched page pinning enhancement (Daniel Jordan) - Page access permission fix (Alex Williamson) * tag 'vfio-v5.12-rc1' of git://github.com/awilliam/linux-vfio: (21 commits) vfio/type1: Batch page pinning vfio/type1: Prepare for batched pinning with struct vfio_batch vfio/type1: Change success value of vaddr_get_pfn() vfio/type1: Use follow_pte() vfio/pci: remove CONFIG_VFIO_PCI_ZDEV from Kconfig vfio/iommu_type1: Fix duplicate included kthread.h vfio-pci/zdev: fix possible segmentation fault issue vfio-pci/zdev: remove unused vdev argument vfio/pci: Fix handling of pci use accessor return codes vfio/iommu_type1: Mantain a counter for non_pinned_groups vfio/iommu_type1: Fix some sanity checks in detach group vfio/iommu_type1: Populate full dirty when detach non-pinned group vfio/type1: block on invalid vaddr vfio/type1: implement notify callback vfio: iommu driver notify callback vfio/type1: implement interfaces to update vaddr vfio/type1: massage unmap iteration vfio: interfaces to update vaddr vfio/type1: implement unmap all vfio/type1: unmap cleanup ...

Linus Torvalds committed 5 years ago

Commit 719bbd42 parents c4fbde8 4d83de610 files · +475 −190Browse files

Showing the changes to include/uapi (1 of 10 files). Show all

Unified · Split

include/uapi/linux/vfio.h+27−0
@@ -46,6 +46,12 @@ · 45 unmodified lines
4646 */
4747 #define VFIO_NOIOMMU_IOMMU 8
4848
49+/* Supports VFIO_DMA_UNMAP_FLAG_ALL */
50+#define VFIO_UNMAP_ALL 9
51+
52+/* Supports the vaddr flag for DMA map and unmap */
53+#define VFIO_UPDATE_VADDR 10
54+
4955 /*
5056 * The IOCTL interface is designed for extensibility by embedding the
5157 * structure length (argsz) and flags into structures passed between
@@ -1074,12 +1080,22 @@ struct vfio_iommu_type1_info_dma_avail { · 1022 unmodified lines
10741080 *
10751081 * Map process virtual addresses to IO virtual addresses using the
10761082 * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required.
1083+ *
1084+ * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and
1085+ * unblock translation of host virtual addresses in the iova range. The vaddr
1086+ * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To
1087+ * maintain memory consistency within the user application, the updated vaddr
1088+ * must address the same memory object as originally mapped. Failure to do so
1089+ * will result in user memory corruption and/or device misbehavior. iova and
1090+ * size must match those in the original MAP_DMA call. Protection is not
1091+ * changed, and the READ & WRITE flags must be 0.
10771092 */
10781093 struct vfio_iommu_type1_dma_map {
10791094 __u32 argsz;
10801095 __u32 flags;
10811096 #define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device */
10821097 #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */
1098+#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)
10831099 __u64 vaddr; /* Process virtual address */
10841100 __u64 iova; /* IO virtual address */
10851101 __u64 size; /* Size of mapping (bytes) */
@@ -1102,6 +1118,7 @@ struct vfio_bitmap { · 16 unmodified lines
11021118 * field. No guarantee is made to the user that arbitrary unmaps of iova
11031119 * or size different from those used in the original mapping call will
11041120 * succeed.
1121+ *
11051122 * VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP should be set to get the dirty bitmap
11061123 * before unmapping IO virtual addresses. When this flag is set, the user must
11071124 * provide a struct vfio_bitmap in data[]. User must provide zero-allocated
@@ -1111,11 +1128,21 @@ struct vfio_bitmap { · 3 unmodified lines
11111128 * indicates that the page at that offset from iova is dirty. A Bitmap of the
11121129 * pages in the range of unmapped size is returned in the user-provided
11131130 * vfio_bitmap.data.
1131+ *
1132+ * If flags & VFIO_DMA_UNMAP_FLAG_ALL, unmap all addresses. iova and size
1133+ * must be 0. This cannot be combined with the get-dirty-bitmap flag.
1134+ *
1135+ * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host
1136+ * virtual addresses in the iova range. Tasks that attempt to translate an
1137+ * iova's vaddr will block. DMA to already-mapped pages continues. This
1138+ * cannot be combined with the get-dirty-bitmap flag.
11141139 */
11151140 struct vfio_iommu_type1_dma_unmap {
11161141 __u32 argsz;
11171142 __u32 flags;
11181143 #define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0)
1144+#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1)
1145+#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2)
11191146 __u64 iova; /* IO virtual address */
11201147 __u64 size; /* Size of mapping (bytes) */
11211148 __u8 data[];