All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 4/5] Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR"
Date: Fri, 23 Oct 2026 19:53:42 +0300	[thread overview]
Message-ID: <20261023165343.503945-5-andrey.drobyshev@virtuozzo.com> (raw)
In-Reply-To: <20261023165343.503945-1-andrey.drobyshev@virtuozzo.com>

From: Anthony Yznaga <anthony.yznaga@oracle.com>

This reverts commit ef3a3f6a294ba65fd906a291553935881796f8a5.

This re-enables support for using VFIO_UPDATE_VADDR with vfio
mediated devices which is needed to fully support Live Update.

Orabug: 35370252
Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
Reviewed-by: Steve Sistare <steven.sistare@oracle.com>

https://virtuozzo.atlassian.net/browse/VSTOR-150595
(cherry picked from commit 24e5a96e6a4ac34b09d45687c38e9d2aa8cea4ac)
---
 drivers/vfio/vfio_iommu_type1.c | 44 ++-------------------------------
 include/uapi/linux/vfio.h       | 15 +++++------
 2 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 6193ff966667..89132d3c037e 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -979,12 +979,6 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
 
 	mutex_lock(&iommu->lock);
 
-	if (WARN_ONCE(iommu->vaddr_invalid_count,
-		      "vfio_pin_pages not allowed with VFIO_UPDATE_VADDR\n")) {
-		ret = -EBUSY;
-		goto pin_done;
-	}
-
 	/*
 	 * Wait for all necessary vaddr's to be valid so they can be used in
 	 * the main loop without dropping the lock, to avoid racing vs unmap.
@@ -1483,12 +1477,6 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
 
 	mutex_lock(&iommu->lock);
 
-	/* Cannot update vaddr if mdev is present. */
-	if (invalidate_vaddr && !list_empty(&iommu->emulated_iommu_groups)) {
-		ret = -EBUSY;
-		goto unlock;
-	}
-
 	if (iova != unmap->iova || size != unmap->size) {
 		ret = -EOVERFLOW;
 		goto unlock;
@@ -2327,16 +2315,11 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 	struct iommu_domain_geometry *geo;
 	LIST_HEAD(iova_copy);
 	LIST_HEAD(group_resv_regions);
-	int ret = -EBUSY;
+	int ret = -EINVAL;
 
 	mutex_lock(&iommu->lock);
 
-	/* Attach could require pinning, so disallow while vaddr is invalid. */
-	if (iommu->vaddr_invalid_count)
-		goto out_unlock;
-
 	/* Check for duplicates */
-	ret = -EINVAL;
 	if (vfio_iommu_find_iommu_group(iommu, iommu_group))
 		goto out_unlock;
 
@@ -2795,16 +2778,6 @@ static int vfio_domains_have_enforce_cache_coherency(struct vfio_iommu *iommu)
 	return ret;
 }
 
-static bool vfio_iommu_has_emulated(struct vfio_iommu *iommu)
-{
-	bool ret;
-
-	mutex_lock(&iommu->lock);
-	ret = !list_empty(&iommu->emulated_iommu_groups);
-	mutex_unlock(&iommu->lock);
-	return ret;
-}
-
 static int vfio_iommu_type1_check_extension(struct vfio_iommu *iommu,
 					    unsigned long arg)
 {
@@ -2812,13 +2785,8 @@ static int vfio_iommu_type1_check_extension(struct vfio_iommu *iommu,
 	case VFIO_TYPE1_IOMMU:
 	case VFIO_TYPE1v2_IOMMU:
 	case VFIO_UNMAP_ALL:
-		return 1;
 	case VFIO_UPDATE_VADDR:
-		/*
-		 * Disable this feature if mdevs are present.  They cannot
-		 * safely pin/unpin/rw while vaddrs are being updated.
-		 */
-		return iommu && !vfio_iommu_has_emulated(iommu);
+		return 1;
 	case VFIO_DMA_CC_IOMMU:
 		if (!iommu)
 			return 0;
@@ -3289,13 +3257,6 @@ static int vfio_iommu_type1_dma_rw(void *iommu_data, dma_addr_t user_iova,
 	size_t done;
 
 	mutex_lock(&iommu->lock);
-
-	if (WARN_ONCE(iommu->vaddr_invalid_count,
-		      "vfio_dma_rw not allowed with VFIO_UPDATE_VADDR\n")) {
-		ret = -EBUSY;
-		goto out;
-	}
-
 	while (count > 0) {
 		ret = vfio_iommu_type1_dma_rw_chunk(iommu, user_iova, data,
 						    count, write, &done);
@@ -3307,7 +3268,6 @@ static int vfio_iommu_type1_dma_rw(void *iommu_data, dma_addr_t user_iova,
 		user_iova += done;
 	}
 
-out:
 	mutex_unlock(&iommu->lock);
 	return ret;
 }
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index ac2329f24141..de95371c179a 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -50,11 +50,7 @@
 /* Supports VFIO_DMA_UNMAP_FLAG_ALL */
 #define VFIO_UNMAP_ALL			9
 
-/*
- * Supports the vaddr flag for DMA map and unmap.  Not supported for mediated
- * devices, so this capability is subject to change as groups are added or
- * removed.
- */
+/* Supports the vaddr flag for DMA map and unmap */
 #define VFIO_UPDATE_VADDR		10
 
 /*
@@ -1594,7 +1590,8 @@ 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. The vaddr
+ * 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
@@ -1645,9 +1642,9 @@ struct vfio_bitmap {
  * 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.  DMA to already-mapped pages continues.
- * Groups may not be added to the container while any addresses are invalid.
- * This cannot be combined with the get-dirty-bitmap flag.
+ * 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;
-- 
2.47.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-10-23 16:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 16:53 [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 1/5] Revert "vfio: revert "iommu driver notify callback"" Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 2/5] Revert "vfio/type1: revert "implement " Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 3/5] Revert "vfio/type1: revert "block on invalid vaddr"" Andrey Drobyshev
2026-10-23 16:53 ` Andrey Drobyshev [this message]
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 5/5] mm: allow MADV_DOEXEC on a VFIO mapping not faulted in yet Andrey Drobyshev
2026-10-27 15:48 ` [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023165343.503945-5-andrey.drobyshev@virtuozzo.com \
    --to=andrey.drobyshev@virtuozzo.com \
    --cc=devel@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.