On Thu, Jan 29, 2026 at 8:16 PM Johannes Thumshirn <[email protected]> wrote: > > From: Alexander Graf <[email protected]> > > 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 <[email protected]> > [jth: Add READ_ONCE in virtqueue_kick_prepare_split ] > Co-developed-by: Johannes Thumshirn <[email protected]> > Signed-off-by: Johannes Thumshirn <[email protected]> > Thanks

