On Tue, May 18, 2021 at 10:24:43PM +0200, Peter Zijlstra wrote: > OK, willy followed up on IRC, and it turns out there's a kbuild > dependency missing; then objtool changes we don't rebuild: > > arch/x86/entry/vdso/vma.o > > even though we should, this led to an unpatched 2 byte jump-label and > things went sideways. I'm not sure I understand the whole build > machinery well enough to know where to begin chasing this. > > Now, this file is mighty magical, due to: > > arch/x86/entry/vdso/Makefile:OBJECT_FILES_NON_STANDARD := y > arch/x86/entry/vdso/Makefile:OBJECT_FILES_NON_STANDARD_vma.o := n > > Maybe that's related. I'm not exactly thrilled that objtool now has the power to easily brick a system :-/ Is it really worth it? Anyway, here's one way to fix it. Maybe Masahiro has a better idea. >From f88b208677953bc445db08ac46b6e4259217bb8a Mon Sep 17 00:00:00 2001 Message-Id: <f88b208677953bc445db08ac46b6e4259217bb8a.1621384807.git.jpoimboe@xxxxxxxxxx> From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> Date: Tue, 18 May 2021 18:59:15 -0500 Subject: [PATCH] kbuild: Fix objtool dependency for 'OBJECT_FILES_NON_STANDARD_<obj> := n' "OBJECT_FILES_NON_STANDARD_vma.o := n" has a dependency bug. When objtool source is updated, the affected object doesn't get re-analyzed by objtool. Peter's new variable-sized jump label feature relies on objtool rewriting the object file. Otherwise the system can fail to boot. That effectively upgrades this minor dependency issue to a major bug. The problem is that variables in prerequisites are expanded early, during the read-in phase. The '$(objtool_dep)' variable indirectly uses '$@', which isn't yet available when the target prerequisites are evaluated. Use '.SECONDEXPANSION:' which causes '$(objtool_dep)' to be expanded in a later phase, after the target-specific '$@' variable has been defined. Fixes: b9ab5ebb14ec ("objtool: Add CONFIG_STACK_VALIDATION option") Fixes: ab3257042c26 ("jump_label, x86: Allow short NOPs") Reported-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> --- scripts/Makefile.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 949f723efe53..34d257653fb4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -268,7 +268,8 @@ define rule_as_o_S endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE +.SECONDEXPANSION: +$(obj)/%.o: $(src)/%.c $(recordmcount_source) $$(objtool_dep) FORCE $(call if_changed_rule,cc_o_c) $(call cmd,force_checksrc) @@ -349,7 +350,7 @@ cmd_modversions_S = \ fi endif -$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE +$(obj)/%.o: $(src)/%.S $$(objtool_dep) FORCE $(call if_changed_rule,as_o_S) targets += $(filter-out $(subdir-builtin), $(real-obj-y)) -- 2.31.1
![]() |