[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 48/81] vhost-user: Fix out of order vring host notification han
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 48/81] vhost-user: Fix out of order vring host notification handling |
Date: |
Sat, 5 Nov 2022 13:17:47 -0400 |
From: Yajun Wu <yajunw@nvidia.com>
vhost backend sends host notification for every VQ. If backend creates
VQs in parallel, the VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG may
arrive to QEMU in different order than incremental queue index order.
For example VQ 1's message arrive earlier than VQ 0's:
After alloc VhostUserHostNotifier for VQ 1. GPtrArray becomes
[ nil, VQ1 pointer ]
After alloc VhostUserHostNotifier for VQ 0. GPtrArray becomes
[ VQ0 pointer, nil, VQ1 pointer ]
This is wrong. fetch_notifier will return NULL for VQ 1 in
vhost_user_get_vring_base, causes host notifier miss removal(leak).
The fix is to remove current element from GPtrArray, make the right
position for element to insert.
Fixes: 503e355465 ("virtio/vhost-user: dynamically assign
VhostUserHostNotifiers")
Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Parav Pandit <parav@nvidia.com>
Message-Id: <20221018023651.1359420-1-yajunw@nvidia.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-user.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 03415b6c95..d256ce589b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1543,6 +1543,11 @@ static VhostUserHostNotifier
*fetch_or_create_notifier(VhostUserState *u,
n = g_ptr_array_index(u->notifiers, idx);
if (!n) {
+ /*
+ * In case notification arrive out-of-order,
+ * make room for current index.
+ */
+ g_ptr_array_remove_index(u->notifiers, idx);
n = g_new0(VhostUserHostNotifier, 1);
n->idx = idx;
g_ptr_array_insert(u->notifiers, idx, n);
--
MST
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, (continued)
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Ani Sinha, 2022/11/07
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Michael S. Tsirkin, 2022/11/07
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Bernhard Beschow, 2022/11/07
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Michael S. Tsirkin, 2022/11/07
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, B, 2022/11/08
[PULL v3 51/81] acpi: pc/q35: drop ad-hoc PCI-ISA bridge AML routines and let bus ennumeration generate AML, Michael S. Tsirkin, 2022/11/05
[PULL v3 59/81] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/11/05
[PULL v3 36/81] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/11/05
[PULL v3 43/81] virtio-net: support queue reset, Michael S. Tsirkin, 2022/11/05
[PULL v3 47/81] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X, Michael S. Tsirkin, 2022/11/05
[PULL v3 48/81] vhost-user: Fix out of order vring host notification handling,
Michael S. Tsirkin <=
[PULL v3 68/81] tests: acpi: add and whitelist *.hmat-noinitiator expected blobs, Michael S. Tsirkin, 2022/11/05
[PULL v3 44/81] virtio-net: support queue_enable, Michael S. Tsirkin, 2022/11/05
[PULL v3 53/81] tests: acpi: whitelist DSDT before generating ICH9_SMB AML automatically, Michael S. Tsirkin, 2022/11/05
[PULL v3 61/81] MAINTAINERS: Add qapi/virtio.json to section "virtio", Michael S. Tsirkin, 2022/11/05
[PULL v3 64/81] hw/i386/acpi-build: Remove unused struct, Michael S. Tsirkin, 2022/11/05
[PULL v3 60/81] hw/acpi/erst.c: Fix memory handling issues, Michael S. Tsirkin, 2022/11/05
[PULL v3 65/81] hw/i386/acpi-build: Resolve redundant attribute, Michael S. Tsirkin, 2022/11/05
[PULL v3 39/81] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/11/05
[PULL v3 35/81] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/11/05
[PULL v3 37/81] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/05