Skip to contentSkip to conversation

pc,virtio: fixes

GIT PULL Applied Michael S. Tsirkin 2 participants 10 messages Nov 19

lore
Share & tools
lore
#0 lore raw

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.

----------------------------------------------------------------
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(-)
#1 lore raw

[PULL 4/8] vhost-user-fs: fix virtqueue array leak on realize failure

From: Alexandr Moshkov <[email protected]>

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")

Message-ID: <[email protected]>

---
 hw/virtio/vhost-user-fs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hw/virtio/vhost-user-fs.c +6 -4
index 0d8842817a1..f26b5b611ac 100644
@@ -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)
Signature · 1 line
MST
#2 lore raw

[PULL 6/8] libvhost-user: return the backend mapping address for SET_MEM_TABLE

In reply to Michael S. Tsirkin

From: Simon Lucido <[email protected]>

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")

Message-ID: <[email protected]>

---
 subprojects/libvhost-user/libvhost-user.c | 1 +
 1 file changed, 1 insertion(+)
subprojects/libvhost-user/libvhost-user.c +1 -0
index 52817cc733d..df215810339 100644
@@ -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");
Signature · 1 line
MST
#3 lore raw

[PULL 7/8] hw/virtio/virtio-iommu: Fix IOVA address lookup

In reply to Michael S. Tsirkin

From: Eric Auger <[email protected]>

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: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4754

Message-ID: <[email protected]>

---
 hw/virtio/virtio-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-iommu.c +1 -1
index 208815096fc..b9ecab01eee 100644
@@ -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 = {
Signature · 1 line
MST
#4 lore raw

[PULL 5/8] intel_iommu: Keep PASID cache consistent with PT fast path

In reply to Michael S. Tsirkin

From: Zhenzhong Duan <[email protected]>

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.

Message-ID: <[email protected]>

---
 hw/i386/intel_iommu.c | 62 ++++++++++++++++++++++++-------------------
 hw/i386/trace-events  |  3 +--
 2 files changed, 35 insertions(+), 30 deletions(-)
hw/i386/intel_iommu.c +34 -28
index b7da5d086d3..a5ff89a11a1 100644
@@ -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);
hw/i386/trace-events +1 -2
index 7bf4cddd389..3337a7e19c3 100644
@@ -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
Signature · 1 line
MST
#5 lore raw

[PULL 3/8] backends/vhost-user: fix memory leak when vhost_dev_init() fails

In reply to Michael S. Tsirkin

From: Stefano Garzarella <[email protected]>

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.

Message-ID: <[email protected]>

---
 backends/vhost-user.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
backends/vhost-user.c +5 -1
index de6b1ba2676..a3cd15a57ed 100644
@@ -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;
     }
 
Signature · 1 line
MST
#6 lore raw

[PULL 1/8] virtio: Reset free_head on shadow virtqueue start

In reply to Michael S. Tsirkin

From: Li RongQing <[email protected]>

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")

Message-ID: <[email protected]>

---
 hw/virtio/vhost-shadow-virtqueue.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-shadow-virtqueue.c +1 -0
index c97bd9f93f1..462c86dc1e2 100644
@@ -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;
Signature · 1 line
MST
#7 lore raw

[PULL 2/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size

In reply to Michael S. Tsirkin

From: Peter Maydell <[email protected]>

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: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3618

Reported-by huntr bubble <https://gitlab.com/bubblehuntr>
Fixes a74bb3110a5b ("amd_iommu: Add helpers to walk AMD v1 Page Table format")

Message-ID: <[email protected]>

---
 hw/i386/amd_iommu.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/amd_iommu.h +2 -1
index 948d8611b15..008e882724c 100644
@@ -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))
Signature · 1 line
MST
#8 lore raw

[PULL 8/8] hw/virtio/virtio-crypto: Drain in-flight operations before unrealizing (CVE-2026-50625)

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

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

Message-ID: <[email protected]>

---
 include/system/cryptodev.h |  9 +++++++++
 backends/cryptodev.c       | 19 +++++++++++++++++++
 hw/virtio/virtio-crypto.c  |  2 ++
 3 files changed, 30 insertions(+)
include/system/cryptodev.h +9 -0
index b20822df0dc..a160a6781a7 100644
@@ -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
backends/cryptodev.c +19 -0
index 46059faa26c..faf5592bc87 100644
@@ -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)
hw/virtio/virtio-crypto.c +2 -0
index 85c7279aae2..6d053e7d936 100644
@@ -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];
Signature · 1 line
MST
#9 lore raw
In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

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:

Quoted 8 lines
   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.

Applied, thanks.

r~