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 C3FD4C54E67 for ; Tue, 26 Mar 2024 23:15:25 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3IO65+zZUWIOBZeIYSIUv3Ks5erwB6SQeQQm4jyth2Y=; b=rk11xuxCHkNzVj /LTY5hsHJ3zZaAf6Q+m5YcG7kS2bjKjhB43aYVZ0DsOjXNOPOnomYd+8WvRnbqh11Y2LJy2W7yPey 3vBGQnVphXnuqFE8S+g5j9iD+GyOIyAU2LkChLOpWb2XhBq21aXBAWRnk+iWkIxyBkSIPJfkW1qjc VLK8f2J/ezUokZ+ZFhWKQ/EX0nI88ni4kQUcbhFZpWh0pnFnJLwXjUameV+0ZuYj0XSd9RFFcTsXl F4d5EuHKwxzL9yZbrAtgVotInj+f7lv+2kIj1CDXKgbc7N+HvXJqANYRgPCPSr/aqeyH7NmE5Qk54 sJT8nXiJ9bg3Js6Srh7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpG0b-00000006q4Y-156R; Tue, 26 Mar 2024 23:15:09 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpG0Y-00000006pzn-2HWH for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2024 23:15:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711494902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0mQCN5HobjN2Q/dtCo4+7FNCVXz9DGDP5AkWFtGzZjc=; b=iRNYT95aXfdWbY3p7vwnFhRZL50GVp4SAfinBjrFvBRKwZJho8Jbw2Rig8hgs0Vugc4gRs OXUSEG1gEVUYs3f7uGy9IqnlgtprWmvzERNqDiDfEb/nQVnVOMxKu1wpHsSa6jb2OhJR5g Ubmc7+XXVIZss+6XxXzAStOMO+wiaL0= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-QBI2WxIfMaqR5DyitycvlA-1; Tue, 26 Mar 2024 19:14:59 -0400 X-MC-Unique: QBI2WxIfMaqR5DyitycvlA-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-29e06733018so4555072a91.0 for ; Tue, 26 Mar 2024 16:14:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711494897; x=1712099697; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0mQCN5HobjN2Q/dtCo4+7FNCVXz9DGDP5AkWFtGzZjc=; b=j6k4pSg1IgTdW0NgB7NX7Hpa+EiGAC57xS2EOeEXfiwfnhr63fy8+wwZMy9kBLWTao 9vJ8V3VVdDytcliXpYI1CFca0v2diGbKgyS3YyDLDHTdjegmDauh1Iz0m2zT8Yjz8reY xQG/QOxX8hZGKfpO/OaitIZoRHgfuLmnLjd3p2/BHNqwHeGbiwv4uT/dK7Z/Tg4aJVGe 6cMeFCPRkz6rKqu6zVUbHX2mePRMS+Bb97c5oZbp4bifWDKPeMnUDzhB7lE+PG4cz4zy 6FvbGXz2yp1IxvQq6VCpuIZpIrmIZebYCgOJB1ERJqJsV3HJFno+1ciT40z+laa29M1V dGXA== X-Forwarded-Encrypted: i=1; AJvYcCWsGy4Nbmeb2vvmbBOUkbotsa6YgLHKTWwCDaz71GNSW9l/Y4LdncEoLJm17FpUsI+2H02PyhZWDvuY9yDYfuvciNVHrEridT/nypRgkbSqysG6GxA= X-Gm-Message-State: AOJu0YwNzeQQYYpJoP4oeQgITEboEq3Vi1K+buljDr15YJ67vGg5SHdA S0sIecpROiKkf63JuYt5UgKBeEcJ9PvQ45M9oX15WZuxuIoRcRyuINi3I4rOr3CaI66+S2w/gni 1Baaf9q85ttgvYCcsFsOsbPRroSPR7epqNC/7tlbiphSKgMO7DLhaUJB0NlmFx9e+9kOPrURI X-Received: by 2002:a17:90a:9606:b0:2a0:50ce:aa95 with SMTP id v6-20020a17090a960600b002a050ceaa95mr8314400pjo.21.1711494897372; Tue, 26 Mar 2024 16:14:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaigOMr/7CiLFK70hJIs+MvOMb27KbuLh6qIXIIew+T0XDmdil0bNWD2Rq0OI35ubw/SLB0g== X-Received: by 2002:a17:90a:9606:b0:2a0:50ce:aa95 with SMTP id v6-20020a17090a960600b002a050ceaa95mr8314380pjo.21.1711494897036; Tue, 26 Mar 2024 16:14:57 -0700 (PDT) Received: from [192.168.68.51] ([43.252.115.31]) by smtp.gmail.com with ESMTPSA id u14-20020a17090abb0e00b0029c49ed3974sm154556pjr.37.2024.03.26.16.14.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Mar 2024 16:14:54 -0700 (PDT) Message-ID: <6bdf2884-852e-42d3-9e67-c9d5aa7d932a@redhat.com> Date: Wed, 27 Mar 2024 09:14:47 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] virtio_ring: Fix the stale index in available ring To: Will Deacon , Keir Fraser 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 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> <20240326154628.GA9613@willie-the-truck> From: Gavin Shan In-Reply-To: <20240326154628.GA9613@willie-the-truck> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_161506_835079_A23170B3 X-CRM114-Status: GOOD ( 14.31 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/27/24 01:46, Will Deacon wrote: > On Tue, Mar 26, 2024 at 11:43:13AM +0000, Will Deacon wrote: > > 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. > > 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); > Thanks, Will. I already noticed smp_rmb() has been missed in vhost_vq_avail_empty(). The issue still exists after smp_rmb() is added here. However, I'm inspired by your suggestion and recheck the code again. It seems another smp_rmb() has been missed in vhost_enable_notify(). With smp_rmb() added to vhost_vq_avail_empty() and vhost_enable_notify(), I'm unable to hit the issue. I will try for more times to make sure the issue is really resolved. After that, I will post formal patches for review. Thanks, Gavin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel