Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: Move RETPOLINE*_CFLAGS to arch Makefile

Currently, RETPOLINE*_CFLAGS are defined in the top-level Makefile
but only x86 makes use of them. Move them there. If ever another
architecture finds the need, it can be reconsidered.

[ bp: Massage a bit. ]

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lkml.kernel.org/r/20211119165630.219152765@infradead.org

authored by

Peter Zijlstra and committed by
Borislav Petkov
b2f825bf 34115065

+11 -11
-11
Makefile
··· 688 688 CC_FLAGS_FTRACE := -pg 689 689 endif 690 690 691 - ifdef CONFIG_CC_IS_GCC 692 - RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) 693 - RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) 694 - endif 695 - ifdef CONFIG_CC_IS_CLANG 696 - RETPOLINE_CFLAGS := -mretpoline-external-thunk 697 - RETPOLINE_VDSO_CFLAGS := -mretpoline 698 - endif 699 - export RETPOLINE_CFLAGS 700 - export RETPOLINE_VDSO_CFLAGS 701 - 702 691 include $(srctree)/arch/$(SRCARCH)/Makefile 703 692 704 693 ifdef need-config
+11
arch/x86/Makefile
··· 12 12 KBUILD_DEFCONFIG := $(ARCH)_defconfig 13 13 endif 14 14 15 + ifdef CONFIG_CC_IS_GCC 16 + RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) 17 + RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) 18 + endif 19 + ifdef CONFIG_CC_IS_CLANG 20 + RETPOLINE_CFLAGS := -mretpoline-external-thunk 21 + RETPOLINE_VDSO_CFLAGS := -mretpoline 22 + endif 23 + export RETPOLINE_CFLAGS 24 + export RETPOLINE_VDSO_CFLAGS 25 + 15 26 # For gcc stack alignment is specified with -mpreferred-stack-boundary, 16 27 # clang has the option -mstack-alignment for that purpose. 17 28 ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)