From nobody Tue Feb 10 09:57:26 2026 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F7EA35D613 for ; Tue, 27 Jan 2026 15:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769527542; cv=none; b=idDZ8zaLoaGQKPKdrRIgR84kJfAwvmYTVW2yon+M/37DecQBWN3SQ8CJd1B5cADlK0Cp/eLSn55/ophVJzprsX2JyQuyCgXs2dkrqrnPQrztJuataT8Iz0zfRqiqudfSdth+nv1vzxqSpo+BdzrlbVsbpyNHOhrfC+aAYQ/94dI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769527542; c=relaxed/simple; bh=7sBrf0Xd+tKmMEUiMyBd8Vqg7Shnvuqfge/ILid7h+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQRs6J1SrjY3XMEyvUk+Yup0YYlPBnxDV+47VVqrn5SXIYh6f0wIInH350d4MjDCaazaBEkM2sLzDtw1i/TyEIq1oEUyT3NZp+p1Fvs7NCqbew/+B0eb+QrCng2KCZQrXwYNIGa+2dahai3SbWJmYafLEdX33WHJkNchkuxLXLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=GksPrd4J; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="GksPrd4J" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1769527541; x=1801063541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7sBrf0Xd+tKmMEUiMyBd8Vqg7Shnvuqfge/ILid7h+s=; b=GksPrd4J35YI1hzD2dIwoLw+KkD/DBfh4ZUZ55OM1vYW89fAQEpfJxwr Se22AA1k9fOOdlLIbYfy8n5+7pYDF9mfIAm2uhNID+CIMwdvvP0fF9vCv WcLk8HkECAqiQawgY9nXjsa4eu8jPw18PRmQXbnwjD5pxclnGbCgPkr+5 ZFlAr2Tddstg32L0s07JRullZzhe2bIeiKzoXbwcy6Gm34BnCmTghv5By Uk9W0LtgMe9eFzxBduNzAfXAYnvuFeatQfIpZxEmASbm6+pr+esmCL+so r7bBeJyoQI5w337lAn+pwkaInYbpQT3vGfD+bEpIphTwA7rPafWT9y5xZ w==; X-CSE-ConnectionGUID: 8LXnpSEMSMKqhgnE5gTVsQ== X-CSE-MsgGUID: DzwHwDOqQWaaX/Klo3FDcQ== X-IronPort-AV: E=Sophos;i="6.21,257,1763395200"; d="scan'208";a="138789705" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 27 Jan 2026 23:25:35 +0800 IronPort-SDR: 6978d8ef_C/uH0i2/UemF+LX6nBssMsb0D9g8EQD1Qmg18yZNjUWTf1+ 7mBPjYCpWP0sJ1+iGkzYgoiql+L7mfAUm/V/TSg== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Jan 2026 07:25:36 -0800 WDCIronportException: Internal Received: from wdap-nm5iivsczy.ad.shared (HELO neo.fritz.box) ([10.224.28.83]) by uls-op-cesaip02.wdc.com with ESMTP; 27 Jan 2026 07:25:33 -0800 From: Johannes Thumshirn To: virtualization@lists.linux.dev Cc: "Michael S . Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Graf , linux-kernel@vger.kernel.org, Johannes Thumshirn Subject: [PATCH v2 1/2] virtio: silence KCSAN warning in virtqueue_get_buf_ctx_split Date: Tue, 27 Jan 2026 16:25:22 +0100 Message-ID: <20260127152524.200465-2-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260127152524.200465-1-johannes.thumshirn@wdc.com> References: <20260127152524.200465-1-johannes.thumshirn@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When booting a Qemu VM with virtio-blk and KCSAN enabled, KCSAN emits the following warning about a data-race in virtqueue_get_buf_ctx_split(). =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D BUG: KCSAN: data-race in virtqueue_get_buf_ctx_split+0x6e/0x260 race at unknown origin, with read to 0xffff8881020f1942 of 2 bytes by task= 1 on cpu 7: virtqueue_get_buf_ctx_split+0x6e/0x260 virtqueue_get_buf+0x4b/0x60 __send_to_port+0x156/0x170 put_chars+0xcb/0x110 hvc_console_print+0x1d6/0x2a0 console_flush_one_record+0x3dd/0x510 console_unlock+0x8c/0x160 vprintk_emit+0x2fe/0x380 vprintk_default+0x1d/0x30 vprintk+0xe/0x20 _printk+0x4c/0x60 btrfs_test_raid_stripe_tree+0x25/0x90 btrfs_run_sanity_tests.cold+0xf1/0x13b init_btrfs_fs+0x73/0x110 do_one_initcall+0x5b/0x2d0 kernel_init_freeable+0x2a2/0x340 kernel_init+0x1e/0x1b0 ret_from_fork+0x137/0x1b0 ret_from_fork_asm+0x1a/0x30 value changed: 0x0160 -> 0x0161 Reported by Kernel Concurrency Sanitizer on: CPU: 7 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.19.0-rc7+ #219 PREEMPT(= none) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-9.fc43 = 06/10/2025 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This warning is likely a false positive as the change happens on the virtio vring. Annotate the return of more_used_split() with data_race() to silence the warning. Signed-off-by: Johannes Thumshirn --- drivers/virtio/virtio_ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index ddab68959671..1db27ee2d89f 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -808,8 +808,8 @@ static void detach_buf_split(struct vring_virtqueue *vq= , unsigned int head, =20 static bool more_used_split(const struct vring_virtqueue *vq) { - return vq->last_used_idx !=3D virtio16_to_cpu(vq->vq.vdev, - vq->split.vring.used->idx); + return data_race(vq->last_used_idx !=3D virtio16_to_cpu(vq->vq.vdev, + vq->split.vring.used->idx)); } =20 static void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq, --=20 2.52.0