[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260130024139-mutt-send-email-mst@kernel.org>
Date: Fri, 30 Jan 2026 02:42:05 -0500
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Jason Wang <jasowang@...hat.com>
Cc: Johannes Thumshirn <johannes.thumshirn@....com>,
Alexander Graf <graf@...zon.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>,
"open list:VIRTIO CORE" <virtualization@...ts.linux.dev>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] virtio_ring: Add READ_ONCE annotations for
device-writable fields
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@....com> wrote:
> >
> > From: Alexander Graf <graf@...zon.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@...zon.com>
> > [jth: Add READ_ONCE in virtqueue_kick_prepare_split ]
> > Co-developed-by: Johannes Thumshirn <johannes.thumshirn@....com>
> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@....com>
> >
>
> Thanks
Powered by blists - more mailing lists