From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11C5BC54E67 for ; Tue, 26 Mar 2024 15:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kiYTZhe1A1oDgDOFLq1vPPMyHNDRthTztsTEshAL4c8=; b=wVfRik5E26ZJeu hOthCV53NBWZfpOBbtBLXlts6AgNJePFBdKRNhXdTO+zXcMzjLrG+zozbRRokMKKMtSdfADfhBGaO NamOfvTjpwBH59Jfu5jRLEIRpiVFy7m5LXLaoh2VwLiPIgUhYPn/t8cQmsRV9AGDKRou2JF/HG5Xk pDKbBMa7yewKMzjvB5fh0f/h+RULtJk/7+fMU//Rv25d/cXU04RXJTivzW4MyHPa1czvIclHjotaW Jbrttfa+SlqZ/Wzy6wlyvdwxmBz7/fhoDN+7AvJV7YFThNCuOCe/+nxZTlCgh4vRbWZDxQZ9VX8PW nJJqORmPUCWaQM8+zvxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp90u-00000005J1g-3I2q; Tue, 26 Mar 2024 15:47:00 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp90X-00000005Irb-151D for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2024 15:46:41 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2D319CE2146; Tue, 26 Mar 2024 15:46:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89CCFC43394; Tue, 26 Mar 2024 15:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711467994; bh=blMMUCS6bBwkEUeKDfD5/uqKHUYqqABX3cMRG8GSLtw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EtXOD6iWSamqz0Z4Z2qRKxQx5zenEIGgmpVobYercZRuxN04pSqre+436BYwczR1z xUOu00ogyzPBJ8VMxe2OtroDVVpSOLB9/VDJc3ZtWe9Z8trBwb5AzHdzZ6dBKnOl7S j23/yCWp4ziRHXMaC4sTcB6jaRBAmL2VMghON5PvuR+B9aWB5BflLQY32JLyjdhCsI BFqWK+dSiPl0qkEXLWxqlVE2TCrHh3fn6sneuVVO7ZmLsgcCjohsGQd4eIra3LxnNF Wsa3oI7oWDa/z1ouDfCokJH30C5BAgGAnoVMjquuwSGVql191lxWXcTwXXZCLOrny9 dZV3fMT7ND9gA== Date: Tue, 26 Mar 2024 15:46:29 +0000 From: Will Deacon To: Keir Fraser , gshan@redhat.com Cc: "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, yihyu@redhat.com, shan.gavin@gmail.com, linux-arm-kernel@lists.infradead.org, Catalin Marinas , mochs@nvidia.com Subject: Re: [PATCH] virtio_ring: Fix the stale index in available ring Message-ID: <20240326154628.GA9613@willie-the-truck> References: <35a6bcef-27cf-4626-a41d-9ec0a338fe28@redhat.com> <20240319182251.GB3121@willie-the-truck> <9500adaf-0075-4ae9-92db-7e310b6598b0@redhat.com> <20240319203540-mutt-send-email-mst@kernel.org> <3a6c8b23-af9c-47a7-8c22-8e0a78154bd3@redhat.com> <20240320030215-mutt-send-email-mst@kernel.org> <1dcec730-ec26-46f4-ba4c-06101fcc599e@redhat.com> <20240326033809-mutt-send-email-mst@kernel.org> <20240326114313.GA9482@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240326114313.GA9482@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_084637_737154_3F9DD319 X-CRM114-Status: GOOD ( 22.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 26, 2024 at 11:43:13AM +0000, Will Deacon wrote: > On Tue, Mar 26, 2024 at 09:38:55AM +0000, Keir Fraser wrote: > > On Tue, Mar 26, 2024 at 03:49:02AM -0400, Michael S. Tsirkin wrote: > > > > Secondly, the debugging code is enhanced so that the available head for > > > > (last_avail_idx - 1) is read for twice and recorded. It means the available > > > > head for one specific available index is read for twice. I do see the > > > > available heads are different from the consecutive reads. More details > > > > are shared as below. > > > > > > > > From the guest side > > > > =================== > > > > > > > > virtio_net virtio0: output.0:id 86 is not a head! > > > > head to be released: 047 062 112 > > > > > > > > avail_idx: > > > > 000 49665 > > > > 001 49666 <-- > > > > : > > > > 015 49664 > > > > > > what are these #s 49665 and so on? > > > and how large is the ring? > > > I am guessing 49664 is the index ring size is 16 and > > > 49664 % 16 == 0 > > > > More than that, 49664 % 256 == 0 > > > > So again there seems to be an error in the vicinity of roll-over of > > the idx low byte, as I observed in the earlier log. Surely this is > > more than coincidence? > > Yeah, I'd still really like to see the disassembly for both sides of the > protocol here. Gavin, is that something you're able to provide? Worst > case, the host and guest vmlinux objects would be a starting point. > > Personally, I'd be fairly surprised if this was a hardware issue. Ok, long shot after eyeballing the vhost code, but does the diff below help at all? It looks like vhost_vq_avail_empty() can advance the value saved in 'vq->avail_idx' but without the read barrier, possibly confusing vhost_get_vq_desc() in polling mode. Will --->8 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 045f666b4f12..87bff710331a 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2801,6 +2801,7 @@ bool vhost_vq_avail_empty(struct vhost_dev *dev, struct vhost_virtqueue *vq) return false; vq->avail_idx = vhost16_to_cpu(vq, avail_idx); + smp_rmb(); return vq->avail_idx == vq->last_avail_idx; } EXPORT_SYMBOL_GPL(vhost_vq_avail_empty); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel