Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp490864ybt; Wed, 1 Jul 2020 03:27:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTb+r3qdor072jcIXDv3GTxRU/RKRpEcAn9xpxniW8oCJd/JKs1eO28JDU96dEpEFmVa+h X-Received: by 2002:a05:6402:f:: with SMTP id d15mr5965365edu.25.1593599236676; Wed, 01 Jul 2020 03:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593599236; cv=none; d=google.com; s=arc-20160816; b=Du6GFlNRo9uWhteHITDvLkIcNTOzxYXpxE/MykmBZp36rmYEMJ0bMITpjlzAHGx3Tl NOqCkiwS0ppTt0ISpXxF20hH4/s0DRkI/jHg+/NS9CEjJjDbSvvffC8A+wTK2RpH31EL xqFLSmnaKij6yc1HfUfONrhOKExPpG0J7CoiAa5kxMAVqgIJKCuHs+za6GEEWrECw/ik Avww4CtEkXpSH1+q1K7qcZX9ZFZndCKg8wRadvDQtPglumRDSm3WS8BiF8APTcqq+42x 9IeKTfPOANpGZSePnLrD0GdagITn2hC1LwgJ4UIXHvIQjBJgrzXVr7q9J1ZgVlKzdMyn 8SrQ== 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:dkim-signature; bh=qWSi6KIyuhPsWwjdsEH8+OeQFyxiA2XBN5EZxJB44pk=; b=tBJe/eq2nmDa2SXYhvSn6azL2Ry/ctqAcfE9Avbi3dK0bRte7E5ZVEDdEeztOvA9oh pwvWz3GaP9eqQ5DRn79R1Dm/KBplHXUrmb9i7LG2vDoJEJ6mmHPrS9ZZ2a2YlAqaudpm XZi0NaHUAYhFmL+HQtDIhLDi55ybPJBVYpf8YMaT8pUpf2mDdTp+NJs/BJGf9+dYPgCk rfd9X1Ge2i23Py3P/pOmxAiZaoe4nckIPAQSp0NYpeZL2s4P21HZQbdqMp3akfih4kTi c/iCCIGgPyx+QNglLmxHUOZjqZyiuKugginrRsSABPY8+i1hmrZy/aM2olTQVBprGvyk 5seA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BQsjf2QA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw23si3500234ejb.231.2020.07.01.03.26.52; Wed, 01 Jul 2020 03:27:16 -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; dkim=pass header.i=@kernel.org header.s=default header.b=BQsjf2QA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729856AbgGAKYf (ORCPT + 99 others); Wed, 1 Jul 2020 06:24:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:43690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbgGAKYe (ORCPT ); Wed, 1 Jul 2020 06:24:34 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0376C2067D; Wed, 1 Jul 2020 10:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593599074; bh=DIRVH3Dx4QYNN2YPXtzS3PQZFuRSscQzlztUVHv4lV0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BQsjf2QASBPMulYwQCwFIhtZgrBXvfSWBtaKBJMnxr/D6qZZUAb93ZxNwnDQ/k+iu LtKSGpZpP5vyXtYOSgswDLkQz833Nb2EEtzkLk17HnOXYgukK/+FWQtB3qnyxYfnLD 3lrHkOwmMYKE6f10gOLnWhO6jCuo/EOgXrC1A/Iw= Date: Wed, 1 Jul 2020 11:24:28 +0100 From: Will Deacon To: Marco Elver Cc: Mark Rutland , Kees Cook , "Paul E. McKenney" , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , Nick Desaulniers , Josh Triplett , LKML , Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Sami Tolvanen , linux-alpha@vger.kernel.org, Alan Stern , Matt Turner , virtualization@lists.linux-foundation.org, Android Kernel Team , Boqun Feng , Arnd Bergmann , Richard Henderson Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Message-ID: <20200701102427.GD14959@willie-the-truck> 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: User-Agent: Mutt/1.10.1 (2018-07-13) 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 09:47:30PM +0200, Marco Elver wrote: > On Tue, 30 Jun 2020 at 19:39, 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 > > This seems reasonable, given we can't realistically tell the compiler > about dependent loads. What (if any), is the performance impact? I > guess this also heavily depends on the actual silicon. Right, it depends both on the CPU micro-architecture and also the workload. When we ran some basic tests, the overhead wasn't greater than the benefit seen by enabling LTO, so it seems like a reasonable trade-off (given that LTO is a dependency for CFI, so it's not just about performance). Will