From: "Michael S. Tsirkin" <mst@redhat.com>
To: Andrew Stellman <astellman@stellman-greene.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
virtualization@lists.linux.dev
Subject: Re: [PATCH 4/4] virtio_ring: preserve VIRTIO_F_RING_RESET in transport features
Date: Tue, 7 Apr 2026 16:53:03 -0400 [thread overview]
Message-ID: <20260407165211-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAChPuV_D33D8t9wFNZB0pq9hfrAe_WKF4LX2VpEmF=npogx7gQ@mail.gmail.com>
On Tue, Apr 07, 2026 at 04:00:00PM -0400, Andrew Stellman wrote:
> No, sorry, I tested it, only with a unit test after finding it via static
> analysis, not the "real" way using the whole kernel build. (Also replied with
> the test for 0002.)
>
> Found with static analysis, reproduced with a unit test (save attached file to
> drivers/virtio/test0004.c):
>
> % cd drivers/virtio
> % git checkout virtio_ring.c
> Updated 0 paths from the index
> % sed -n '/^void vring_transport_features/,/^}/p' virtio_ring.c > extracted.c &
> & gcc -Wall -Werror -o test0004 test0004.c && ./test0004
> FAIL: VIRTIO_F_RING_RESET cleared during negotiation
> % git apply 0004-virtio_ring-preserve-VIRTIO_F_RING_RESET-in-transpor.patch
> % sed -n '/^void vring_transport_features/,/^}/p' virtio_ring.c > extracted.c &
> & gcc -Wall -Werror -o test0004 test0004.c && ./test0004
> PASS: VIRTIO_F_RING_RESET preserved
>
> If this doesn't work, feel free to ditch.
I want to know if there's a bug or not, and what does the patch achieve.
The current code does not make it clear at all.
> On Tue, Apr 7, 2026 at 2:08 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Apr 07, 2026 at 01:33:39PM -0400, Andrew Stellman wrote:
> > Code analysis only — not observed in practice. And you're right that on
> PCI it
> > doesn't matter: vp_transport_features() re-sets the bit after
> > vring_transport_features() clears it, so PCI never actually loses the
> feature.
>
> Oh. please do test patches, or note they were not tested.
> how were rest of patches here tested?
>
> >
> > The gap is for transports that call vring_transport_features() without
> > independently re-setting VIRTIO_F_RING_RESET afterward. Whether any
> current
> > transport hits this in practice I'm not sure — it may just be a whitelist
> > consistency fix at this point.
> >
> > Happy to add a Fixes tag and resend, or drop it if you think the
> PCI-level
> > re-set makes it unnecessary.
> >
> > Fixes: 04ca0b0b16f1 ("virtio_pci: support VIRTIO_F_RING_RESET")
>
>
> surely not this because pci is fine.
>
> > On Tue, Apr 7, 2026 at 12:22 PM Michael S. Tsirkin <mst@redhat.com>
> wrote:
> >
> > On Tue, Apr 07, 2026 at 08:39:04AM -0400, Andrew Stellman wrote:
> > > vring_transport_features() whitelists known transport feature bits
> and
> > > clears the rest via __virtio_clear_bit(). VIRTIO_F_RING_RESET is
> > > missing from the whitelist, so it is unconditionally cleared during
> > > feature negotiation. Drivers that depend on ring reset capability
> > > silently lose the feature.
> >
> > Hmm was this observed in practice or just from code analysis?
> > And on which transport?
> > Because
> >
> >
> > static void vp_transport_features(struct virtio_device *vdev, u64
> features)
> > {
> > struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> > struct pci_dev *pci_dev = vp_dev->pci_dev;
> >
> > if ((features & BIT_ULL(VIRTIO_F_SR_IOV)) &&
> > pci_find_ext_capability(pci_dev,
> > PCI_EXT_CAP_ID_SRIOV))
> > __virtio_set_bit(vdev, VIRTIO_F_SR_IOV);
> >
> > if (features & BIT_ULL(VIRTIO_F_RING_RESET))
> > __virtio_set_bit(vdev, VIRTIO_F_RING_RESET);
> >
> >
> > ...
> >
> >
> >
> > }
> >
> >
> >
> >
> > > Add VIRTIO_F_RING_RESET to the switch statement, matching the other
> > > transport-level features.
> > >
> > > Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
> > > ---
> > > drivers/virtio/virtio_ring.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/
> virtio_ring.c
> > > index fbca7ce..2cb643f 100644
> > > --- a/drivers/virtio/virtio_ring.c
> > > +++ b/drivers/virtio/virtio_ring.c
> > > @@ -3524,6 +3524,8 @@ void vring_transport_features(struct
> virtio_device
> > *vdev)
> > > break;
> > > case VIRTIO_F_IN_ORDER:
> > > break;
> > > + case VIRTIO_F_RING_RESET:
> > > + break;
> > > default:
> > > /* We don't understand this bit. */
> > > __virtio_clear_bit(vdev, i);
> > > --
> > > 2.34.1
> >
> >
>
>
prev parent reply other threads:[~2026-04-07 20:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 12:39 [PATCH 0/4] virtio: fix four bugs across mmio, pci, and vring Andrew Stellman
2026-04-07 12:39 ` [PATCH 1/4] virtio-mmio: wait for status readback after reset Andrew Stellman
2026-04-07 16:24 ` Michael S. Tsirkin
2026-04-07 12:39 ` [PATCH 2/4] virtio-pci: use avq->vq_index for admin VQ in INTx path Andrew Stellman
2026-04-07 16:26 ` Michael S. Tsirkin
[not found] ` <CAChPuV9OuQw_F5dsna4meVxV6Hicxe4+674xoSx+KEev6JEEQw@mail.gmail.com>
2026-04-07 18:08 ` Michael S. Tsirkin
2026-04-07 12:39 ` [PATCH 3/4] virtio-pci: return IRQ_HANDLED for config-change interrupts Andrew Stellman
2026-04-07 16:20 ` Michael S. Tsirkin
[not found] ` <CAChPuV9iGu6o5yJz87DEo6=gfr2P7m_jM=-auFuZevrr-HoYNw@mail.gmail.com>
2026-04-07 20:53 ` Michael S. Tsirkin
2026-04-07 12:39 ` [PATCH 4/4] virtio_ring: preserve VIRTIO_F_RING_RESET in transport features Andrew Stellman
2026-04-07 16:21 ` Michael S. Tsirkin
[not found] ` <CAChPuV92aD4BibJiGfMASQVQBHAoz+3OgzQS6Hb2Dw7JDcRJTQ@mail.gmail.com>
2026-04-07 18:08 ` Michael S. Tsirkin
2026-04-07 20:00 ` Andrew Stellman
2026-04-07 20:53 ` Michael S. Tsirkin [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=20260407165211-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=astellman@stellman-greene.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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