From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: "Johannes Thumshirn" <johannes.thumshirn@wdc.com>,
"Alexander Graf" <graf@amazon.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"open list:VIRTIO CORE" <virtualization@lists.linux.dev>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] virtio_ring: Add READ_ONCE annotations for device-writable fields
Date: Fri, 30 Jan 2026 02:42:05 -0500 [thread overview]
Message-ID: <20260130024139-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEtqBJKaG0H6zcyr_RJZ3bZgdNvT1KX52fKHpA=bLsUuew@mail.gmail.com>
On Fri, Jan 30, 2026 at 10:03:23AM +0800, Jason Wang wrote:
> On Thu, Jan 29, 2026 at 8:16 PM Johannes Thumshirn
> <johannes.thumshirn@wdc.com> wrote:
> >
> > From: Alexander Graf <graf@amazon.com>
> >
> > KCSAN reports data races when accessing virtio ring fields that are
> > concurrently written by the device (host). These are legitimate
> > concurrent accesses where the CPU reads fields that the device updates
> > via DMA-like mechanisms.
>
> Technically, the device can write to the descriptor ring as well, do
> we need to care about this case or not?
Why would we?
> >
> > Add accessor functions that use READ_ONCE() to properly annotate these
> > device-writable fields and prevent compiler optimizations that could in
> > theory break the code. This also serves as documentation showing which
> > fields are shared with the device.
> >
> > The affected fields are:
> > - Split ring: used->idx, used->ring[].id, used->ring[].len
> > - Packed ring: desc[].flags, desc[].id, desc[].len
> >
> > Signed-off-by: Alexander Graf <graf@amazon.com>
> > [jth: Add READ_ONCE in virtqueue_kick_prepare_split ]
> > Co-developed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> >
>
> Thanks
prev parent reply other threads:[~2026-01-30 7:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 12:15 [PATCH v2] virtio_ring: Add READ_ONCE annotations for device-writable fields Johannes Thumshirn
2026-01-29 16:39 ` Alexander Graf
2026-01-29 18:11 ` Michael S. Tsirkin
2026-01-30 2:03 ` Jason Wang
2026-01-30 7:42 ` 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=20260130024139-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=graf@amazon.com \
--cc=jasowang@redhat.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-kernel@vger.kernel.org \
--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 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.