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=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 5CBDEC433E2 for ; Tue, 8 Sep 2020 20:57:45 +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 0B0CA20732 for ; Tue, 8 Sep 2020 20:57:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z83pzeSZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="kqiVfXTq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B0CA20732 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: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=laqCjHKjWX+r+h3sRctOibAYsJVEI0LfOElf6XEuCo0=; b=z83pzeSZ2qld4On/NHFUZvxUu n2JcFbAEb6KZzcqn4GQdQvQ47IDmRXDL5/mkcO/Vt7FrR0h41CEXPu/+WfOhdmdFW7gd/tHSudUWK BnspzwWriIFpDqfkWuhMx/22WPQQwnKKPA2EOkTwqs7905TnBDsFL8gqarTA7WJo8q/bzaCz8hXrx 1Xxxl8Ihj2D9VjOEmfjnSY0VY1SgXiMzUCvlwskG+uf4bEYL05K+sulClETb+IhmTTmZvLJxT0aoL cwScqwGcEtFuYyMQeKwAWKmGJX4d5hiO7pqybmHkCzGUdy8ZwsUNl60WwVHxjSCgC2/iRWBrazd8Q LlryWCCFQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFkfC-0005mb-33; Tue, 08 Sep 2020 20:56:26 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFkf8-0005lU-Jt for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 20:56:23 +0000 Received: by mail-pj1-x1043.google.com with SMTP id jw11so223059pjb.0 for ; Tue, 08 Sep 2020 13:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+1kwkhnnjfbD1n3YicFbQyeenHuldLrryzBMnu30RTk=; b=kqiVfXTqdvpE+D8HME82Bm/99OYWSZDGK7Oq76UCHFIRCcsokRD7oz4xAQHKlHR74v 8jFd7Rm7VgphQioMxWqT6sB7WDRfEhiq+5dlPJB+VwsYe0Gws+0LJm6D9zwG/r15KK4j cuzPLvDpOo+kNSRVML9vt8TFZj2LIN0dx3+GMt+v/gfQiWWDTGc/5e1sfumXGI2CjeI6 Wy++ioGxrd4TyZOe6AhKrFK49Dd0klSTZ4EyeBc8yeTCbAl+4UnrnXBHPmJZk+pzkRBq MO/Socm9d6L4MR4DbsbQU9qRVnfcNKA/i/3XI/d16ytiFjJKk9h0Y3hAMCxgdwcJ4siN gBjQ== 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=+1kwkhnnjfbD1n3YicFbQyeenHuldLrryzBMnu30RTk=; b=sBSwrViW06Dk3KyT8K5cXXs48dveU/XRqZO+NaQD3KHd5WcGbxPFGQx+U8Bo+U2KX0 ZAKToOrUuRQXMNMIwJk9ioswCgUBE1TZzmUVcaIZGUlD+ksPMXINeR/CL94YsRvl4Hho FZFhFpJrR08nINC5XLFYGiMnqTMezq8shPmwG5YP4QcNqvzrskCBb1FEvumoL1mplkj8 PxWbhGTOEyGZuB+ZiBdPuZy5rGtUKUwKejEgz/xiJbCDYPICbP+Wi+6SiNoA/jn3E4Ph /p7MYd2/VEboj3vTiPbDJA2jz+bPdlfB+hhOcKNU1c1xMJUvQa+XlNWHu17amzr/xltY aNJw== X-Gm-Message-State: AOAM532u50gGQ3nhxVsEPulRzeVCGYr5CzAdggbRP0e8tk253D+wlDt/ TElw644jUSEiW2EbcSO/BQyVQA== X-Google-Smtp-Source: ABdhPJwmdCJZLAUsrl/QW5wKuUZMBwlVdVl2VXP+Jk7zMzVi2ljr8t2PHAqCINz0HMBlae3lzorpYw== X-Received: by 2002:a17:90b:3444:: with SMTP id lj4mr574843pjb.78.1599598579801; Tue, 08 Sep 2020 13:56:19 -0700 (PDT) Received: from google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) by smtp.gmail.com with ESMTPSA id e14sm187682pgu.47.2020.09.08.13.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 13:56:19 -0700 (PDT) Date: Tue, 8 Sep 2020 13:56:12 -0700 From: Sami Tolvanen To: Kees Cook Subject: Re: [PATCH v2 11/28] kbuild: lto: postpone objtool Message-ID: <20200908205612.GA1060586@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-12-samitolvanen@google.com> <202009031513.B558594FB9@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202009031513.B558594FB9@keescook> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_165622_698087_81555A7B X-CRM114-Status: GOOD ( 26.54 ) 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, "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, 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 Thu, Sep 03, 2020 at 03:19:43PM -0700, Kees Cook wrote: > On Thu, Sep 03, 2020 at 01:30:36PM -0700, Sami Tolvanen wrote: > > 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 > > For a "fail fast" style of building, it makes sense to have objtool run > as early as possible, so it makes sense to keep the current behavior in > non-LTO mode. I do wonder, though, if there is a real benefit to having > "fail fast" case. I imagine a lot of automated builds are using > --keep-going with make, and actually waiting until the end to do the > validation means more code will get build-tested before objtool rejects > the results. *shrug* > > > --- > > arch/Kconfig | 2 +- > > scripts/Makefile.build | 2 ++ > > scripts/Makefile.modfinal | 24 ++++++++++++++++++++++-- > > scripts/link-vmlinux.sh | 23 ++++++++++++++++++++++- > > 4 files changed, 47 insertions(+), 4 deletions(-) > > > > diff --git a/arch/Kconfig b/arch/Kconfig > > index 71392e4a8900..7a418907e686 100644 > > --- a/arch/Kconfig > > +++ b/arch/Kconfig > > @@ -599,7 +599,7 @@ config LTO_CLANG > > depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) > > depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) > > depends on ARCH_SUPPORTS_LTO_CLANG > > - depends on !FTRACE_MCOUNT_RECORD > > + depends on HAVE_OBJTOOL_MCOUNT || !(X86_64 && DYNAMIC_FTRACE) > > depends on !KASAN > > depends on !GCOV_KERNEL > > select LTO > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > > index c348e6d6b436..b8f1f0d65a73 100644 > > --- a/scripts/Makefile.build > > +++ b/scripts/Makefile.build > > @@ -218,6 +218,7 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), > > endif # USE_RECORDMCOUNT > > > > ifdef CONFIG_STACK_VALIDATION > > +ifndef CONFIG_LTO_CLANG > > ifneq ($(SKIP_STACK_VALIDATION),1) > > > > __objtool_obj := $(objtree)/tools/objtool/objtool > > @@ -253,6 +254,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 1005b147abd0..909bd509edb4 100644 > > --- a/scripts/Makefile.modfinal > > +++ b/scripts/Makefile.modfinal > > @@ -34,10 +34,30 @@ ifdef CONFIG_LTO_CLANG > > # With CONFIG_LTO_CLANG, reuse the object file we compiled for modpost to > > # avoid a second slow LTO link > > prelink-ext := .lto > > -endif > > + > > +# ELF processing was skipped earlier because we didn't have native code, > > +# so let's now process the prelinked binary before we link the module. > > + > > +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,) \ > > + $(if $(USE_OBJTOOL_MCOUNT),--mcount,) \ > > + $(@:.ko=$(prelink-ext).o); > > + > > +endif # SKIP_STACK_VALIDATION > > +endif # CONFIG_STACK_VALIDATION > > I wonder if objtool_args could be reused here instead of having two > places to keep in sync? It looks like that might mean moving things > around a bit before this patch, since I can't quite see if > Makefile.build's variables are visible to Makefile.modfinal? It doesn't look like they are. I suppose we could move objtool_args to Makefile.lib. Masahiro, any thoughts? Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel