Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp878764ybt; Wed, 24 Jun 2020 13:36:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4mtzDDhQPMUJctjrq159xrVkcPvi7ZiWasZjWwsqkEANLlyefaJQfJSQvIr48ArgItTaN X-Received: by 2002:a05:6402:16db:: with SMTP id r27mr3074730edx.139.1593030990978; Wed, 24 Jun 2020 13:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593030990; cv=none; d=google.com; s=arc-20160816; b=0+28j3Dn8HBFflS1rhMnSdVSmrIO2IFJccFtsWse+UBGPb2DvZhQPXcJCHXBsq4Kub x1OAydoIIj11EWIr/g7uWp95sq/gN0Wep+nfxVfXIjIF7+LOMSTPVMMMRMnMGU/C6ejE Om4uAcFcczzl3zxmGOpUfv80KssSKVoyu9VCIY4slzb7fVHP6uo6O241+bYF+gTgsWFF uF8dBUsYRTjni12kJUJad1RPzHa7cR6YS9lroCFgj5Il7LdqhIOzOwu+jlHvWjvTu9+q unGXE2RgcWuu1zJQjV01gjOWB2OdtXrqXgkU0rTAubvWSaIOF/NFZ68vG9U4m3/vD4IB V6hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=E72RKePZ9QWe5v89HuDG9dmOi1TM58THK6MPfXGAxFQ=; b=C8oVl00/6fu8eaGtONgeTZ+Wva+4oo/ppEAOmdHpt/IfCTVAd+4yU0AY/b6zTv/1eO JA2xIa3kveHCDkEZ5KBIRi9wzN0uUcLmQ5BQW+k1xZL4npTOvu2TWJjLs61v67L+SvVi 7r0vBw5ILmozdFwGnDJ5P3/oFXl8kp+fD08+P/Q2g+G34jU8zVtOmAE9hJfr2Fl5aDUT BKw539eUXtcwrh01ltAPZywytmtR0sWl/5Sj/rhVgz1c+DBeZBqf+gfoDwOw1pTeL+PM e1QCeS3BaB6HOi0LqfZQQ4Jc/9mgsDWB2GsyxAVsTzQf363q1iRM2zAOMqkYiltl8Z+4 fRKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IfZnlNH6; 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 b24si1614267edy.271.2020.06.24.13.36.07; Wed, 24 Jun 2020 13:36:30 -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=IfZnlNH6; 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 S2406726AbgFXUfC (ORCPT + 99 others); Wed, 24 Jun 2020 16:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406444AbgFXUdH (ORCPT ); Wed, 24 Jun 2020 16:33:07 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BCE3C0613ED for ; Wed, 24 Jun 2020 13:33:07 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id bk16so2493428qvb.11 for ; Wed, 24 Jun 2020 13:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=E72RKePZ9QWe5v89HuDG9dmOi1TM58THK6MPfXGAxFQ=; b=IfZnlNH6VN1h5kv70OdYXiwpqxbG8Fsr0lLuwZMxg60FtsN9/VTg/yfhaEKY69+/+Y hyTqsTQRwHJPTGJCgx79BwJ5QVcEKyLgdthjRqbiH95tnfQghy4dm0yUNuDWrYAYeuQK bXlz5RTuRnG7qvLP46Ux6LdFVV3vgejq+f8vMdwP7C0ECe86rxVnbt4+28XS5oy0e//W 3PvqoaOrjXwuF1y+TVGpByJgFdYpZGp3bhGDnuXbGiV8bnYHuHTTFlOLOu5U7PsEVYbS zVdr70MPwdtPFtMyvFviHewEzUoy8KN1TAyWLRedjTg9ydVnxrcpJqLiET5LocVJTpl1 qi7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=E72RKePZ9QWe5v89HuDG9dmOi1TM58THK6MPfXGAxFQ=; b=mXukkxexqDbFY8FbIwR3w1/YSLIcalnOEnJsAXeVm2WpmeUeCDBbHcF6GlWp5QA2JM B6LoZDsDm0VKl4DYTJuxU8JGWsaKImJ35Za21iPoXxvSnIj0KgNZ0Gr6MqNIvZgTsjdy kCZW09etdRm8R0pBpNtRv3OLbK2oaiyqFWOoZUFmG5mOHXQFJDL8OeuzMTqF2DlvXcG8 pYfa23LBSwzffXNgADTH1uLHfu/wLVev66cpF620ZqW1SOPJzYd2/eJIHZ2ldiNl2AJ/ +LESisd3nFZgC2Pj3JYgzyOJUV9+DWS7x3kJO8Hbmz1lhxUMdIG3JSgykSUAQpWinNL5 mT8w== X-Gm-Message-State: AOAM532sK4AlNBkyKrmKSmxtn+vsy57TR9J7GtAhyHI7egrUf5Oqn7KR nh9GugEDqC8MDVHmjeisGWNDXT20PFqRc0nD0fk= X-Received: by 2002:a0c:85a3:: with SMTP id o32mr8043763qva.189.1593030786670; Wed, 24 Jun 2020 13:33:06 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:43 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-6-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 05/22] kbuild: lto: postpone objtool From: Sami Tolvanen To: Masahiro Yamada , Will Deacon Cc: Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , 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, x86@kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With LTO, LLVM bitcode won't be compiled into native code until modpost_link, or modfinal for modules. This change postpones calls to objtool until after these steps. Signed-off-by: Sami Tolvanen --- include/linux/compiler.h | 2 +- lib/Kconfig.debug | 2 +- scripts/Makefile.build | 2 ++ scripts/Makefile.modfinal | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 30827f82ad62..12b115152532 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -120,7 +120,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, /* Annotate a C jump table to allow objtool to follow the code flow */ #define __annotate_jump_table __section(.rodata..c_jump_table) -#ifdef CONFIG_DEBUG_ENTRY +#if defined(CONFIG_DEBUG_ENTRY) || defined(CONFIG_LTO_CLANG) /* Begin/end of an instrumentation safe region */ #define instrumentation_begin() ({ \ asm volatile("%c0:\n\t" \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 9ad9210d70a1..9fdba71c135a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -399,7 +399,7 @@ config STACK_VALIDATION config VMLINUX_VALIDATION bool - depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT + depends on STACK_VALIDATION && (DEBUG_ENTRY || LTO_CLANG) && !PARAVIRT default y config DEBUG_FORCE_WEAK_PER_CPU diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 64e99f4baa5b..82977350f5a6 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -226,6 +226,7 @@ endif # CC_USING_PATCHABLE_FUNCTION_ENTRY endif # CONFIG_FTRACE_MCOUNT_RECORD ifdef CONFIG_STACK_VALIDATION +ifndef CONFIG_LTO_CLANG ifneq ($(SKIP_STACK_VALIDATION),1) __objtool_obj := $(objtree)/tools/objtool/objtool @@ -258,6 +259,7 @@ objtool_obj = $(if $(patsubst y%,, \ $(__objtool_obj)) endif # SKIP_STACK_VALIDATION +endif # CONFIG_LTO_CLANG endif # CONFIG_STACK_VALIDATION # Rebuild all objects when objtool changes, or is enabled/disabled. diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index d168f0cfe67c..9f1df2f1fab5 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -48,6 +48,21 @@ endif # CC_USING_PATCHABLE_FUNCTION_ENTRY endif # CC_USING_RECORD_MCOUNT endif # CONFIG_FTRACE_MCOUNT_RECORD +ifdef CONFIG_STACK_VALIDATION +ifneq ($(SKIP_STACK_VALIDATION),1) +cmd_ld_ko_o += \ + $(objtree)/tools/objtool/objtool \ + $(if $(CONFIG_UNWINDER_ORC),orc generate,check) \ + --module \ + $(if $(CONFIG_FRAME_POINTER),,--no-fp) \ + $(if $(CONFIG_GCOV_KERNEL),--no-unreachable,) \ + $(if $(CONFIG_RETPOLINE),--retpoline,) \ + $(if $(CONFIG_X86_SMAP),--uaccess,) \ + $(@:.ko=$(prelink-ext).o); + +endif # SKIP_STACK_VALIDATION +endif # CONFIG_STACK_VALIDATION + endif # CONFIG_LTO_CLANG quiet_cmd_ld_ko_o = LD [M] $@ -- 2.27.0.212.ge8ba1cc988-goog