* [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs
@ 2026-10-23 16:53 Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 1/5] Revert "vfio: revert "iommu driver notify callback"" Andrey Drobyshev
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
Reverts are taken from the Oracle's UEK kernel.
Plus one real bug fix.
https://virtuozzo.atlassian.net/browse/VSTOR-150595
Andrey Drobyshev (1):
mm: allow MADV_DOEXEC on a VFIO mapping not faulted in yet
Anthony Yznaga (4):
Revert "vfio: revert "iommu driver notify callback""
Revert "vfio/type1: revert "implement notify callback""
Revert "vfio/type1: revert "block on invalid vaddr""
Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR"
drivers/vfio/container.c | 5 ++
drivers/vfio/vfio.h | 7 ++
drivers/vfio/vfio_iommu_type1.c | 149 ++++++++++++++++++++++----------
include/linux/mm.h | 4 +-
include/uapi/linux/vfio.h | 15 ++--
5 files changed, 124 insertions(+), 56 deletions(-)
--
2.47.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.1 1/5] Revert "vfio: revert "iommu driver notify callback""
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 ` Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 2/5] Revert "vfio/type1: revert "implement " Andrey Drobyshev
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
From: Anthony Yznaga <anthony.yznaga@oracle.com>
This reverts commit e592296cd6e15ddeebe4c8411365c550da65c8bf.
This is needed in order to re-enable 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 698288d494ff9be37b208daf89ea163378a23253)
---
drivers/vfio/container.c | 5 +++++
drivers/vfio/vfio.h | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/vfio/container.c b/drivers/vfio/container.c
index d53d08f16973..849785b533ce 100644
--- a/drivers/vfio/container.c
+++ b/drivers/vfio/container.c
@@ -376,6 +376,11 @@ static int vfio_fops_open(struct inode *inode, struct file *filep)
static int vfio_fops_release(struct inode *inode, struct file *filep)
{
struct vfio_container *container = filep->private_data;
+ struct vfio_iommu_driver *driver = container->iommu_driver;
+
+ if (driver && driver->ops->notify)
+ driver->ops->notify(container->iommu_data,
+ VFIO_IOMMU_CONTAINER_CLOSE);
filep->private_data = NULL;
diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h
index 50128da18bca..a9adfe2242d8 100644
--- a/drivers/vfio/vfio.h
+++ b/drivers/vfio/vfio.h
@@ -196,6 +196,11 @@ static inline bool vfio_device_is_noiommu(struct vfio_device *vdev)
#endif /* CONFIG_VFIO_GROUP */
#if IS_ENABLED(CONFIG_VFIO_CONTAINER)
+/* events for the backend driver notify callback */
+enum vfio_iommu_notify_type {
+ VFIO_IOMMU_CONTAINER_CLOSE = 0,
+};
+
/**
* struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
*/
@@ -226,6 +231,8 @@ struct vfio_iommu_driver_ops {
void *data, size_t count, bool write);
struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
struct iommu_group *group);
+ void (*notify)(void *iommu_data,
+ enum vfio_iommu_notify_type event);
};
struct vfio_iommu_driver {
--
2.47.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.1 2/5] Revert "vfio/type1: revert "implement notify callback""
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 ` Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 3/5] Revert "vfio/type1: revert "block on invalid vaddr"" Andrey Drobyshev
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
From: Anthony Yznaga <anthony.yznaga@oracle.com>
This reverts commit a5ac1f816563503eb25739ba8cc3d74548169f09.
This is needed in order to re-enable 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 f18e52427b2a452dcd0cf2eee3956c039b06e329)
---
drivers/vfio/vfio_iommu_type1.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 5167bec14e36..b2d6c68fa79c 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -75,6 +75,7 @@ struct vfio_iommu {
uint64_t num_non_pinned_groups;
bool v2;
bool dirty_page_tracking;
+ bool container_open;
struct list_head emulated_iommu_groups;
};
@@ -2645,6 +2646,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
INIT_LIST_HEAD(&iommu->iova_list);
iommu->dma_list = RB_ROOT;
iommu->dma_avail = dma_entry_limit;
+ iommu->container_open = true;
mutex_init(&iommu->lock);
mutex_init(&iommu->device_list_lock);
INIT_LIST_HEAD(&iommu->device_list);
@@ -3250,6 +3252,18 @@ vfio_iommu_type1_group_iommu_domain(void *iommu_data,
return domain;
}
+static void vfio_iommu_type1_notify(void *iommu_data,
+ enum vfio_iommu_notify_type event)
+{
+ struct vfio_iommu *iommu = iommu_data;
+
+ if (event != VFIO_IOMMU_CONTAINER_CLOSE)
+ return;
+ mutex_lock(&iommu->lock);
+ iommu->container_open = false;
+ mutex_unlock(&iommu->lock);
+}
+
static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = {
.name = "vfio-iommu-type1",
.owner = THIS_MODULE,
@@ -3264,6 +3278,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = {
.unregister_device = vfio_iommu_type1_unregister_device,
.dma_rw = vfio_iommu_type1_dma_rw,
.group_iommu_domain = vfio_iommu_type1_group_iommu_domain,
+ .notify = vfio_iommu_type1_notify,
};
static int __init vfio_iommu_type1_init(void)
--
2.47.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.1 3/5] Revert "vfio/type1: revert "block on invalid vaddr""
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 ` Andrey Drobyshev
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 4/5] Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR" Andrey Drobyshev
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
From: Anthony Yznaga <anthony.yznaga@oracle.com>
This reverts commit da4f1c2e1c9cb2832b5a4de3472cd1cad63781b2.
This is needed in order to re-enable 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 b1bfe0e165fd85657e530462da70bccb498256b2)
---
drivers/vfio/vfio_iommu_type1.c | 94 +++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 5 deletions(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index b2d6c68fa79c..6193ff966667 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -73,6 +73,7 @@ struct vfio_iommu {
unsigned int vaddr_invalid_count;
uint64_t pgsize_bitmap;
uint64_t num_non_pinned_groups;
+ wait_queue_head_t vaddr_wait;
bool v2;
bool dirty_page_tracking;
bool container_open;
@@ -153,6 +154,8 @@ struct vfio_regions {
#define DIRTY_BITMAP_PAGES_MAX ((u64)INT_MAX)
#define DIRTY_BITMAP_SIZE_MAX DIRTY_BITMAP_BYTES(DIRTY_BITMAP_PAGES_MAX)
+#define WAITED 1
+
static int put_pfn(unsigned long pfn, int prot);
static struct vfio_iommu_group*
@@ -669,6 +672,61 @@ static long vpfn_pages(struct vfio_dma *dma,
return ret;
}
+static int vfio_wait(struct vfio_iommu *iommu)
+{
+ DEFINE_WAIT(wait);
+
+ prepare_to_wait(&iommu->vaddr_wait, &wait, TASK_KILLABLE);
+ mutex_unlock(&iommu->lock);
+ schedule();
+ mutex_lock(&iommu->lock);
+ finish_wait(&iommu->vaddr_wait, &wait);
+ if (kthread_should_stop() || !iommu->container_open ||
+ fatal_signal_pending(current)) {
+ return -EFAULT;
+ }
+ return WAITED;
+}
+
+/*
+ * Find dma struct and wait for its vaddr to be valid. iommu lock is dropped
+ * if the task waits, but is re-locked on return. Return result in *dma_p.
+ * Return 0 on success with no waiting, WAITED on success if waited, and -errno
+ * on error.
+ */
+static int vfio_find_dma_valid(struct vfio_iommu *iommu, dma_addr_t start,
+ size_t size, struct vfio_dma **dma_p)
+{
+ int ret = 0;
+
+ do {
+ *dma_p = vfio_find_dma(iommu, start, size);
+ if (!*dma_p)
+ return -EINVAL;
+ else if (!(*dma_p)->vaddr_invalid)
+ return ret;
+ else
+ ret = vfio_wait(iommu);
+ } while (ret == WAITED);
+
+ return ret;
+}
+
+/*
+ * Wait for all vaddr in the dma_list to become valid. iommu lock is dropped
+ * if the task waits, but is re-locked on return. Return 0 on success with no
+ * waiting, WAITED on success if waited, and -errno on error.
+ */
+static int vfio_wait_all_valid(struct vfio_iommu *iommu)
+{
+ int ret = 0;
+
+ while (iommu->vaddr_invalid_count && ret >= 0)
+ ret = vfio_wait(iommu);
+
+ return ret;
+}
+
/*
* Attempt to pin pages. We really don't want to track all the pfns and
* the iommu can only map chunks of consecutive pfns anyway, so get the
@@ -904,6 +962,7 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
unsigned long remote_vaddr;
struct vfio_dma *dma;
bool do_accounting;
+ dma_addr_t iova;
dma_addr_t iova_end;
size_t iova_size;
@@ -926,6 +985,22 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
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.
+ */
+again:
+ if (iommu->vaddr_invalid_count) {
+ for (i = 0; i < npage; i++) {
+ iova = user_iova + PAGE_SIZE * i;
+ ret = vfio_find_dma_valid(iommu, iova, PAGE_SIZE, &dma);
+ if (ret < 0)
+ goto pin_done;
+ if (ret == WAITED)
+ goto again;
+ }
+ }
+
/* Fail if no dma_umap notifier is registered */
if (list_empty(&iommu->device_list)) {
ret = -EINVAL;
@@ -941,7 +1016,6 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
for (i = 0; i < npage; i++) {
unsigned long phys_pfn;
- dma_addr_t iova;
struct vfio_pfn *vpfn;
iova = user_iova + PAGE_SIZE * i;
@@ -1240,8 +1314,10 @@ static void vfio_remove_dma(struct vfio_iommu *iommu, struct vfio_dma *dma)
put_task_struct(dma->task);
mmdrop(dma->mm);
vfio_dma_bitmap_free(dma);
- if (dma->vaddr_invalid)
+ if (dma->vaddr_invalid) {
iommu->vaddr_invalid_count--;
+ wake_up_all(&iommu->vaddr_wait);
+ }
kfree(dma);
iommu->dma_avail++;
}
@@ -1737,6 +1813,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
dma->vaddr = vaddr;
dma->vaddr_invalid = false;
iommu->vaddr_invalid_count--;
+ wake_up_all(&iommu->vaddr_wait);
}
goto out_unlock;
} else if (dma) {
@@ -1811,6 +1888,10 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
int ret;
+ ret = vfio_wait_all_valid(iommu);
+ if (ret < 0)
+ return ret;
+
/* Arbitrarily pick the first domain in the list for lookups */
if (!list_empty(&iommu->domain_list))
d = list_first_entry(&iommu->domain_list,
@@ -2650,6 +2731,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
mutex_init(&iommu->lock);
mutex_init(&iommu->device_list_lock);
INIT_LIST_HEAD(&iommu->device_list);
+ init_waitqueue_head(&iommu->vaddr_wait);
iommu->pgsize_bitmap = PAGE_MASK;
INIT_LIST_HEAD(&iommu->emulated_iommu_groups);
@@ -3148,12 +3230,13 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,
struct vfio_dma *dma;
bool kthread = current->mm == NULL;
size_t offset;
+ int ret;
*copied = 0;
- dma = vfio_find_dma(iommu, user_iova, 1);
- if (!dma)
- return -EINVAL;
+ ret = vfio_find_dma_valid(iommu, user_iova, 1, &dma);
+ if (ret < 0)
+ return ret;
if ((write && !(dma->prot & IOMMU_WRITE)) ||
!(dma->prot & IOMMU_READ))
@@ -3262,6 +3345,7 @@ static void vfio_iommu_type1_notify(void *iommu_data,
mutex_lock(&iommu->lock);
iommu->container_open = false;
mutex_unlock(&iommu->lock);
+ wake_up_all(&iommu->vaddr_wait);
}
static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = {
--
2.47.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.1 4/5] Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR"
2026-10-23 16:53 [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev
` (2 preceding siblings ...)
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
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
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.1 5/5] mm: allow MADV_DOEXEC on a VFIO mapping not faulted in yet
2026-10-23 16:53 [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev
` (3 preceding siblings ...)
2026-10-23 16:53 ` [Devel] [PATCH hci-8.1 4/5] Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR" Andrey Drobyshev
@ 2026-10-23 16:53 ` Andrey Drobyshev
2026-10-27 15:48 ` [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-23 16:53 UTC (permalink / raw)
To: devel
The NVIDIA vGPU mdev driver doesn't map BAR1 in its mmap(): it only
installs a ->fault() handler, which sets VM_PFNMAP on the first access
by the guest. Until the guest touches BAR1, e.g. right after the VM
starts or with no guest driver loaded, the mapping is a shared file
mapping without VM_PFNMAP, so MADV_DOEXEC refuses it with -EINVAL and
qemu-update of the VM fails.
Don't test VM_PFNMAP, take any shared mapping of a file. MADV_DOEXEC
still admits only VFIO files. vma_dup() handles such a mapping like a
faulted-in one: there are no PTEs to copy yet, and the first access in
the new process goes to the driver's ->fault() handler as usual.
https://virtuozzo.atlassian.net/browse/VSTOR-150595
Fixes: 95e14696fa3f ("mm: allow MADV_DOEXEC on shared PFN mappings of device memory")
Feature: oracle/mm: MADV_DOEXEC madvise() flag
Assisted-by: LLM
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
include/linux/mm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 496cbdfc7141..9addd5ce2ea5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1020,12 +1020,12 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
/*
* Shared PFN mapping of a file, such as a device BAR mapped through VFIO.
+ * A driver may set VM_PFNMAP only on the first fault, so don't test it.
* Its vm_ops may be NULL, so it must be tested before vma_is_anonymous().
*/
static inline bool vma_is_shared_pfnmap(struct vm_area_struct *vma)
{
- return vma->vm_file &&
- (vma->vm_flags & (VM_SHARED | VM_PFNMAP)) == (VM_SHARED | VM_PFNMAP);
+ return vma->vm_file && (vma->vm_flags & VM_SHARED);
}
/*
--
2.47.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs
2026-10-23 16:53 [Devel] [PATCH hci-8.1 0/5] Support VM migration with mdev vGPUs Andrey Drobyshev
` (4 preceding siblings ...)
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 ` Andrey Drobyshev
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Drobyshev @ 2026-10-27 15:48 UTC (permalink / raw)
To: devel
On 10/23/26 7:53 PM, Andrey Drobyshev wrote:
> Reverts are taken from the Oracle's UEK kernel.
> Plus one real bug fix.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-150595
>
> Andrey Drobyshev (1):
> mm: allow MADV_DOEXEC on a VFIO mapping not faulted in yet
>
> Anthony Yznaga (4):
> Revert "vfio: revert "iommu driver notify callback""
> Revert "vfio/type1: revert "implement notify callback""
> Revert "vfio/type1: revert "block on invalid vaddr""
> Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR"
>
> drivers/vfio/container.c | 5 ++
> drivers/vfio/vfio.h | 7 ++
> drivers/vfio/vfio_iommu_type1.c | 149 ++++++++++++++++++++++----------
> include/linux/mm.h | 4 +-
> include/uapi/linux/vfio.h | 15 ++--
> 5 files changed, 124 insertions(+), 56 deletions(-)
>
This series should be dropped as we've decided not to support older
generation mdev vGPUs.
Thanks,
Andrey
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-27 15:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [Devel] [PATCH hci-8.1 4/5] Revert "vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR" Andrey Drobyshev
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox