Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp796282ybt; Wed, 1 Jul 2020 10:10:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy5j4xBaklDmppcnHIeCl7JzlZj5vuf+t9INYw1DBauz6M2uiZ8MzEYqZCOtZ4k5EDwpJR X-Received: by 2002:a17:906:fa13:: with SMTP id lo19mr23546585ejb.213.1593623432718; Wed, 01 Jul 2020 10:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593623432; cv=none; d=google.com; s=arc-20160816; b=kjYxhefqntdwbclQeBd8QDUXbzb2/xeAMrDT9Q+30/Ec2YDKj7nuJMXpsz+2m3q72u 9gCi8gL7wPihuROGDC7jGgMh74emJhOFEcCjLt85PH6YSLWlKppEu6D7xSynj2MiBSII hJYwfsc0itu2Mf7l1kbsF5DaTr6nLOolN6+HTUsbzetWoRgI2L2FpU7IVuuNOUQZ3G+A 4QoIQbmb7ppxth3eTwkQeKTZ5DszfcaeQLGDa0/EUihYBmy8BFl+RvLdnPQjaagBhDq5 VozJHhk5jCAGkhmzL0UYeuf9/hMum2EVWLFZeNotSduovIdQLk8CsBTKvKMuDg6p2WLf Jm9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=wuMS87LPqcT/r0XzSgMwkgWhI/TbAIaA6rhulD2wHZk=; b=Sy7898TGyxHHt+gq6SdZxXlomsDHoc429ycrqiT0VfsebBPDmN575F8TKeUbFXN0Qm arouNIU/8/D+0i0gha5qAieZBs29cr9r23fDiIa15GIuwcYvkT8yIZBxqtjQuzYwRVuK pb0mEjD3Tyqp5frXSuTSu/kNqe/2whec+cGah8qOV5RFONkOAZ5+VQMJufeP0v+1gjzp MHSKKt3B8couJdfx5lWDZVsHG53R5vUeKDueBn2A7TEppMS84MFsTmpblzAwma3mYdjp dKlgOsU0CRl6Y9bXJk+cOZYXnF2u4g4qsOj5AlJ9Y/zCTzR39iXiGfaJKSvreMbCVbcW NI+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm19si4101613edb.529.2020.07.01.10.10.08; Wed, 01 Jul 2020 10:10:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732478AbgGARHe (ORCPT + 99 others); Wed, 1 Jul 2020 13:07:34 -0400 Received: from foss.arm.com ([217.140.110.172]:58846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728966AbgGARHe (ORCPT ); Wed, 1 Jul 2020 13:07:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 38EBF31B; Wed, 1 Jul 2020 10:07:33 -0700 (PDT) Received: from bakewell.cambridge.arm.com (unknown [10.37.8.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 572E33F73C; Wed, 1 Jul 2020 10:07:28 -0700 (PDT) Date: Wed, 1 Jul 2020 18:07:25 +0100 From: Dave P Martin To: Will Deacon Cc: linux-kernel@vger.kernel.org, Mark Rutland , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , virtualization@lists.linux-foundation.org, Arnd Bergmann , Alan Stern , Sami Tolvanen , Matt Turner , kernel-team@android.com, Marco Elver , Kees Cook , "Paul E. McKenney" , Boqun Feng , Josh Triplett , Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Richard Henderson , Nick Desaulniers , linux-alpha@vger.kernel.org Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Message-ID: <20200701170722.4rte5ssnmrn2uqzg@bakewell.cambridge.arm.com> References: <20200630173734.14057-1-will@kernel.org> <20200630173734.14057-19-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200630173734.14057-19-will@kernel.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 06:37:34PM +0100, Will Deacon wrote: > When building with LTO, there is an increased risk of the compiler > converting an address dependency headed by a READ_ONCE() invocation > into a control dependency and consequently allowing for harmful > reordering by the CPU. > > Ensure that such transformations are harmless by overriding the generic > READ_ONCE() definition with one that provides acquire semantics when > building with LTO. > > Signed-off-by: Will Deacon > --- > arch/arm64/include/asm/rwonce.h | 63 +++++++++++++++++++++++++++++++ > arch/arm64/kernel/vdso/Makefile | 2 +- > arch/arm64/kernel/vdso32/Makefile | 2 +- > 3 files changed, 65 insertions(+), 2 deletions(-) > create mode 100644 arch/arm64/include/asm/rwonce.h > > diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h > new file mode 100644 > index 000000000000..515e360b01a1 > --- /dev/null > +++ b/arch/arm64/include/asm/rwonce.h > @@ -0,0 +1,63 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2020 Google LLC. > + */ > +#ifndef __ASM_RWONCE_H > +#define __ASM_RWONCE_H > + > +#ifdef CONFIG_CLANG_LTO Don't we have a generic option for LTO that's not specific to Clang. Also, can you illustrate code that can only be unsafe with Clang LTO? [...] Cheers ---Dave