From: Michael S. Tsirkin Date: Mon, 29 Dec 2025 23:23:53 +0000 (-0500) Subject: vsock/virtio: fix DMA alignment for event_list X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63dfad0517f0418a5192024fad934be79c2f5902;p=thirdparty%2Flinux.git vsock/virtio: fix DMA alignment for event_list On non-cache-coherent platforms, when a structure contains a buffer used for DMA alongside fields that the CPU writes to, cacheline sharing can cause data corruption. The event_list array is used for DMA_FROM_DEVICE operations via virtqueue_add_inbuf(). The adjacent event_run and guest_cid fields are written by the CPU while the buffer is available, so mapped for the device. If these share cachelines with event_list, CPU writes can corrupt DMA data. Add __dma_from_device_group_begin()/end() annotations to ensure event_list is isolated in its own cachelines. Message-ID: Acked-by: Stefano Garzarella Signed-off-by: Michael S. Tsirkin --- diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 8c867023a2e52..3de2b2d49b51e 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,9 @@ struct virtio_vsock { */ struct mutex event_lock; bool event_run; + __dma_from_device_group_begin(); struct virtio_vsock_event event_list[8]; + __dma_from_device_group_end(); u32 guest_cid; bool seqpacket_allow;