[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4fde2f6e-d272-4aa8-9701-63bc6b7e7d16@amazon.com>
Date: Wed, 28 Jan 2026 10:03:26 +0100
From: Alexander Graf <graf@...zon.com>
To: Johannes Thumshirn <Johannes.Thumshirn@....com>,
"virtualization@...ts.linux.dev" <virtualization@...ts.linux.dev>
CC: "Michael S . Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Eugenio Pérez
<eperezma@...hat.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] virtio: silence KCSAN warning in
virtqueue_get_buf_ctx_split
On 28.01.26 09:47, Johannes Thumshirn wrote:
> On 1/27/26 5:30 PM, Alexander Graf wrote:
>> This patches the split vring format, but does not touch the packed one.
>> What happens if you run the same test with the packed format? You can do
>> so by passing "packed=on" as argument to your -device parameter.
> This opened up a whole new can of worms... :(
That's what I expected :).
How do other DMA based devices handle this? Is the real problem that
virtio by default does not use the DMA API and so it confuses generic
KCSAN logic that would otherwise track DMA regions as "can be modified
by DMA at any time"?
If that is the case, maybe what we really want is to force enable use of
the DMA API when KCSAN is active. Does something like the (whitespace
broken) patch below work?
Alex
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index ddab68959671..b1dd790ce622 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -284,6 +284,13 @@ static bool vring_use_map_api(const struct
virtio_device *vdev)
if (xen_domain())
return true;
+ /*
+ * KCSAN needs to track who can modify memory. DMA API gets
+ * us that, so always use it.
+ */
+ if (IS_ENABLED(CONFIG_KCSAN))
+ return true;
+
return false;
}
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Powered by blists - more mailing lists