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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no 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 B86C1C433E2 for ; Wed, 24 Jun 2020 20:35:18 +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 4EF6B2080C for ; Wed, 24 Jun 2020 20:35:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="f8yvqKUc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Uawx1Hym" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EF6B2080C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=M1W095UjEZoYrrMUCM+DkpAzdbYagzGPLNExOa1GoeY=; b=f8yvqKUcecOqzX4eitGwDC2QHj mZnuvbnsvue9g4nVvW8FHq1eQdGCgaoZhez6VUzUqD/I98/K5cEuw6gW5KEErHqgNFWI6FyA4KIjB 79MNdhHZW1G3/9NAthswI6CTiwYYl4Hu0DIltzP2Q3KFdqtAK7w8fZphWjEqzaR+0+aimJgSu/CHy YZ+lPTHq7VE1MvsbIFsQzP1RcQh4+XeTDVW0eIdErDmejOJMbIkprhipuedlLMHI470rvKKAzmU50 Hfw7WcSqayiKzPcyRoboFxRnCFdC+7CozDoFhw+2dMkmtKRtjeJ6IHD2pKmrLFMxmGnwjy2bUJUQO 2jShW/6w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joC4k-0006zp-8D; Wed, 24 Jun 2020 20:32:54 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joC4g-0006xn-Fh for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 20:32:51 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id m63so3468976ybc.13 for ; Wed, 24 Jun 2020 13:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=geZqQu8Pc2IZyEmyfjSbirVoyCHoNCVPX8WSrD5/a0I=; b=Uawx1HymTuOmFuIsE6m0edc2JOJkrIL4ohCvAqVmbJ8lL51+F8GFU8Edzr7cqZcv2w HodyjPnW3CEUXq8PkZVULO6ZyoUtxp9+p+vdtGUCMz8qqae3fj+ztQ8oZGg5KLQxzxtv WsCNEibFNfuA+bNlcIR8b4sSEDOv2SkH85c5Dy7chvY+wP/aaRR1NsYEhp1bKM54GsoI 2QcLu0Jhfop40Tu+FeyQ89Qe5QVYishLUcPnbhRan/pilxFWfHclHWVyGJPxpvvrwTh0 JNHLSYYTI2a6tpFbw45+Zc3Ez5EH+jMImL6HifoQ7sZW+Y10m8LKlencaSHV2sNpKm9n vXag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=geZqQu8Pc2IZyEmyfjSbirVoyCHoNCVPX8WSrD5/a0I=; b=ncvIg0azjSB2Vh8iuS1GeN6mp7zdj+9vrsq1bfS1IfPYcQbGbh4SSZz1umv6p9hHXc yuPNS1JUqa3lezOko/DW+nhu2vhY+mmIlNNOVWQPwtYh/wS88XAOUR9Dm4Rjg+dRk2xQ jVuQLfv38eRjYyuxDUVsYOlwE4XQlXSYRma09szopygCFfBM5IzUDKAJtB4nuiLasJJ+ xx3QkrNSwF+lZgDOvtHpWPvuFnPU46Qt7Mn/9jN0rUWF80SeQ9dDK5IZjJy8Ceu2llwY g6qXP/MO3opR6JTH5KY19DB7+/9+x+cDy2nL500EcUEdo1mEylh8t3cFtPcIWeanYors 9ISQ== X-Gm-Message-State: AOAM533KypvmDzC3zFi07xfaRkI6Exso2kGkYrhbgI96VWjbfUERxFIt 4MD/eDC0dGAav87r5kNpeJrC6DKHVzFjOFZl7pE= X-Google-Smtp-Source: ABdhPJxWR9GEuM9Xe3hags9/hH99MHEAXvV4G6BQoWnGF1JJpG+hf2xaFzi6meCZqAzm99eCovUBw+L4m3sg7uT3BU4= X-Received: by 2002:a25:3342:: with SMTP id z63mr44129932ybz.200.1593030767109; Wed, 24 Jun 2020 13:32:47 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:38 -0700 Message-Id: <20200624203200.78870-1-samitolvanen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 00/22] add support for Clang LTO From: Sami Tolvanen To: Masahiro Yamada , Will Deacon 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, x86@kernel.org, Kees Cook , "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Sami Tolvanen , linux-pci@vger.kernel.org, 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 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's Pixel devices have shipped with LTO+CFI kernels 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 first objtool patch in the series is already in linux-next, but as it's needed with LTO, I'm including it also here to make testing easier. Sami Tolvanen (22): objtool: use sh_info to find the base for .rela sections kbuild: add support for Clang LTO kbuild: lto: fix module versioning kbuild: lto: fix recordmcount kbuild: lto: postpone objtool kbuild: lto: limit inlining kbuild: lto: merge module sections kbuild: lto: remove duplicate dependencies from .mod files init: lto: ensure initcall ordering init: lto: fix PREL32 relocations pci: lto: fix PREL32 relocations modpost: lto: strip .lto from module names scripts/mod: disable LTO for empty.c efi/libstub: disable LTO drivers/misc/lkdtm: disable LTO for rodata.o arm64: export CC_USING_PATCHABLE_FUNCTION_ENTRY arm64: vdso: disable LTO arm64: allow LTO_CLANG and THINLTO to be selected x86, vdso: disable LTO only for vDSO x86, ftrace: disable recordmcount for ftrace_make_nop x86, relocs: Ignore L4_PAGE_OFFSET relocations x86, build: allow LTO_CLANG and THINLTO to be selected .gitignore | 1 + Makefile | 27 ++- arch/Kconfig | 65 +++++++ arch/arm64/Kconfig | 2 + arch/arm64/Makefile | 1 + arch/arm64/kernel/vdso/Makefile | 4 +- arch/x86/Kconfig | 2 + arch/x86/Makefile | 5 + arch/x86/entry/vdso/Makefile | 5 +- arch/x86/kernel/ftrace.c | 1 + arch/x86/tools/relocs.c | 1 + drivers/firmware/efi/libstub/Makefile | 2 + drivers/misc/lkdtm/Makefile | 1 + include/asm-generic/vmlinux.lds.h | 12 +- include/linux/compiler-clang.h | 4 + include/linux/compiler.h | 2 +- include/linux/compiler_types.h | 4 + include/linux/init.h | 78 +++++++- include/linux/pci.h | 15 +- kernel/trace/ftrace.c | 1 + lib/Kconfig.debug | 2 +- scripts/Makefile.build | 55 +++++- scripts/Makefile.lib | 6 +- scripts/Makefile.modfinal | 40 +++- scripts/Makefile.modpost | 26 ++- scripts/generate_initcall_order.pl | 270 ++++++++++++++++++++++++++ scripts/link-vmlinux.sh | 100 +++++++++- scripts/mod/Makefile | 1 + scripts/mod/modpost.c | 16 +- scripts/mod/modpost.h | 9 + scripts/mod/sumversion.c | 6 +- scripts/module-lto.lds | 26 +++ scripts/recordmcount.c | 3 +- tools/objtool/elf.c | 2 +- 34 files changed, 737 insertions(+), 58 deletions(-) create mode 100755 scripts/generate_initcall_order.pl create mode 100644 scripts/module-lto.lds base-commit: 26e122e97a3d0390ebec389347f64f3730fdf48f -- 2.27.0.212.ge8ba1cc988-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel