* [PULL 0/8] pc,virtio: fixes
@ 2026-11-19 9:47 Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 1/8] virtio: Reset free_head on shadow virtqueue start Michael S. Tsirkin
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
The following changes since commit 29760efaf96bbe5928f8111881eddbf5ac06439e:
Update version for v11.2.0-rc0 release (2026-11-10 14:47:54 -0800)
are available in the Git repository at:
https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 902c849979ce2be367dc0a643310d6b45b76bcd4:
hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625) (2026-11-19 02:57:57 -0500)
----------------------------------------------------------------
pc,virtio: fixes
A collection of small fixes all over the place.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
----------------------------------------------------------------
Alexandr Moshkov (1):
vhost-user-fs: fix virtqueue array leak on realize failure
Eric Auger (1):
hw/virtio/virtio-iommu: Fix IOVA address lookup
Li RongQing (1):
virtio: Reset free_head on shadow virtqueue start
Peter Maydell (1):
hw/i386/amd_iommu: Mask address when calculating large PTE page size
Simon Lucido (1):
libvhost-user: return the backend mapping address for SET_MEM_TABLE
Stefano Garzarella (1):
backends/vhost-user: fix memory leak when vhost_dev_init() fails
Thomas Huth (1):
hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625)
Zhenzhong Duan (1):
intel_iommu: Keep PASID cache consistent with PT fast path
hw/i386/amd_iommu.h | 3 +-
include/system/cryptodev.h | 9 +++++
backends/cryptodev.c | 19 ++++++++++
backends/vhost-user.c | 6 ++-
hw/i386/intel_iommu.c | 62 +++++++++++++++++--------------
hw/virtio/vhost-shadow-virtqueue.c | 1 +
hw/virtio/vhost-user-fs.c | 10 +++--
hw/virtio/virtio-crypto.c | 2 +
hw/virtio/virtio-iommu.c | 2 +-
subprojects/libvhost-user/libvhost-user.c | 1 +
hw/i386/trace-events | 3 +-
11 files changed, 81 insertions(+), 37 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PULL 1/8] virtio: Reset free_head on shadow virtqueue start
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 2/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size Michael S. Tsirkin
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Li RongQing, Eugenio Pérez,
Stefano Garzarella
From: Li RongQing <lirongqing@baidu.com>
free_head tracks the index of the next free descriptor in the SVQ
descriptor ring. It is used by vhost_svq_vring_write_descs() to
choose where to place new descriptors, and is updated as descriptors
are allocated and recycled.
free_head is zero-initialized when the SVQ is created through
vhost_svq_new() (g_new0), but it is not reset in vhost_svq_start().
The start function already resets the rest of the ring state
(shadow_avail_idx, shadow_used_idx, last_used, last_used_idx and
num_free), yet free_head is left untouched.
Since an SVQ can be stopped and restarted on the same object, for
example across vDPA device migration or control virtqueue processing,
a stale free_head from the previous run survives into the new one.
This causes new descriptors to be written at the wrong position of
the SVQ descriptor ring, corrupting it.
Reset free_head to 0 in vhost_svq_start() so that descriptor
allocation always begins from the head of a fresh ring.
Fixes: 100890f7cad5 ("vhost: Shadow virtqueue buffers forwarding")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261104020053.2548-1-lirongqing@baidu.com>
---
hw/virtio/vhost-shadow-virtqueue.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index c97bd9f93f1..462c86dc1e2 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -857,6 +857,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
svq->shadow_used_idx = 0;
memset(&svq->batch_last, 0, sizeof(svq->batch_last));
svq->last_used = 0;
+ svq->free_head = 0;
svq->last_used_idx = 0;
svq->vdev = vdev;
svq->vq = vq;
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 2/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 1/8] virtio: Reset free_head on shadow virtqueue start Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 3/8] backends/vhost-user: fix memory leak when vhost_dev_init() fails Michael S. Tsirkin
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, qemu-stable, Alejandro Jimenez, Sairaj kodilkar,
Paolo Bonzini, Richard Henderson
From: Peter Maydell <peter.maydell@linaro.org>
The amd_iommu handling of the "large PTE page size" (where Next Level
bits are 0b111) case is not correct. We calculate the page size
using the address in the descriptor (as per table 14 of the spec),
but we don't explicitly pick out the Page Address field, instead
passing the whole PTE word to cto64(). This means that a PTE which
incorrectly sets all the reserved high bits can cause cto64() to
return 63 or 64, and we will try to shift by an out of range amount,
which is undefined behaviour.
Mask the PTE with AMDVI_DEV_PT_ROOT_MASK to get the page address
(matching how we do it to get the address for the next page table
level in NEXT_PTE_ADDR).
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3618
Reported-by: huntr bubble <https://gitlab.com/bubblehuntr>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: a74bb3110a5b ("amd_iommu: Add helpers to walk AMD v1 Page Table format")
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Reviewed-by: Sairaj kodilkar <sarunkod@amd.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261105105816.3012283-1-peter.maydell@linaro.org>
---
hw/i386/amd_iommu.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index 948d8611b15..008e882724c 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -216,7 +216,8 @@
/*
* Take a PTE value with mode=0x07 and return the page size it encodes.
*/
-#define PTE_LARGE_PAGE_SIZE(pte) (1ULL << (1 + cto64(((pte) | 0xfffULL))))
+#define PTE_LARGE_PAGE_SIZE(pte) \
+ (1ULL << (1 + cto64((((pte) & AMDVI_DEV_PT_ROOT_MASK) | 0xfffULL))))
/* Return number of PTEs to use for a given page size (expected power of 2) */
#define PAGE_SIZE_PTE_COUNT(pgsz) (1ULL << ((ctz64(pgsz) - 12) % 9))
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 3/8] backends/vhost-user: fix memory leak when vhost_dev_init() fails
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 1/8] virtio: Reset free_head on shadow virtqueue start Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 2/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 4/8] vhost-user-fs: fix virtqueue array leak on realize failure Michael S. Tsirkin
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Stefano Garzarella, Luigi Leonardi,
Alexandr Moshkov
From: Stefano Garzarella <sgarzare@redhat.com>
vhost_dev_init() clears the struct vhost_dev in the error path calling
vhost_dev_cleanup(). So, to prevent memory leaks, we need to keep a
local reference to the vhost_virtqueue array and deallocate it in case
of failure, just as most other callers of vhost_dev_init() do.
Discovered while reviewing a patch by Alexandr Moshkov fixing the
same issue in vhost-user-fs.
Fixes: f24bb7287ddb ("Add vhost-user-backend")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261105162443.232929-1-sgarzare@redhat.com>
---
backends/vhost-user.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/backends/vhost-user.c b/backends/vhost-user.c
index de6b1ba2676..a3cd15a57ed 100644
--- a/backends/vhost-user.c
+++ b/backends/vhost-user.c
@@ -24,6 +24,7 @@ int
vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
unsigned nvqs, Error **errp)
{
+ struct vhost_virtqueue *vqs;
int ret;
assert(!b->vdev && vdev);
@@ -32,13 +33,16 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
return -1;
}
+ vqs = g_new0(struct vhost_virtqueue, nvqs);
+
b->vdev = vdev;
b->dev.nvqs = nvqs;
- b->dev.vqs = g_new0(struct vhost_virtqueue, nvqs);
+ b->dev.vqs = vqs;
ret = vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USER, 0,
errp);
if (ret < 0) {
+ g_free(vqs);
return -1;
}
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 4/8] vhost-user-fs: fix virtqueue array leak on realize failure
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (2 preceding siblings ...)
2026-11-19 9:47 ` [PULL 3/8] backends/vhost-user: fix memory leak when vhost_dev_init() fails Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 5/8] intel_iommu: Keep PASID cache consistent with PT fast path Michael S. Tsirkin
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Alexandr Moshkov, Stefano Garzarella,
Stefan Hajnoczi, virtio-fs
From: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
On failure, vhost_dev_init() clears vhost_dev, so the error path frees
NULL instead of the virtqueue array. Keep the pointer in the existing
vhost_vqs field and use it to free the array on failure and unrealize.
Fixes: 98fc1ada4cf7 ("virtio: add vhost-user-fs base device")
Signed-off-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261109062401.81161-1-dtalexundeer@yandex-team.ru>
---
hw/virtio/vhost-user-fs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index 0d8842817a1..f26b5b611ac 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -255,7 +255,8 @@ static void vuf_device_realize(DeviceState *dev, Error **errp)
/* 1 high prio queue, plus the number configured */
fs->vhost_dev.nvqs = 1 + fs->conf.num_request_queues;
- fs->vhost_dev.vqs = g_new0(struct vhost_virtqueue, fs->vhost_dev.nvqs);
+ fs->vhost_vqs = g_new0(struct vhost_virtqueue, fs->vhost_dev.nvqs);
+ fs->vhost_dev.vqs = fs->vhost_vqs;
ret = vhost_dev_init(&fs->vhost_dev, &fs->vhost_user,
VHOST_BACKEND_TYPE_USER, 0, errp);
if (ret < 0) {
@@ -272,14 +273,14 @@ err_virtio:
}
g_free(fs->req_vqs);
virtio_cleanup(vdev);
- g_free(fs->vhost_dev.vqs);
+ g_free(fs->vhost_vqs);
+ fs->vhost_vqs = NULL;
}
static void vuf_device_unrealize(DeviceState *dev)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostUserFS *fs = VHOST_USER_FS(dev);
- struct vhost_virtqueue *vhost_vqs = fs->vhost_dev.vqs;
int i;
/* This will stop vhost backend if appropriate. */
@@ -295,7 +296,8 @@ static void vuf_device_unrealize(DeviceState *dev)
}
g_free(fs->req_vqs);
virtio_cleanup(vdev);
- g_free(vhost_vqs);
+ g_free(fs->vhost_vqs);
+ fs->vhost_vqs = NULL;
}
static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev)
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 5/8] intel_iommu: Keep PASID cache consistent with PT fast path
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (3 preceding siblings ...)
2026-11-19 9:47 ` [PULL 4/8] vhost-user-fs: fix virtqueue array leak on realize failure Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 6/8] libvhost-user: return the backend mapping address for SET_MEM_TABLE Michael S. Tsirkin
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Zhenzhong Duan, Clement Mathieu--Drif, Yi Liu,
Jason Wang, Paolo Bonzini, Richard Henderson
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
With caching mode disabled, a guest can install a scalable-mode
pass-through PASID entry without issuing a PASID-cache invalidation. The
first DMA enables the PT fast path, but leaves QEMU's PASID cache invalid.
When the guest tears down that entry to switch back to a DMA domain, the
invalidation handler sees both a non-present guest entry and an invalid
cached entry and returns without re-enabling the IOMMU memory region.
Subsequent DMA therefore continues to bypass translation.
The issue can be reproduced with an emulated device in scalable mode
with caching-mode=off:
1. Unbind the guest device driver and change the group's type to
identity through /sys/kernel/iommu_groups/<group>/type.
2. Rebind the driver and issue a DMA write.
3. Unbind the driver, change the group's type back to DMA-FQ, and
rebind the driver.
4. Issue another DMA write using an IOVA mapped to a different GPA.
The second write incorrectly bypasses translation instead of reaching
the mapped GPA.
Save the PASID entry when enabling the scalable-mode PT fast path so
teardown invalidation can restore the IOMMU address space. Return after
handling a non-present entry, and refresh the cached entry when a present
entry changes, pass vtd_as to vtd_try_enable_pt_fast_path() instead of
pick it from PASID 0.
Opportunistically clarify the invalidation modes in the fast-path comment
and merge trace event vtd_translate_pt and vtd_pt_enable_fast_path into
vtd_fast_path_translate_pt.
Fixes: c9cf33075a4c ("intel_iommu: Fix DMA failure when guest switches IOMMU domain")
Reported-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Tested-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261112081509.442872-1-zhenzhong.duan@intel.com>
---
hw/i386/intel_iommu.c | 62 ++++++++++++++++++++++++-------------------
hw/i386/trace-events | 3 +--
2 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index b7da5d086d3..a5ff89a11a1 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -1649,7 +1649,7 @@ static int vtd_address_space_sync(VTDAddressSpace *vtd_as)
* or second stage translation, it depends on PGTT setting.
*/
static bool vtd_dev_pt_enabled(IntelIOMMUState *s, VTDContextEntry *ce,
- uint32_t pasid)
+ uint32_t pasid, VTDPASIDEntry *pasid_entry)
{
VTDPASIDEntry pe;
int ret;
@@ -1663,6 +1663,11 @@ static bool vtd_dev_pt_enabled(IntelIOMMUState *s, VTDContextEntry *ce,
*/
return false;
}
+
+ if (pasid_entry) {
+ *pasid_entry = pe;
+ }
+
return vtd_pe_pgtt_is_pt(&pe);
}
@@ -1689,7 +1694,7 @@ static bool vtd_as_pt_enabled(VTDAddressSpace *as)
return false;
}
- return vtd_dev_pt_enabled(s, &ce, as->pasid);
+ return vtd_dev_pt_enabled(s, &ce, as->pasid, NULL);
}
/* Return whether the device is using IOMMU translation. */
@@ -1701,8 +1706,8 @@ static bool vtd_switch_address_space(VTDAddressSpace *as)
assert(as);
s = as->iommu_state;
- use_iommu = s->dmar_enabled && !vtd_as_pt_enabled(as);
pt = s->dmar_enabled && vtd_as_pt_enabled(as);
+ use_iommu = s->dmar_enabled && !pt;
/*
* When guest enables scalable mode and sets up first stage page table,
@@ -1887,23 +1892,34 @@ VTDAddressSpace *vtd_get_as_by_sid(IntelIOMMUState *s, uint16_t sid)
return vtd_get_as_by_sid_and_pasid(s, sid, IOMMU_NO_PASID);
}
-static void vtd_pt_enable_fast_path(IntelIOMMUState *s, uint16_t source_id)
+static bool vtd_try_enable_pt_fast_path(IntelIOMMUState *s,
+ VTDAddressSpace *vtd_as,
+ VTDContextEntry *ce, uint32_t pasid)
{
- VTDAddressSpace *vtd_as;
- bool success = false;
+ VTDPASIDEntry pe;
- vtd_as = vtd_get_as_by_sid(s, source_id);
- if (!vtd_as) {
- goto out;
+ if (!vtd_dev_pt_enabled(s, ce, pasid, &pe)) {
+ return false;
}
- if (vtd_switch_address_space(vtd_as) == false) {
- /* We switched off IOMMU region successfully. */
- success = true;
+ /*
+ * When this happens, it means firstly caching-mode is not
+ * enabled, and this is the first passthrough translation for
+ * the device. Let's enable the fast path for passthrough.
+ *
+ * When passthrough is disabled again for the device, we can
+ * capture it via context-cache invalidation in legacy mode or
+ * PASID-cache invalidation in scalable mode, then the IOMMU
+ * region can be swapped back.
+ */
+ if (!vtd_switch_address_space(vtd_as) && s->root_scalable) {
+ VTDPASIDCacheEntry *pc_entry = &vtd_as->pasid_cache_entry;
+
+ pc_entry->pasid_entry = pe;
+ pc_entry->valid = true;
}
-out:
- trace_vtd_pt_enable_fast_path(source_id, success);
+ return true;
}
/*
@@ -2167,23 +2183,12 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
* We don't need to translate for pass-through context entries.
* Also, let's ignore IOTLB caching as well for PT devices.
*/
- if (vtd_dev_pt_enabled(s, &ce, pasid)) {
+ if (vtd_try_enable_pt_fast_path(s, vtd_as, &ce, pasid)) {
entry->iova = addr & VTD_PAGE_MASK_4K;
entry->translated_addr = entry->iova;
entry->addr_mask = ~VTD_PAGE_MASK_4K;
entry->perm = IOMMU_RW;
- trace_vtd_translate_pt(source_id, entry->iova);
-
- /*
- * When this happens, it means firstly caching-mode is not
- * enabled, and this is the first passthrough translation for
- * the device. Let's enable the fast path for passthrough.
- *
- * When passthrough is disabled again for the device, we can
- * capture it via the context entry invalidation, then the
- * IOMMU region can be swapped back.
- */
- vtd_pt_enable_fast_path(s, source_id);
+ trace_vtd_fast_path_translate_pt(source_id, entry->iova);
vtd_iommu_unlock(s);
return true;
}
@@ -3133,6 +3138,7 @@ static void vtd_pasid_cache_sync_locked(gpointer key, gpointer value,
vtd_address_space_unmap(vtd_as, n);
}
vtd_switch_address_space(vtd_as);
+ return;
}
/*
@@ -3158,11 +3164,11 @@ static void vtd_pasid_cache_sync_locked(gpointer key, gpointer value,
}
if (!pc_entry->valid) {
- pc_entry->pasid_entry = pe;
pc_entry->valid = true;
} else if (!vtd_pasid_entry_compare(&pe, &pc_entry->pasid_entry)) {
return;
}
+ pc_entry->pasid_entry = pe;
vtd_switch_address_space(vtd_as);
vtd_address_space_sync(vtd_as);
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index 7bf4cddd389..3337a7e19c3 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -47,8 +47,7 @@ vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"P
vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"
vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)"
vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64
-vtd_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIx16", iova 0x%"PRIx64
-vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIx16" %d"
+vtd_fast_path_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIx16", iova 0x%"PRIx64
vtd_irq_generate(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PRIx64
vtd_reg_read(uint64_t addr, uint64_t size) "addr 0x%"PRIx64" size 0x%"PRIx64
vtd_reg_write(uint64_t addr, uint64_t size, uint64_t val) "addr 0x%"PRIx64" size 0x%"PRIx64" value 0x%"PRIx64
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 6/8] libvhost-user: return the backend mapping address for SET_MEM_TABLE
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (4 preceding siblings ...)
2026-11-19 9:47 ` [PULL 5/8] intel_iommu: Keep PASID cache consistent with PT fast path Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 7/8] hw/virtio/virtio-iommu: Fix IOVA address lookup Michael S. Tsirkin
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Simon Lucido, Stefano Garzarella, vhost-user
From: Simon Lucido <simonlucido@meta.com>
During postcopy, the vhost-user backend ought to return the base address
at which they mapped regions during SET_MEM_TABLE and ADD_MEM_REG calls
[0]. This was done properly for ADD_MEM_REG, but not for SET_MEM_TABLE,
so any frontend that was relying on that call would not work.
The bug appeared in d288eef3a0a8, which, to silence the
address-of-packed-member warning, created a local copy of vhost message.
That's fine for reading the table, but for postcopy, we also write into
it to send the base addresses back, and after d288eef3a0a8 we ended up
writing into the copy.
This bug was affecting ADD_MEM_REG and SET_MEM_TABLE alike, until
905e8c7e260d fixed the ADD_MEM_REG path by copying back the memory into
the payload.
This commit fixes the SET_MEM_TABLE path by doing exactly that: copying
back the memory table into the payload.
QEMU wasn't affected as it uses ADD_MEM_REG, but any combination of a
frontend that uses SET_MEM_TABLE and libvhost-user backend is.
[0]: https://gitlab.com/qemu-project/qemu/-/blob/144393da8d4bd307a22525c7feea2bb29a0a7556/docs/interop/vhost-user.rst#L1263
Fixes: d288eef3a0a8 ("libvhost-user: fix -Waddress-of-packed-member")
Signed-off-by: Simon Lucido <simonlucido@meta.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261112-setmemtable-fix-v2-1-b38ee27e8f19@meta.com>
---
subprojects/libvhost-user/libvhost-user.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 52817cc733d..df215810339 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -1119,6 +1119,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
if (dev->postcopy_listening) {
/* Send the message back to qemu with the addresses filled in */
+ vmsg->payload.memory = m;
vmsg->fd_num = 0;
if (!vu_send_reply(dev, dev->sock, vmsg)) {
vu_panic(dev, "failed to respond to set-mem-table for postcopy");
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 7/8] hw/virtio/virtio-iommu: Fix IOVA address lookup
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (5 preceding siblings ...)
2026-11-19 9:47 ` [PULL 6/8] libvhost-user: return the backend mapping address for SET_MEM_TABLE Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 8/8] hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625) Michael S. Tsirkin
2026-11-19 21:50 ` [PULL 0/8] pc,virtio: fixes Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eric Auger, qemu-stable,
Philippe Mathieu-Daudé
From: Eric Auger <eric.auger@redhat.com>
The translation code checks the address to be translated
belongs to mapped segments by calling g_tree_lookup_extended().
This uses the interval_cmp() function. However the interval
is badly formed with the .low=addr and .high= addr + 1 instead
of both being set to addr.
As a result an attempt to translate an unmapped byte just before
a mapped segment will not fault as expected.
Example: only [0x2000, 0x2fff] IOVA range is mapped.
An attempt to translate 0x1fff will succeed
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4754
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261116173857.367638-1-eric.auger@redhat.com>
---
hw/virtio/virtio-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 208815096fc..b9ecab01eee 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -1185,7 +1185,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
GList *l;
interval.low = addr;
- interval.high = addr + 1;
+ interval.high = addr;
granule = ctz64(s->config.page_size_mask);
IOMMUTLBEntry entry = {
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 8/8] hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625)
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (6 preceding siblings ...)
2026-11-19 9:47 ` [PULL 7/8] hw/virtio/virtio-iommu: Fix IOVA address lookup Michael S. Tsirkin
@ 2026-11-19 9:47 ` Michael S. Tsirkin
2026-11-19 21:50 ` [PULL 0/8] pc,virtio: fixes Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 9:47 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Thomas Huth, Jia Jia, Gonglei (Arei), zhenwei pi
From: Thomas Huth <thuth@redhat.com>
virtio_crypto_device_unrealize() does not drain or cancel requests that
are sitting in the cryptodev backend's throttle delay queue. So when
hot-unplugging the device, the throttle timer callback can still run and
complete the queued operation later through the virtio_crypto_req_complete()
callback, which dereferences the already-freed VirtIOCrypto device and its
deleted virtqueue, so we end up with a host use-after-free bug here.
Fix it by draining the queue first before deleting the virtqueue and the
device.
CVE: CVE-2026-50625
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3918
Reported-by: Jia Jia <physicalmtea@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261118123948.221366-1-thuth@redhat.com>
---
include/system/cryptodev.h | 9 +++++++++
backends/cryptodev.c | 19 +++++++++++++++++++
hw/virtio/virtio-crypto.c | 2 ++
3 files changed, 30 insertions(+)
diff --git a/include/system/cryptodev.h b/include/system/cryptodev.h
index b20822df0dc..a160a6781a7 100644
--- a/include/system/cryptodev.h
+++ b/include/system/cryptodev.h
@@ -389,6 +389,15 @@ int cryptodev_backend_close_session(
CryptoDevCompletionFunc cb,
void *opaque);
+/**
+ * cryptodev_backend_drain_requests:
+ * @backend: the cryptodev backend object
+ *
+ * Drain crypto operations that might still be in flight on a throttled
+ * backend.
+ */
+void cryptodev_backend_drain_requests(CryptoDevBackend *backend);
+
/**
* cryptodev_backend_crypto_operation:
* @backend: the cryptodev backend object
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index 46059faa26c..faf5592bc87 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -263,6 +263,25 @@ static void cryptodev_backend_throttle_timer_cb(void *opaque)
}
}
+void cryptodev_backend_drain_requests(CryptoDevBackend *backend)
+{
+ CryptoDevBackendOpInfo *opinfo, *tmp;
+
+ /* Cancels pending timer, prevent it from firing during or after drain */
+ if (throttle_enabled(&backend->tc)) {
+ throttle_timers_detach_aio_context(&backend->tt);
+ }
+
+ QTAILQ_FOREACH_SAFE(opinfo, &backend->opinfos, next, tmp) {
+ QTAILQ_REMOVE(&backend->opinfos, opinfo, next);
+ cryptodev_backend_operation(backend, opinfo);
+ }
+
+ if (throttle_enabled(&backend->tc)) {
+ throttle_timers_attach_aio_context(&backend->tt, qemu_get_aio_context());
+ }
+}
+
int cryptodev_backend_crypto_operation(
CryptoDevBackend *backend,
CryptoDevBackendOpInfo *op_info)
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 85c7279aae2..6d053e7d936 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -1116,6 +1116,8 @@ static void virtio_crypto_device_unrealize(DeviceState *dev)
VirtIOCryptoQueue *q;
int i;
+ cryptodev_backend_drain_requests(vcrypto->cryptodev);
+
for (i = 0; i < vcrypto->max_queues; i++) {
virtio_delete_queue(vcrypto->vqs[i].dataq);
q = &vcrypto->vqs[i];
--
MST
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PULL 0/8] pc,virtio: fixes
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
` (7 preceding siblings ...)
2026-11-19 9:47 ` [PULL 8/8] hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625) Michael S. Tsirkin
@ 2026-11-19 21:50 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2026-11-19 21:50 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel; +Cc: Peter Maydell
On 11/19/26 01:47, Michael S. Tsirkin wrote:
> The following changes since commit 29760efaf96bbe5928f8111881eddbf5ac06439e:
>
> Update version for v11.2.0-rc0 release (2026-11-10 14:47:54 -0800)
>
> are available in the Git repository at:
>
> https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
>
> for you to fetch changes up to 902c849979ce2be367dc0a643310d6b45b76bcd4:
>
> hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625) (2026-11-19 02:57:57 -0500)
>
> ----------------------------------------------------------------
> pc,virtio: fixes
>
> A collection of small fixes all over the place.
>
> Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
Applied, thanks.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-19 21:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 9:47 [PULL 0/8] pc,virtio: fixes Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 1/8] virtio: Reset free_head on shadow virtqueue start Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 2/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 3/8] backends/vhost-user: fix memory leak when vhost_dev_init() fails Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 4/8] vhost-user-fs: fix virtqueue array leak on realize failure Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 5/8] intel_iommu: Keep PASID cache consistent with PT fast path Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 6/8] libvhost-user: return the backend mapping address for SET_MEM_TABLE Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 7/8] hw/virtio/virtio-iommu: Fix IOVA address lookup Michael S. Tsirkin
2026-11-19 9:47 ` [PULL 8/8] hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625) Michael S. Tsirkin
2026-11-19 21:50 ` [PULL 0/8] pc,virtio: fixes Richard Henderson
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.