aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-07-24 19:08:27 -0400
committerIngo Molnar <mingo@kernel.org>2018-07-25 06:00:08 -0400
commit92a4728608a8fd228c572bc8ff50dd98aa0ddf2a (patch)
tree88db14df88fb86397b038ca9177720e59ebc9321
parentb3681dd548d06deb2e1573890829dff4b15abf46 (diff)
x86/boot: Fix if_changed build flip/flop bug
Dirk Gouders reported that two consecutive "make" invocations on an already compiled tree will show alternating behaviors: $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h DATAREL arch/x86/boot/compressed/vmlinux Kernel: arch/x86/boot/bzImage is ready (#48) Building modules, stage 2. MODPOST 165 modules $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h LD arch/x86/boot/compressed/vmlinux ZOFFSET arch/x86/boot/zoffset.h AS arch/x86/boot/header.o LD arch/x86/boot/setup.elf OBJCOPY arch/x86/boot/setup.bin OBJCOPY arch/x86/boot/vmlinux.bin BUILD arch/x86/boot/bzImage Setup is 15644 bytes (padded to 15872 bytes). System is 6663 kB CRC 3eb90f40 Kernel: arch/x86/boot/bzImage is ready (#48) Building modules, stage 2. MODPOST 165 modules He bisected it back to: commit 98f78525371b ("x86/boot: Refuse to build with data relocations") The root cause was the use of the "if_changed" kbuild function multiple times for the same target. It was designed to only be used once per target, otherwise it will effectively always trigger, flipping back and forth between the two commands getting recorded by "if_changed". Instead, this patch merges the two commands into a single function to get stable build artifacts (i.e. .vmlinux.cmd), and a single build behavior. Bisected-and-Reported-by: Dirk Gouders <dirk@gouders.net> Fix-Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20180724230827.GA37823@beast Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/boot/compressed/Makefile8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index fa42f895fdde..169c2feda14a 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -106,9 +106,13 @@ define cmd_check_data_rel
106 done 106 done
107endef 107endef
108 108
109# We need to run two commands under "if_changed", so merge them into a
110# single invocation.
111quiet_cmd_check-and-link-vmlinux = LD $@
112 cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld)
113
109$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 114$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
110 $(call if_changed,check_data_rel) 115 $(call if_changed,check-and-link-vmlinux)
111 $(call if_changed,ld)
112 116
113OBJCOPYFLAGS_vmlinux.bin := -R .comment -S 117OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
114$(obj)/vmlinux.bin: vmlinux FORCE 118$(obj)/vmlinux.bin: vmlinux FORCE