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 X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 838DFC433FE for ; Fri, 11 Dec 2020 21:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4648D24078 for ; Fri, 11 Dec 2020 21:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392898AbgLKTjY (ORCPT ); Fri, 11 Dec 2020 14:39:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390353AbgLKTjQ (ORCPT ); Fri, 11 Dec 2020 14:39:16 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6BC9C0613CF for ; Fri, 11 Dec 2020 11:38:35 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id b26so7618602pfi.3 for ; Fri, 11 Dec 2020 11:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VNfUmoHugTzMNVPlGX+wnRh5Cf/stQAzYSuLpPo56Do=; b=FEC9uEup9Neav9R+6U+sr3qeNh7Pg8WcbZYYXZwTn8O8CiG2ftP1IPYk0zCyjiYFSF c94oFOC9/6e94fHGubU93cGjPF1HGZHYHPragsSfEBUJ7FdZnpViexh6U4PPA/zRRum+ eJUlsS8wc4R+iMPuouzj/+4aQfrfbSeOVoqX8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VNfUmoHugTzMNVPlGX+wnRh5Cf/stQAzYSuLpPo56Do=; b=Q4QFue6VGH/9CK8Rdfgz5OKdi4YE5w4B4CnGV9D9exX+Beor7JuSAUYILoEX929LMu y5OFxw07uO9bnsSRy1CU9Yf38v37wmIQGZKyXsZZyg7N5on4FrUPH181O3LhWHORp3jk jyrVz7iURTwYenJop4mN8xFLVPes4gFFBpj8LDrc9v+NMZwSOKPtbA7Jn5+y8UdoovyD 58NJejvb8L7KHUIdzASDBfsNwYbRjAI+8ubSLGVR1/N7GBrK5mBE0HhN8bahIV25OJ14 TVmyWwiAOrvfL6GSN+3X6KHw1fLNXOj4UeX/EiyDp8PzNhI6Qm1ycTPMvZKePVdEay2f m1QA== X-Gm-Message-State: AOAM533AgUK662qRFX9qM3it1/ZHuZgZnzyDISO1Wq71PPS1c2yZV5aM 4xkQNByYHMOHLk+QD/trOyGWVg== X-Google-Smtp-Source: ABdhPJyVEoQImRCMu3zSXvZnm5dHPPI8XqAV4RWpzzfXPBlCN0XEN9HOeEk46yg5rZ5bTGUzmtXFMg== X-Received: by 2002:a63:f456:: with SMTP id p22mr13270729pgk.360.1607715515417; Fri, 11 Dec 2020 11:38:35 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h11sm11456024pjg.46.2020.12.11.11.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 11:38:34 -0800 (PST) Date: Fri, 11 Dec 2020 11:38:33 -0800 From: Kees Cook To: Sami Tolvanen Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v9 00/16] Add support for Clang LTO Message-ID: <202012111134.209A6D311@keescook> References: <20201211184633.3213045-1-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201211184633.3213045-1-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 10:46:17AM -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]. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/lto > [2] https://lore.kernel.org/lkml/20201120040424.a3wctajzft4ufoiw@treble/ > [3] https://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git/log/?h=objtool-vmlinux > > You can also pull this series from > > https://github.com/samitolvanen/linux.git lto-v9 > > --- > Changes in v9: > > - Added HAS_LTO_CLANG dependencies to LLVM=1 and LLVM_IAS=1 to avoid > issues with mismatched toolchains. > > - Dropped the .mod patch as Masahiro landed a better solution to > the split line issue in commit 7d32358be8ac ("kbuild: avoid split > lines in .mod files"). > > - Updated CC_FLAGS_LTO to use -fvisibility=hidden to avoid weak symbol > visibility issues with ThinLTO on x86. > > - Changed LTO_CLANG_FULL to depend on !COMPILE_TEST to prevent > timeouts in automated testing. > > - Added a dependency to CPU_LITTLE_ENDIAN to ARCH_SUPPORTS_LTO_CLANG > in arch/arm64/Kconfig. > > - Added a default symbol list to fix an issue with TRIM_UNUSED_KSYMS. This continues to look good to me. I'd like to see it in -next ASAP so we can continue to find any little needed tweaks. Since it works in the general case, we can add on top of this series once it's in -next. Masahiro, let me know if you'd rather I not carry this in -next. AFAICT, the bulk of the changes in the build system continue to be confined to the LTO-only cases, so it should not be disruptive to anyone doing non-LTO builds. -- Kees Cook 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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 2F068C433FE for ; Fri, 11 Dec 2020 19:39:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 A9A3D23D5A for ; Fri, 11 Dec 2020 19:39:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9A3D23D5A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1HZfP/vEv5lbJH2gNMM8dlJm9NNkYUaDHgzLbSDdfnQ=; b=wMvO9SPDL4J58+VpSrApjpy9a qYRbhvsZCCd+Dqunnk7f9sfznaxINLPJaEfKv4iDZ8U8DDtk3uem1wlSVxuxd5hu+CFs2axU+sQ5L of4Dl4u00zvvB5wLnav+LKyicCWhgWRewTBsbmC5gW1jiuLSEVY79p6mFPp7mpvCUHE9grtEFZ0ei kPxVh6wQAqbaqn4FAc/J66e1gReRfjOLYZ/vgGwblW7JYOPWuL49pUgUqEIpDnUGb9JuYKv/zmE7w ETP3LwcemV1zwha/DOkyGHVh8hkzbN1nLumWrq+3gSXcCTr5Skz15vrvlKqwNUzkwBI389mRVo1sa O6Ai6QI+Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knoFU-0007GB-3A; Fri, 11 Dec 2020 19:38:40 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knoFR-0007FD-IV for linux-arm-kernel@lists.infradead.org; Fri, 11 Dec 2020 19:38:38 +0000 Received: by mail-pf1-x441.google.com with SMTP id p4so7625758pfg.0 for ; Fri, 11 Dec 2020 11:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VNfUmoHugTzMNVPlGX+wnRh5Cf/stQAzYSuLpPo56Do=; b=FEC9uEup9Neav9R+6U+sr3qeNh7Pg8WcbZYYXZwTn8O8CiG2ftP1IPYk0zCyjiYFSF c94oFOC9/6e94fHGubU93cGjPF1HGZHYHPragsSfEBUJ7FdZnpViexh6U4PPA/zRRum+ eJUlsS8wc4R+iMPuouzj/+4aQfrfbSeOVoqX8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VNfUmoHugTzMNVPlGX+wnRh5Cf/stQAzYSuLpPo56Do=; b=MF1rS6ARlB5Xk1sxRUpK2d52BCJLNbpnmeBATZoPk9R0HO5AGYtaMUsrjH6Oo9Cj40 +7sGeTP4+i0WTsdh2TNN2BBHLXOcA3jrLzOXBkTDzqXRjuJdO2SS962YSFxtWMVcK+yC 4RAycZ15p0hMIZYsv9RQLLEcF8w5w3x5Nl4rka2r/JTvGQ3YSx91IZTDBjz5oVuwdF0W a37Y/nS6wJaeEUFqRzymTUbYR2IG5+hgHT+I9g+S2jpC5zJ9566nTgmtMQl6o/ybjJSx +N2/xAVPbzRHBIDfgWoWD1tdVRrHsIVC8TG+ssAWVFfPQ397IopOTVmKGbfASQo0QRmK +ylQ== X-Gm-Message-State: AOAM532IE404h3/99kuWyasRcqlBfAUWpYDMXOxsuPTnQlEgqYcniYgO 9inulZRqbjx5fun2T4YHOh4Fdg== X-Google-Smtp-Source: ABdhPJyVEoQImRCMu3zSXvZnm5dHPPI8XqAV4RWpzzfXPBlCN0XEN9HOeEk46yg5rZ5bTGUzmtXFMg== X-Received: by 2002:a63:f456:: with SMTP id p22mr13270729pgk.360.1607715515417; Fri, 11 Dec 2020 11:38:35 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h11sm11456024pjg.46.2020.12.11.11.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 11:38:34 -0800 (PST) Date: Fri, 11 Dec 2020 11:38:33 -0800 From: Kees Cook To: Sami Tolvanen Subject: Re: [PATCH v9 00/16] Add support for Clang LTO Message-ID: <202012111134.209A6D311@keescook> References: <20201211184633.3213045-1-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201211184633.3213045-1-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201211_143837_733851_8B6DF017 X-CRM114-Status: GOOD ( 27.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , clang-built-linux@googlegroups.com, linux-pci@vger.kernel.org, Josh Poimboeuf , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Dec 11, 2020 at 10:46:17AM -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]. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/lto > [2] https://lore.kernel.org/lkml/20201120040424.a3wctajzft4ufoiw@treble/ > [3] https://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git/log/?h=objtool-vmlinux > > You can also pull this series from > > https://github.com/samitolvanen/linux.git lto-v9 > > --- > Changes in v9: > > - Added HAS_LTO_CLANG dependencies to LLVM=1 and LLVM_IAS=1 to avoid > issues with mismatched toolchains. > > - Dropped the .mod patch as Masahiro landed a better solution to > the split line issue in commit 7d32358be8ac ("kbuild: avoid split > lines in .mod files"). > > - Updated CC_FLAGS_LTO to use -fvisibility=hidden to avoid weak symbol > visibility issues with ThinLTO on x86. > > - Changed LTO_CLANG_FULL to depend on !COMPILE_TEST to prevent > timeouts in automated testing. > > - Added a dependency to CPU_LITTLE_ENDIAN to ARCH_SUPPORTS_LTO_CLANG > in arch/arm64/Kconfig. > > - Added a default symbol list to fix an issue with TRIM_UNUSED_KSYMS. This continues to look good to me. I'd like to see it in -next ASAP so we can continue to find any little needed tweaks. Since it works in the general case, we can add on top of this series once it's in -next. Masahiro, let me know if you'd rather I not carry this in -next. AFAICT, the bulk of the changes in the build system continue to be confined to the LTO-only cases, so it should not be disruptive to anyone doing non-LTO builds. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel