[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACGkMEtqBJKaG0H6zcyr_RJZ3bZgdNvT1KX52fKHpA=bLsUuew@mail.gmail.com>
Date: Fri, 30 Jan 2026 10:03:23 +0800
From: Jason Wang <jasowang@...hat.com>
To: Johannes Thumshirn <johannes.thumshirn@....com>
Cc: Alexander Graf <graf@...zon.com>, "Michael S. Tsirkin" <mst@...hat.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 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?
>
> 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