Skip to content

Commit e501ce9

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86: Force asm-goto
We want to start using asm-goto to guarantee the absence of dynamic branches (and thus speculation). A primary prerequisite for this is of course that the compiler supports asm-goto. This effecively lifts the minimum GCC version to build an x86 kernel to gcc-4.5. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: torvalds@linux-foundation.org Link: https://lkml.kernel.org/r/20180319201327.GJ4043@hirez.programming.kicks-ass.net
1 parent edc39c9 commit e501ce9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
494494
RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))
495495
export RETPOLINE_CFLAGS
496496

497+
# check for 'asm goto'
498+
ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
499+
CC_HAVE_ASM_GOTO := 1
500+
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
501+
KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
502+
endif
503+
497504
ifeq ($(config-targets),1)
498505
# ===========================================================================
499506
# *config targets only - make sure prerequisites are updated, and descend
@@ -658,12 +665,6 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
658665
# Tell gcc to never replace conditional load with a non-conditional one
659666
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
660667

661-
# check for 'asm goto'
662-
ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
663-
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
664-
KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
665-
endif
666-
667668
include scripts/Makefile.kcov
668669
include scripts/Makefile.gcc-plugins
669670

arch/x86/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ ifdef CONFIG_FUNCTION_GRAPH_TRACER
181181
endif
182182
endif
183183

184+
ifndef CC_HAVE_ASM_GOTO
185+
$(error Compiler lacks asm-goto support.)
186+
endif
187+
184188
#
185189
# Jump labels need '-maccumulate-outgoing-args' for gcc < 4.5.2 to prevent a
186190
# GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46226). There's no way

0 commit comments

Comments
 (0)