From nobody Fri Nov 07 14:59:08 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d32JY24t3z6G3Db; Fri, 07 Nov 2025 14:59:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d32JY1Wz7z3PFw; Fri, 07 Nov 2025 14:59:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762527549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=be/YIk+XP2mFcVHRT0EfepVm/ZLTbjvW2UmweQDqd/A=; b=JJlkaBW+a8NB+LcmVlTIkC2pv4pld7cEUON57X4ytvH4YlSEcGqDiXCNkzFxqLJ59xYGfO yGKE/VjmPafMHd+aMcCfDVcDZuKepBdUaGekMQcbIjaSGHA6eIssc89mmvL/ExmeLXdeN3 g4B6nly8cscaKeZKI68UYYyW107NWZb7i/UdYDZ5OcW8Wg0f9/HnIJqbV9Cz8oZiPOAcIp 9GkMrMHGI1b0s8FpJrTxm/LUR4aVUrK8FW2jbg8B/pZ3xN5WohT5GF7uWraIKGwxCReW2N XdlqEJSTfO7JahQqMRdp94UVy3VXbSRgQO06k0exjihhEBQOpQS/FQt0Nlrp9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762527549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=be/YIk+XP2mFcVHRT0EfepVm/ZLTbjvW2UmweQDqd/A=; b=taVMfaaKx5zyPCWBk2Sc7Fw35sv8eKRud8Ny7jm2cdfg+S4zDeH+fBnnGDD41RRF9KEEVi w9tRWF6Wlc8J9hQJ2Co2E/v/E/icsr5V8h9iM1ugUTPm+6L325yG9SiQ4xjJh7uyRROMeU FbWzhaRNno5PlwhgYAtfz/HYKF9y16UUh6JNQE5ufHLFIh/3Mz/tXiQHIDbm8C31CV05b/ JElS+eu/F5uEvUJ7zckF9J0b/UncTG/t9pFSI5Ky2FLKgvzxT7+Li7yEOZVeWPgDajZpdP fwg1dOXMOxg1lH3BAGAUgW+KmVaUAUepZkpMnztqD/xYIjmxImVw2CbkrTM+5Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762527549; a=rsa-sha256; cv=none; b=lavdfnefplqKeQlhoaweHBYDOckztzLfvmU3VIj9LToyy27+20BqfWQ5Q/0JYY6Zypnia9 D2Q4g6qUcSc17HDts5L7Xff9EK9aJDefNKJVMH2moPMNUdAKZASsNZbn5rYNjKgxKsOg+y Xk5/Bn0BGMoiFdN+BHRvKY3zhoU7jkanRkdg5WdkzUwNhRn1VhomBCA0+xceX3O2T6Uz7m rjE4hBRuSjd2RH25kuKsT8yd+/1nsd3seTSjFjRw2cK9r1Hpr5xZckH1AdmkiENSx/s8fl qUdwJbRzx0O4VOkpC1HgKj7/25o2s/fn0PQPbVC3fLhY7HpFiplTgn8sV9Krmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d32JY0Zw6z14JB; Fri, 07 Nov 2025 14:59:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A7Ex83T083914; Fri, 7 Nov 2025 14:59:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A7Ex8gI083911; Fri, 7 Nov 2025 14:59:08 GMT (envelope-from git) Date: Fri, 7 Nov 2025 14:59:08 GMT Message-Id: <202511071459.5A7Ex8gI083911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 72c76047541a - stable/15 - virtio: Fix polling in virtqueue_dequeue() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 72c76047541ab6cc0e989a74e8de4d6e6a1a94b6 Auto-Submitted: auto-generated The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=72c76047541ab6cc0e989a74e8de4d6e6a1a94b6 commit 72c76047541ab6cc0e989a74e8de4d6e6a1a94b6 Author: Mark Johnston AuthorDate: 2025-11-04 14:27:33 +0000 Commit: Mark Johnston CommitDate: 2025-11-07 14:10:04 +0000 virtio: Fix polling in virtqueue_dequeue() The access of vq->vq_ring.used->idx needs to be volatile-qualified, otherwise the compiler may optimize virtqueue_poll() into an infinite loop if there is no data available upon the first poll. Prior to commit ad17789a8569 this wasn't a problem since an external function call after each poll inhibited the optimization. PR: 289930 MFC after: 3 days Sponsored by: Klara, Inc. Fixes: ad17789a8569 ("virtio: Remove the unused poll method") (cherry picked from commit f999ffdce3813eb946f10999ccffb8275c324469) --- sys/dev/virtio/virtqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index cc7a233d60ee..41e01549c8b2 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -580,7 +580,8 @@ virtqueue_dequeue(struct virtqueue *vq, uint32_t *len) void *cookie; uint16_t used_idx, desc_idx; - if (vq->vq_used_cons_idx == vq_htog16(vq, vq->vq_ring.used->idx)) + if (vq->vq_used_cons_idx == + vq_htog16(vq, atomic_load_16(&vq->vq_ring.used->idx))) return (NULL); used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);