[PATCH V1 6/8] vfio/type1: update vaddr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Re-define VFIO_DMA_MAP_FLAG_VADDR as follows:

  If flags & VFIO_DMA_MAP_FLAG_VADDR, prepare to change the base virtual
  address for iova to vaddr.  The updated vaddr must address the same
  memory object as originally mapped, with the same access permissions,
  and must be shared.  The change takes effect after the next call to
  VFIO_CHANGE_DMA_OWNER.

VFIO_CHANGE_DMA_OWNER is defined in a subsequent patch.
See vfio.h for more details.

Signed-off-by: Steve Sistare <steven.sistare@xxxxxxxxxx>
---
 drivers/vfio/vfio_iommu_type1.c | 3 ++-
 include/uapi/linux/vfio.h       | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 3bd89d5..fbea2b5 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -90,6 +90,7 @@ struct vfio_dma {
 	struct rb_node		node;
 	dma_addr_t		iova;		/* Device address */
 	unsigned long		vaddr;		/* Process virtual addr */
+	unsigned long		new_vaddr;
 	size_t			size;		/* Map size (bytes) */
 	int			prot;		/* IOMMU_READ/WRITE */
 	bool			iommu_mapped;
@@ -1556,7 +1557,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
 		} else if (dma->iova != iova || dma->size != size) {
 			ret = -EINVAL;
 		} else {
-			dma->vaddr = vaddr;
+			dma->new_vaddr = vaddr;
 		}
 		goto out_unlock;
 	} else if (dma) {
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 5c5cc7e..8b7c1ed 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1214,6 +1214,13 @@ 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, prepare to change the base virtual
+ * address for iova to vaddr.  The updated vaddr must address the same memory
+ * object as originally mapped, with the same access permissions, and must be
+ * shared.  The iova and size must match those in the original MAP_DMA call.
+ * Protection is not changed, and the READ & WRITE flags must be 0.  The change
+ * takes effect after the next call to VFIO_CHANGE_DMA_OWNER.
  */
 struct vfio_iommu_type1_dma_map {
 	__u32	argsz;
-- 
1.8.3.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux