Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4922120pxk; Wed, 30 Sep 2020 15:42:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx96qjVmR+rqoT6nnnnlbAUlQHm6SWiC2QGez9435F3XbkUPVKmmT/1O8bJUALWizmMuTsa X-Received: by 2002:aa7:d6c6:: with SMTP id x6mr5237532edr.338.1601505776374; Wed, 30 Sep 2020 15:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601505776; cv=none; d=google.com; s=arc-20160816; b=jXPiCith9/bVW1DstyVnSlWxLyHENudrWxCAHdOGPlq2WKxZEoU4H3Bsn3qZVBgr0D OzndiKtMHNI6fI0PxCtw0wVma62NNi5JhYb2nE0tn6XbPxLX+P6FaKXUkBJHcttr1ws4 qMxKCA7d79JQX8Lj1t6+k2GWl+mBBabt0aduEwE09A1hfVcO7tOiRmww/MvThKir4TgO XUIoscMZOFtPO5cNxZu/ilW7R1Jr5BO+86TFLKOh+B/wyYf2rPhvR+owjFDBKXkjHDqm kwQkhrOqU2mwIkF5CUDnnk3N9h6OMv2D/e+9wjaRFql1w5FhjqgWXY62h1uRDf6Nd+Q5 l31A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=t4yHwQDoeC7Qpj3w+ohiUiQzIr7R18uaPZSHZDC/wBA=; b=nzh12pQWzMc9Ec4tIkRWeYknaYxEawLFO+IYJ+wnPcc1ksx9aUrgjbBqF1NaRAQCia DxWb7hj4rbNgTYbYElysem9VsrrN7tqC6T9q9yyoWjDW4Zg6TuhL/VhpFc9Cibnel0Kz jMxLtskyQtSDRngZr/DoAh0RYg6EnxL5REjMKzlm89aXQLsEQkPQCKgTApaz2p/gvlqo Ikq+A7K3loVWXwu5GkcQFaJxvtNB68xqZou3DfgUmLTI5MvPACsFS5fOOH4FqF8B7JSG SxbnYIznF0X3aVI4SNrUUCzky7q/Nqjz1jKj3T1+60Dp8l+pDzE8qI8H5v/wXXW4jUkG Adqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LHz9Zcam; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si2073011edc.112.2020.09.30.15.42.33; Wed, 30 Sep 2020 15:42:56 -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=@google.com header.s=20161025 header.b=LHz9Zcam; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729996AbgI3V6N (ORCPT + 99 others); Wed, 30 Sep 2020 17:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728721AbgI3V6M (ORCPT ); Wed, 30 Sep 2020 17:58:12 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE87C0613D0 for ; Wed, 30 Sep 2020 14:58:12 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 197so2063364pge.8 for ; Wed, 30 Sep 2020 14:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t4yHwQDoeC7Qpj3w+ohiUiQzIr7R18uaPZSHZDC/wBA=; b=LHz9Zcam7CeKHZ2FruDPRDuY0e07YHSqVvGalfh32T3Fuffnt2bHgr5rwgpKJmywr5 vYYvj2pj3Prw08WL6qW4WlpRdEOLUCrT+9hncLjFVN1Ft8Md5FT+cXeVzwCbCclkl92o hiVEXzmM9WAhHeXPsScWmhH08ZPlqMeItatEG49WX1OQPxwmMQyfc2iYMB/Z7txm5yp9 RRa0vfTlhSB0oEdLv191LDpEXlrqdDLR97VB59MmnkaiwZ4LOuqrpJLUtPF1GuZMwqmk sGSI3yP3GaxL9/tqCvhaOlXgx1uB7P44MkrgKvdzV+0gcVnwItyMO1mDDu9EjVXS5h+m ERsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t4yHwQDoeC7Qpj3w+ohiUiQzIr7R18uaPZSHZDC/wBA=; b=HWkdvHYrT01WkFxYf7cTTo01XrR/J8eWmGEN0CgckLj37lLXxI5vhKtNVPoeq+3EjC 1n1Wv0vzBoPq7ygZJO6iDPr18DrR+SkhGaEPbXqrhUTiQjKfKU4TEDuhfjrOZS3uMFo2 Ox/YXQ1kTw14Na5u1lgczRGsg1n+GwVAa3/ECFFkeC+VVx22hxsDn2qilPP1qjbLBhsA 0p8sQElb0YndECWLBYCWb54rQJZ3G0OspfuYFVtZHVyPXY3/B28pfanP1te/F8dMxEJr 2qj5pJpFKolcPFYWQJtj4Wzggj1b4Kb6Zvt5ESe3CYtI56bUqkINb+5EMhZ/0o8OZgtb 4Fwg== X-Gm-Message-State: AOAM531ckS0eQvKqahbBKwDNYU57/Az9TrO6n3G4aVT7GTMp1Uqdl9m4 Gm40fcWw2fQbJv79tIFSO963P933L7ZVNivt0uxBmw== X-Received: by 2002:a17:902:c40d:b029:d2:93e8:1f4b with SMTP id k13-20020a170902c40db02900d293e81f4bmr4327278plk.29.1601503091998; Wed, 30 Sep 2020 14:58:11 -0700 (PDT) MIME-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 30 Sep 2020 14:58:00 -0700 Message-ID: Subject: Re: [PATCH v4 00/29] Add support for Clang LTO To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Steven Rostedt , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , LKML , linux-pci@vger.kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 2:46 PM Sami Tolvanen wrote: > > This patch series adds support for building x86_64 and arm64 kernels > 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. Sami, thanks for continuing to drive the series. I encourage you to keep resending with fixes accumulated or dropped on a weekly cadence. The series worked well for me on arm64, but for x86_64 on mainline I saw a stream of new objtool warnings: testing your LTO series; x86_64 defconfig + CONFIG_THINLTO: ``` LTO vmlinux.o OBJTOOL vmlinux.o vmlinux.o: warning: objtool: wakeup_long64()+0x61: indirect jump found in RETPOLINE build vmlinux.o: warning: objtool: .text+0x308a: indirect jump found in RETPOLINE build vmlinux.o: warning: objtool: .text+0x30c5: indirect jump found in RETPOLINE build vmlinux.o: warning: objtool: copy_user_enhanced_fast_string() falls through to next function copy_user_generic_unrolled() vmlinux.o: warning: objtool: __memcpy_mcsafe() falls through to next function mcsafe_handle_tail() vmlinux.o: warning: objtool: memset() falls through to next function memset_erms() vmlinux.o: warning: objtool: __memcpy() falls through to next function memcpy_erms() vmlinux.o: warning: objtool: __x86_indirect_thunk_rax() falls through to next function __x86_retpoline_rax() vmlinux.o: warning: objtool: __x86_indirect_thunk_rbx() falls through to next function __x86_retpoline_rbx() vmlinux.o: warning: objtool: __x86_indirect_thunk_rcx() falls through to next function __x86_retpoline_rcx() vmlinux.o: warning: objtool: __x86_indirect_thunk_rdx() falls through to next function __x86_retpoline_rdx() vmlinux.o: warning: objtool: __x86_indirect_thunk_rsi() falls through to next function __x86_retpoline_rsi() vmlinux.o: warning: objtool: __x86_indirect_thunk_rdi() falls through to next function __x86_retpoline_rdi() vmlinux.o: warning: objtool: __x86_indirect_thunk_rbp() falls through to next function __x86_retpoline_rbp() vmlinux.o: warning: objtool: __x86_indirect_thunk_r8() falls through to next function __x86_retpoline_r8() vmlinux.o: warning: objtool: __x86_indirect_thunk_r9() falls through to next function __x86_retpoline_r9() vmlinux.o: warning: objtool: __x86_indirect_thunk_r10() falls through to next function __x86_retpoline_r10() vmlinux.o: warning: objtool: __x86_indirect_thunk_r11() falls through to next function __x86_retpoline_r11() vmlinux.o: warning: objtool: __x86_indirect_thunk_r12() falls through to next function __x86_retpoline_r12() vmlinux.o: warning: objtool: __x86_indirect_thunk_r13() falls through to next function __x86_retpoline_r13() vmlinux.o: warning: objtool: __x86_indirect_thunk_r14() falls through to next function __x86_retpoline_r14() vmlinux.o: warning: objtool: __x86_indirect_thunk_r15() falls through to next function __x86_retpoline_r15() ``` I think those should be resolved before I provide any kind of tested by tag. My other piece of feedback was that I like the default ThinLTO, but I think the help text in the Kconfig which is visible during menuconfig could be improved by informing the user the tradeoffs. For example, if CONFIG_THINLTO is disabled, it should be noted that full LTO will be used instead. Also, that full LTO may produce slightly better optimized binaries than ThinLTO, at the cost of not utilizing multiple cores when linking and thus significantly slower to link. Maybe explaining that setting it to "n" implies a full LTO build, which will be much slower to link but possibly slightly faster would be good? It's not visible unless LTO_CLANG and ARCH_SUPPORTS_THINLTO is enabled, so I don't think you need to explain that THINLTO without those is *not* full LTO. I'll leave the precise wording to you. WDYT? Also, when I look at your treewide DISABLE_LTO patch, I think "does that need to be a part of this series, or is it a cleanup that can stand on its own?" I think it may be the latter? Maybe it would help shed one more patch than to have to carry it to just send it? Or did I miss something as to why it should remain a part of this series? -- Thanks, ~Nick Desaulniers