]> git.ipfire.org Git - thirdparty/linux.git/commit
virtio-rng: fix DMA alignment for data buffer
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 29 Dec 2025 23:27:21 +0000 (18:27 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 8 Jan 2026 14:54:27 +0000 (09:54 -0500)
commitbd2b617c49820a38cefcf512c6d56d30deb59aa9
tree908c11710a6f0d45502383aecedae3f6348e3794
parent2678369e8efe0c5ac71adb49fbc2c240a222e44d
virtio-rng: fix DMA alignment for data buffer

The data buffer in struct virtrng_info is used for DMA_FROM_DEVICE via
virtqueue_add_inbuf() and shares cachelines with the adjacent
CPU-written fields (data_avail, data_idx).

The device writing to the DMA buffer and the CPU writing to adjacent
fields could corrupt each other's data on non-cache-coherent platforms.

Add __dma_from_device_group_begin()/end() annotations to place these
in distinct cache lines.

Message-ID: <157a63b6324d1f1307ddd4faa3b62a8b90a79423.1767601130.git.mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/char/hw_random/virtio-rng.c