Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AF2BC433DF for ; Tue, 18 Aug 2020 16:07:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67190207D3 for ; Tue, 18 Aug 2020 16:07:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67190207D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k848X-0005gS-0p; Tue, 18 Aug 2020 16:06:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k848W-0005gK-Cq for xen-devel@lists.xenproject.org; Tue, 18 Aug 2020 16:06:56 +0000 X-Inumbo-ID: 9177a386-b2ca-4a10-ae43-75d903c4d9a5 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9177a386-b2ca-4a10-ae43-75d903c4d9a5; Tue, 18 Aug 2020 16:06:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 098D6B61E; Tue, 18 Aug 2020 16:07:20 +0000 (UTC) Subject: Re: [PATCH] xen/x86: irq: Avoid a TOCTOU race in pirq_spin_lock_irq_desc() To: Julien Grall Cc: Andrew Cooper , xen-devel@lists.xenproject.org, Julien Grall , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <20200722165300.22655-1-julien@xen.org> <5bd56ef4-8bf5-3308-b7db-71e41ac45918@xen.org> <5a11fa4e-1d57-ad12-ef43-08ed9c5c79dd@xen.org> <7b30d0d7-24d4-b38a-6b97-d6b450574b15@xen.org> <17176e45-abc9-8b90-50b7-50aacb0e19bf@suse.com> <09367b86-50ee-37c5-f0ec-74698f4f4e71@xen.org> <4b4a0691-a1ae-6493-fd6f-7bfa4ae80d67@suse.com> <676a32d9-c9cf-d436-d3d7-352e7605fa77@xen.org> From: Jan Beulich Message-ID: <4ebe8364-b08c-7bba-1045-131239840447@suse.com> Date: Tue, 18 Aug 2020 18:06:52 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <676a32d9-c9cf-d436-d3d7-352e7605fa77@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 18.08.2020 13:52, Julien Grall wrote: > > > On 18/08/2020 12:27, Jan Beulich wrote: >> On 18.08.2020 11:12, Julien Grall wrote: >>>> As pointed >>>> out before, ACCESS_ONCE() and {read,write}_atomic() serve slightly >>>> different purposes, and so far it looks like all of us are lacking ideas >>>> on how to construct something that catches all cases by one single approach. >>> >>> I am guessing you are referring to [1], right? >>> >>> If you read the documentation of READ_ONCE()/WRITE_ONCE(), they are meant to be atomic in some cases. The cases are exactly the same as {read, write}_atomic(). >>> >>> I will ask the same thing as I asked to Roger. If Linux can rely on it, why can't we? >> >> That's not the way I'd like to see arguments go here: If Linux has >> something suitable, I'm fine with us using it. But we ought to be >> permitted to question whether what we inherit is indeed fit for >> purpose, and afaict there is at least one gap to be filled. In no >> case should we blindly pull in things from Linux and then assume >> that simply by doing so all is well. > > I don't think any of us here are compilers guru, so I would tend to rely on Linux memory work. After all their code received much more attention. But sure we can question everything they have been doing. > > To me the expected semantics (/!\ I am not referring to the implementation) for all the helpers are the same. But you seem to disagree on that. > > I read the thread again and I couldn't find any explanation how a developper could chose between ACCESS_ONCE() and {read, write}_atomic(). > > Can you outline how one would decide? As long as both have weaknesses I'm afraid it's really a case-by-case decision. If you're strictly after only the property that one has and the other doesn't, the case is clear. In all other cases it'll need weighing of the risks. No clear rules, I'm afraid. Jan