Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4290791pxp; Tue, 15 Mar 2022 17:31:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlc/gBGltDKYJF23pJSZnmb2uqUNmh0hMiV0+tx4vPYeacZaEpDqV0nERYpcBJ8KNdyApO X-Received: by 2002:a17:907:6286:b0:6da:6e24:5e43 with SMTP id nd6-20020a170907628600b006da6e245e43mr25065873ejc.449.1647390704808; Tue, 15 Mar 2022 17:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647390704; cv=none; d=google.com; s=arc-20160816; b=oTk8IwdU5t+Kcj2PbjBGY2aNwicyHaJVp6OJSpYtGD2GzkDIZkdBx0/EYYDUMCMLsr 3W8nO30u7p+YvcyhHLY6OASQkn+6pNT8GkTpThCLmBB0BEzUBzzn3OLc8ild9uGAEQ2e 3q3s3EB32S+GII54+M1PuSK5Mabchq2RTmf2EIIkkE+joDKZdWJYVBYhDLiidNVgzH6U mXwOLW9/mpRhxtEnrJMImy6sQjT4Br2HdEzY/qQWMjFiX83aPwe/d8j+Ifo22NKRut23 CCW9yptqPHk0jklqO/Lt92Qo/fNvgs0yJ/LeaZOvW85f8G1p5YA4X5XLgzRRaE8HrK/R O8xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qyv9L1J7lwguExQlG54d6Y/3Vo+2ko997MYNN73Ttqo=; b=aGLWYT3geYb3dPPpijQaC2Ht3r+FBpOY5b6A1rktUOGJN6BV+buc4Nnqggsbfs7XYy 3EdFWlruM/fkhfLhS5iiwkUtmp6Bf38zm7prB8Idx6zfIVDqcyOagYWm2w3S1TVVP+wS hCkQQb3i/1k5PZffn+xX7KFqmtcnhVl7DyaNBWTwygdIlvNpVnPoTU4FCRkJoEeN+yfi HTUq5Xt043Veo8AZx2xJ9q8E3ifRgJn0mQHGbS/wOa9FL0iS0wxdY9RqP3pQvJqpYr2h 8SQvO4GJPU2hJI9pAbC+SHBoe5tHObWvmfcwH15K0TtAdVspRlNPlQ0n4vIAXyrsBd9+ tzXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=OVHBEZrc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js10-20020a17090797ca00b006db3aa7acbesi280604ejc.946.2022.03.15.17.31.18; Tue, 15 Mar 2022 17:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=OVHBEZrc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345790AbiCOIRN (ORCPT + 99 others); Tue, 15 Mar 2022 04:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345787AbiCOIRK (ORCPT ); Tue, 15 Mar 2022 04:17:10 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5677F4BFCF; Tue, 15 Mar 2022 01:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qyv9L1J7lwguExQlG54d6Y/3Vo+2ko997MYNN73Ttqo=; b=OVHBEZrcSgULGYImZyZkeB3Dqz 3mskSLqD8AwhZSFAA7P/tPJv7+HK2PEdrKy52Xglr8vRqFGDVFu9EfUh97rSAN0G09sd6ImNb2lGO Kx6A9vSANmb1GH9jY+ADoPlxn7jYM0uxiIwDc7iKyQQhSjIss+XMa6lVhLLEaBb8CS/o+6NUGpPyo aiHUrZlqrV+ezBfxrpwzlMxTYbXbykV90OpfWcKKOJ9kepb5Bw+sQ8v+quvD/ZqJv/G/sTJ67/Awz WlZWrls9KEinKvs9pd+ybn364wMZrD5hOR9rePpWTxWZ+/n2WIpwp18y4Na8y4ZQREbQgLSecriHW QTRr04Aw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nU2Ky-0019lg-15; Tue, 15 Mar 2022 08:15:24 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 6C8F0986205; Tue, 15 Mar 2022 09:15:22 +0100 (CET) Date: Tue, 15 Mar 2022 09:15:22 +0100 From: Peter Zijlstra To: Alexei Starovoitov Cc: Kumar Kartikeya Dwivedi , X86 ML , joao@overdrivepizza.com, hjl.tools@gmail.com, Josh Poimboeuf , Andrew Cooper , LKML , Nick Desaulniers , Kees Cook , Sami Tolvanen , Mark Rutland , alyssa.milburn@intel.com, Miroslav Benes , Steven Rostedt , Masami Hiramatsu , Daniel Borkmann , Andrii Nakryiko , bpf , masahiroy@kernel.org Subject: Re: [PATCH v4 00/45] x86: Kernel IBT Message-ID: <20220315081522.GA8939@worktop.programming.kicks-ass.net> References: <20220309190917.w3tq72alughslanq@ast-mbp.dhcp.thefacebook.com> <20220312154407.GF28057@worktop.programming.kicks-ass.net> <20220313085214.GK28057@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 14, 2022 at 03:59:05PM +0100, Peter Zijlstra wrote: > On Sun, Mar 13, 2022 at 09:52:14AM +0100, Peter Zijlstra wrote: > > On Sat, Mar 12, 2022 at 05:33:39PM -0800, Alexei Starovoitov wrote: > > > During the build with gcc 8.5 I see: > > > > > > arch/x86/crypto/crc32c-intel.o: warning: objtool: file already has > > > .ibt_endbr_seal, skipping > > > arch/x86/crypto/crc32c-intel.o: warning: objtool: file already has > > > .orc_unwind section, skipping > > > LD [M] crypto/async_tx/async_xor.ko > > > LD [M] crypto/authenc.ko > > > make[3]: *** [../scripts/Makefile.modfinal:61: > > > arch/x86/crypto/crc32c-intel.ko] Error 255 > > > make[3]: *** Waiting for unfinished jobs.... > > > > > > but make clean cures it. > > > I suspect it's some missing makefile dependency. > > > > Yes, I recently ran into it; I've been trying to kick Makefile into > > submission but have not had success yet. Will try again on Monday. > > > > Problem appears to be that it will re-link .ko even though .o hasn't > > changed, resulting in duplicate objtool runs. I've been trying to have > > makefile generate .o.objtool empty file to serve as dependency marker to > > avoid doing second objtool run, but like said, no luck yet. > > Masahiro-san, I'm trying the below, but afaict it's not working because > the rule for the .o file itself: > Ha, sleep, it is marvelous! The below appears to be working as desired. --- Index: linux-2.6/scripts/Makefile.build =================================================================== --- linux-2.6.orig/scripts/Makefile.build +++ linux-2.6/scripts/Makefile.build @@ -86,12 +86,18 @@ ifdef need-builtin targets-for-builtin += $(obj)/built-in.a endif -targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) +targets-for-modules := ifdef CONFIG_LTO_CLANG targets-for-modules += $(patsubst %.o, %.lto.o, $(filter %.o, $(obj-m))) endif +ifdef CONFIG_X86_KERNEL_IBT +targets-for-modules += $(patsubst %.o, %.objtool, $(filter %.o, $(obj-m))) +endif + +targets-for-modules += $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) + ifdef need-modorder targets-for-modules += $(obj)/modules.order endif @@ -276,6 +282,19 @@ cmd_mod = { \ $(obj)/%.mod: $(obj)/%$(mod-prelink-ext).o FORCE $(call if_changed,mod) +# +# Since objtool will re-write the file it will change the timestamps, therefore +# it is critical that the %.objtool file gets a timestamp *after* objtool runs. +# +# Additionally, care must be had with ordering this rule against the other rules +# that take %.o as a dependency. +# +cmd_objtool_mod = \ + true $(cmd_objtool) ; touch $@ + +$(obj)/%.objtool: $(obj)/%$(mod-prelink-ext).o FORCE + $(call if_changed,objtool_mod) + quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ Index: linux-2.6/scripts/Makefile.lib =================================================================== --- linux-2.6.orig/scripts/Makefile.lib +++ linux-2.6/scripts/Makefile.lib @@ -552,9 +552,8 @@ objtool_args = \ $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \ $(if $(CONFIG_SLS), --sls) -cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@) -cmd_objtool_mod = $(if $(objtool-enabled), $(objtool) $(objtool_args) $(@:.ko=.o) ; ) -cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd) +cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $(@:.objtool=.o)) +cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$(@:.objtool=.o): $$(wildcard $(objtool))' ; } >> $(dot-target).cmd) endif # CONFIG_STACK_VALIDATION @@ -575,8 +574,8 @@ $(obj)/%.o: objtool-enabled := # instead run objtool on the module as a whole, right before # the final link pass with the linker script. -%.ko: objtool-enabled = y -%.ko: part-of-module := y +$(obj)/%.objtool: objtool-enabled = y +$(obj)/%.objtool: part-of-module := y else Index: linux-2.6/scripts/Makefile.modfinal =================================================================== --- linux-2.6.orig/scripts/Makefile.modfinal +++ linux-2.6/scripts/Makefile.modfinal @@ -32,7 +32,6 @@ ARCH_POSTLINK := $(wildcard $(srctree)/a quiet_cmd_ld_ko_o = LD [M] $@ cmd_ld_ko_o += \ - $(cmd_objtool_mod) \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ -T scripts/module.lds -o $@ $(filter %.o, $^); \