Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp969795pxp; Wed, 16 Mar 2022 23:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5u8Ef2mgVyd69vyEHpjiume2+flA+bMXrgBpnv79RTPVOcsIwXcgQ6ErhQCIm1X3kDn+q X-Received: by 2002:a65:6e87:0:b0:380:a1ef:a9be with SMTP id bm7-20020a656e87000000b00380a1efa9bemr2474401pgb.284.1647496877593; Wed, 16 Mar 2022 23:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647496877; cv=none; d=google.com; s=arc-20160816; b=CUX9MfBoz4DOdWJYIu/4/01EPBHjmZIn8DY2eORMGB2hty5jJaZQ0eGIhr+gKAbhUL /D84F+g4+We53p2DvDxOKZPRNqjsWiwT5z/4ANkPnBvhGvCrbHsFNImWGE4lDxDMUuxu yJHnS3+Xb0x6uY/kiWi4aYtoOJ4UjsZbVOchspO5LszZTk/jUYXQwPEvc2+uQoj/lZeR JjnqbkXz9WMDVG9ooSG3sFzXcC7VQCt1sj0ReqXkCkhQLqsiTTjvF44ElaR0uCjyf70w 3hLzvWsnaxtvuImUewS8s802xYaveITCzPDqnDxXo+L5bnzB0a21nyl2BF5Fk0goP7cf p1rQ== 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:dkim-filter; bh=kto8rSbm3Q3xiCM3iwqUkTy1Lz+u7MD+xAW0APggEBU=; b=dqPgK1eDugYGhO7WwSXFTVbob9GaDmREYboKIGJ74eV8LX1WGilQGhHGlODR6lVNuT bqaSBGaDZxv52DkmIQVTT5M1dfPSF5BEHBm+WlY+Jemh0sVpEjCilyYgYKu8p2h3wy33 mhT4Oa6pkP1hg/v/2ePQnEj+mKBRc0Q+02tC+JD3we5q/eZHOhWYfTl8mHKYLBroj1L7 0yul/wD4BbcxXrz9TIVmYxxs3oseEBC7XXbE2YXjKDDy/uLVs16/9tkSyYphiG7mHCHz 6PvlIS568cZCLER1ORwiLvY1e7E5RdsyweAXOaO3XSXBRudCiVnSVz19JqRVG52QlYGu suRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=B36aTK1e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j1-20020a056a00174100b004f79b676f54si4207742pfc.350.2022.03.16.23.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=B36aTK1e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14C9B21FF7C; Wed, 16 Mar 2022 22:00:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350053AbiCOQaT (ORCPT + 99 others); Tue, 15 Mar 2022 12:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350010AbiCOQaS (ORCPT ); Tue, 15 Mar 2022 12:30:18 -0400 X-Greylist: delayed 105 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 15 Mar 2022 09:29:06 PDT Received: from conssluserg-03.nifty.com (conssluserg-03.nifty.com [210.131.2.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D3E56C38; Tue, 15 Mar 2022 09:29:06 -0700 (PDT) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 22FGSqlW026839; Wed, 16 Mar 2022 01:28:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 22FGSqlW026839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1647361732; bh=kto8rSbm3Q3xiCM3iwqUkTy1Lz+u7MD+xAW0APggEBU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=B36aTK1eOn+/DzeSKGQletXIVYZrcXnog3sAaflmoIeR8H/7rpVhq+y+D6//2VaeO vVDy0Sa8nS1yzua+ySP4gGoK9GZNq7HgLBaN53Q90UhxYqn0A4IP+U75WLtf/R6AYf GO6JRuP+WZlvpvKRBE6+iX/aEVe/LCa+BhMC5Rb/H4GkfYaO64IlQKzEsMzEGSYwV4 0zTJkF/9RrsFTgLsvzRicpoRoLgT2BnnoHErkpYziHeRdDynhDEsJ8SL1dF4ZDxhUZ YAwJEZJhRQttDsojavllWVGf8W9or0rsUWfb3v0BRYJsrs0sYONIfF5dJmM8533BJZ pl+AeSF69MbgQ== X-Nifty-SrcIP: [209.85.216.44] Received: by mail-pj1-f44.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so2914770pjl.4; Tue, 15 Mar 2022 09:28:52 -0700 (PDT) X-Gm-Message-State: AOAM531Gy75IXSaPIJcsaU9KNUukIzfI7XD4enmH5/cQHrblVPfMRf9n bOExu+0NC4zBX3qQ4EPvpg2YgBJORLLM1Rag3xY= X-Received: by 2002:a17:90a:ab17:b0:1b9:b61a:aadb with SMTP id m23-20020a17090aab1700b001b9b61aaadbmr5506333pjq.77.1647361731601; Tue, 15 Mar 2022 09:28:51 -0700 (PDT) MIME-Version: 1.0 References: <20220309190917.w3tq72alughslanq@ast-mbp.dhcp.thefacebook.com> <20220312154407.GF28057@worktop.programming.kicks-ass.net> <20220313085214.GK28057@worktop.programming.kicks-ass.net> <20220315081522.GA8939@worktop.programming.kicks-ass.net> In-Reply-To: <20220315081522.GA8939@worktop.programming.kicks-ass.net> From: Masahiro Yamada Date: Wed, 16 Mar 2022 01:28:08 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 00/45] x86: Kernel IBT To: Peter Zijlstra Cc: Alexei Starovoitov , Kumar Kartikeya Dwivedi , X86 ML , joao@overdrivepizza.com, "H . J . Lu" , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Mar 15, 2022 at 5:15 PM Peter Zijlstra wrote: > > 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 := Why do you need to change this line? > > 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. Thanks for explaining how stupidly this works. NACK. I guess re-using the current clang-lto rule is much cleaner. (but please rename %.lto.o to %.prelink.o) Roughly like this: if CONFIG_LTO_CLANG || CONFIG_X86_KERNEL_IBT $(obj)/%.prelink: $(obj)/%.o FORCE [ $(LD) if CONFIG_LTO_CLANG ] + $(cmd_objtool) endif > +# > +# 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, $^); \ -- Best Regards Masahiro Yamada