Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp701861pxu; Thu, 3 Dec 2020 10:25:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzK7eY+2SqKJiyH4aUfJ4c1gfxyYEejCJeM2EcHZP5A8Rg3yT3Ycgx3iTSVAy5OaS4SZDoc X-Received: by 2002:a17:906:1e93:: with SMTP id e19mr3785426ejj.440.1607019933607; Thu, 03 Dec 2020 10:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607019933; cv=none; d=google.com; s=arc-20160816; b=OyiDxriDJyMndXPlRaLhr0IJYpJTI73BoY2YBZ7nbhVeuQZf6GZsdc0vAJB4J4+vvY iswu+Fj771WzZjJsQN3kjQvrMw8fIeMQ+Bnul8UzbfHzwMNwNDrBGhwajF/98W5AbtfU b7YyGRF4VqgKU8efoJL2ENGA9ceRPnHKFTbNkyaDQf+j/l8tW0CY0c5m1dKcf8kiXHx+ WOlV6BlC+KsQPimszQNBAsA7wwwoUn9ed/pevHsUa+R7cX5eyE1K1ZcxE4pNptmLBjc1 NZ/YdAEAfg5Z2knwByJ3CdNU5rhuRp7v9kkbFp26K0QlDbFVtpca8z4pdvDp/8Pyiovr pJ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from :dkim-signature:date; bh=v/E73XkVZifcNl/7djpNXYa1P7zIy2HhP5LZGyuVODI=; b=LFnYFqu6bdnNhxuw+F6GpZIe7RTNc8pD0cajPXinvdBBUP2OYKqLgUh1C1rMuVnGum TeL2a/JOaEpqhs1kY1QkwLhEX7SDVeQnNMYRgJXsJh+G9VOpbcVzuA4r+HhzTd1IY59T WUJogb4aU4lLND8Jfset4QcGwCfPvexHq6XvYKl6UkRYWI9XB7FGQaJIH12/ZDb2UIwU d9jBt3sWoaOwrbOGMhkx1zgWBgo/Yra3fsAUjVqyZPX6N8qwEcNn9Sd+uV6Q5DI+lpDW BdP5R7D8sN7Ak70kAOOEFwc+nRZZE+2WH2s8EZuRQBn/C0xIFyNC4CZGFOddst1SM3pC 2JxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4tuv3ca; 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 h9si1482637edn.355.2020.12.03.10.25.10; Thu, 03 Dec 2020 10:25:33 -0800 (PST) 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=k20201202 header.b=j4tuv3ca; 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 S1729982AbgLCSXl (ORCPT + 99 others); Thu, 3 Dec 2020 13:23:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:53654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbgLCSXk (ORCPT ); Thu, 3 Dec 2020 13:23:40 -0500 Date: Thu, 3 Dec 2020 18:22:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607019780; bh=5a8ME2oAXsKqPoeqJfEFvJGi2qwglFd3HcH42x+ZJqE=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=j4tuv3canVKeGWPc00whrPf+yMo+rCeJBSSu9hQ8JKopGOeh22g/l4jLBxki+Q3S4 GSy6xiQfH2GEr5ORIucdbbEVNr0+FmT1NytvINuFt62ibIHSwQQe+XYxmKQbFUBoQm Pe3O1nyWoKMJPEEb4rf10UT8GM0TMsNCoKs0CA1Y6VDqMD3Fa15DWO2+8KzDpouaH/ jk1NY9n6DPz7lGFPTSZZ3NhJoqHMrLxT9UBGdtIKfzs7C+/Z/dfeNnE5pmTpJgadKr WuTbKHZQrQHeug6qVN5E7eo5w7WLqpt9nlELvChtCWZI3JyjnMxiQXEC4zYRHhnct0 /Nj+EdgBLhJYA== From: Will Deacon To: Sami Tolvanen Cc: Nick Desaulniers , Nathan Chancellor , Masahiro Yamada , Steven Rostedt , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , PCI Subject: Re: [PATCH v8 00/16] Add support for Clang LTO Message-ID: <20201203182252.GA32011@willie-the-truck> References: <20201201213707.541432-1-samitolvanen@google.com> <20201203112622.GA31188@willie-the-truck> 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 09:07:30AM -0800, Sami Tolvanen wrote: > On Thu, Dec 3, 2020 at 3:26 AM Will Deacon wrote: > > On Tue, Dec 01, 2020 at 01:36:51PM -0800, Sami Tolvanen wrote: > > > This patch series adds support for building the kernel with Clang's > > > Link Time Optimization (LTO). In addition to performance, the primary > > > motivation for LTO is to allow Clang's Control-Flow Integrity (CFI) > > > to be used in the kernel. Google has shipped millions of Pixel > > > devices running three major kernel versions with LTO+CFI since 2018. > > > > > > Most of the patches are build system changes for handling LLVM > > > bitcode, which Clang produces with LTO instead of ELF object files, > > > postponing ELF processing until a later stage, and ensuring initcall > > > ordering. > > > > > > Note that arm64 support depends on Will's memory ordering patches > > > [1]. I will post x86_64 patches separately after we have fixed the > > > remaining objtool warnings [2][3]. > > > > I took this series for a spin, with my for-next/lto branch merged in but > > I see a failure during the LTO stage with clang 11.0.5 because it doesn't > > understand the '.arch_extension rcpc' directive we throw out in READ_ONCE(). > > I just tested this with Clang 11.0.0, which I believe is the latest > 11.x version, and the current Clang 12 development branch, and both > work for me. Godbolt confirms that '.arch_extension rcpc' is supported > by the integrated assembler starting with Clang 11 (the example fails > with 10.0.1): > > https://godbolt.org/z/1csGcT > > What does running clang --version and ld.lld --version tell you? I'm using some Android prebuilts I had kicking around: Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/google/home/willdeacon/work/android/repo/android-kernel/prebuilts-master/clang/host/linux-x86/clang-r399163b/bin and: LLD 11.0.5 (/buildbot/tmp/tmpx1DlI_ 87f1315dfbea7c137aa2e6d362dbb457e388158d) (compatible with GNU linkers) > > We actually check that this extension is available before using it in > > the arm64 Kconfig: > > > > config AS_HAS_LDAPR > > def_bool $(as-instr,.arch_extension rcpc) > > > > so this shouldn't happen. I then realised, I wasn't passing LLVM_IAS=1 > > on my Make command line; with that, then the detection works correctly > > and the LTO step succeeds. > > > > Why is it necessary to pass LLVM_IAS=1 if LTO is enabled? I think it > > would be _much_ better if this was implicit (or if LTO depended on it). > > Without LLVM_IAS=1, Clang uses two different assemblers when LTO is > enabled: the external GNU assembler for stand-alone assembly, and > LLVM's integrated assembler for inline assembly. as-instr tests the > external assembler and makes an admittedly reasonable assumption that > the test is also valid for inline assembly. > > I agree that it would reduce confusion in future if we just always > enabled IAS with LTO. Nick, Nathan, any thoughts about this? That works for me, although I'm happy with anything which means that the assembler checks via as-instr apply to the assembler which will ultimately be used. Will