From: sashiko-bot@kernel.org
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v4 3/3] virtio_pci: drop callback sync on reset
Date: Sat, 12 Sep 2026 10:43:51 +0000 [thread overview]
Message-ID: <20260912104351.73CCD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <64421afa76075c2e0b66ef5c2ea18948b861ab73.1789204858.git.mst@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Removal of callback synchronization from `vp_reset()` introduces a race condition during system shutdown, as `virtio_device_shutdown()` fails to synchronize callbacks after device reset.
--
commit a9d5f056fe92ddf169045b3557dd34b627d1eb0b
Author: Michael S. Tsirkin <mst@redhat.com>
virtio_pci: drop callback sync on reset
The virtio core now synchronizes callbacks after reset, so the PCI transports
no longer need to do it themselves.
> diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
> index d9cbb02b35a11..8115aa39e01e9 100644
> --- a/drivers/virtio/virtio_pci_legacy.c
> +++ b/drivers/virtio/virtio_pci_legacy.c
> @@ -98,8 +98,6 @@ static void vp_reset(struct virtio_device *vdev)
> /* Flush out the status write, and flush in device writes,
> * including MSi-X interrupts, if any. */
> vp_legacy_get_status(&vp_dev->ldev);
> - /* Flush pending VQ/configuration callbacks. */
> - vp_synchronize_vectors(vdev);
[Severity: High]
Does removing this synchronization introduce a race condition during system
shutdown?
During system shutdown, virtio_device_shutdown() in drivers/virtio/virtio.c
calls dev->config->reset(dev) directly without calling virtio_reset_device():
drivers/virtio/virtio.c:virtio_device_shutdown() {
...
dev->config->reset(dev);
/* Missing virtio_synchronize_cbs(dev) here */
}
The vp_reset() implementation flushes pending MSI-X interrupts, which can
cause a configuration interrupt to fire. Because this patch removes the
internal synchronization from vp_reset(), virtio_device_shutdown() returns
immediately.
The configuration interrupt (vp_config_changed()) could then run concurrently
on another CPU, invoking driver callbacks while the system is tearing down the
IOMMU or jumping into a kexec kernel.
> }
>
> static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index b4249afd7f580..922e2df027de9 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
[ ... ]
> @@ -563,9 +563,6 @@ static void vp_reset(struct virtio_device *vdev)
> */
> while (vp_modern_get_status(mdev))
> msleep(1);
> -
> - /* Flush pending VQ/configuration callbacks. */
> - vp_synchronize_vectors(vdev);
[Severity: High]
Does removing the synchronization here present the same issue?
This breaks the guarantee that interrupts flushed during the reset loop have
finished before returning, which virtio_device_shutdown() relies upon to
safely stop the device.
> }
>
> static int vp_active_vq(struct virtqueue *vq, u16 msix_vec)
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789204858.git.mst@redhat.com?part=3
prev parent reply other threads:[~2026-09-12 10:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 10:30 [PATCH v4 0/3] virtio: fix callback synchronization and avq cleanup on reset Michael S. Tsirkin
2026-09-12 10:30 ` [PATCH v4 1/3] virtio: synchronize callbacks after device reset Michael S. Tsirkin
2026-09-12 10:37 ` sashiko-bot
2026-09-12 10:30 ` [PATCH v4 2/3] virtio_pci_modern: move avq cleanup from reset to del_vqs Michael S. Tsirkin
2026-09-12 10:51 ` sashiko-bot
2026-09-12 10:30 ` [PATCH v4 3/3] virtio_pci: drop callback sync on reset Michael S. Tsirkin
2026-09-12 10:43 ` sashiko-bot [this message]
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=20260912104351.73CCD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox