diff options
author | Steve Sistare <steven.sistare@oracle.com> | 2021-01-29 17:54:07 +0100 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2021-02-01 21:20:06 +0100 |
commit | 441e8106a238920f28e2e79cff462044551f60e2 (patch) | |
tree | 86a5b1e9d54c48874d25937c92087d4e08259474 | |
parent | vfio/type1: implement unmap all (diff) | |
download | linux-441e8106a238920f28e2e79cff462044551f60e2.tar.xz linux-441e8106a238920f28e2e79cff462044551f60e2.zip |
vfio: interfaces to update vaddr
Define interfaces that allow the underlying memory object of an iova
range to be mapped to a new host virtual address in the host process:
- VFIO_DMA_UNMAP_FLAG_VADDR for VFIO_IOMMU_UNMAP_DMA
- VFIO_DMA_MAP_FLAG_VADDR flag for VFIO_IOMMU_MAP_DMA
- VFIO_UPDATE_VADDR extension for VFIO_CHECK_EXTENSION
Unmap vaddr invalidates the host virtual address in an iova range, and
blocks vfio translation of host virtual addresses. DMA to already-mapped
pages continues. Map vaddr updates the base VA and resumes translation.
See comments in uapi/linux/vfio.h for more details.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r-- | include/uapi/linux/vfio.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 78462599e5ed..8ce36c1d53ca 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -49,6 +49,9 @@ /* Supports VFIO_DMA_UNMAP_FLAG_ALL */ #define VFIO_UNMAP_ALL 9 +/* Supports the vaddr flag for DMA map and unmap */ +#define VFIO_UPDATE_VADDR 10 + /* * The IOCTL interface is designed for extensibility by embedding the * structure length (argsz) and flags into structures passed between @@ -1077,12 +1080,22 @@ struct vfio_iommu_type1_info_dma_avail { * * Map process virtual addresses to IO virtual addresses using the * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. + * + * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and + * unblock translation of host virtual addresses in the iova range. The vaddr + * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To + * maintain memory consistency within the user application, the updated vaddr + * must address the same memory object as originally mapped. Failure to do so + * will result in user memory corruption and/or device misbehavior. iova and + * size must match those in the original MAP_DMA call. Protection is not + * changed, and the READ & WRITE flags must be 0. */ struct vfio_iommu_type1_dma_map { __u32 argsz; __u32 flags; #define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device */ #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */ +#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2) __u64 vaddr; /* Process virtual address */ __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */ @@ -1118,12 +1131,18 @@ struct vfio_bitmap { * * If flags & VFIO_DMA_UNMAP_FLAG_ALL, unmap all addresses. iova and size * must be 0. This cannot be combined with the get-dirty-bitmap flag. + * + * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host + * virtual addresses in the iova range. Tasks that attempt to translate an + * iova's vaddr will block. DMA to already-mapped pages continues. This + * cannot be combined with the get-dirty-bitmap flag. */ struct vfio_iommu_type1_dma_unmap { __u32 argsz; __u32 flags; #define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0) #define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1) +#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2) __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */ __u8 data[]; |