x86/retpoline: split retpoline compiler support into separate option
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 31 Mar 2022 08:54:08 +0000 (10:54 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Mar 2022 08:54:08 +0000 (10:54 +0200)
Keep the previous option as a way to signal generic retpoline support
regardless of the underlying compiler, while introducing a new
CC_HAS_INDIRECT_THUNK that signals whether the underlying compiler
supports retpoline.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: e245bc154300b5d0367b64e8b937c9d1da508ad3
master date: 2022-02-21 18:17:56 +0000

xen/arch/x86/Kconfig
xen/arch/x86/arch.mk

index ef72e7821b25d7caf7a26e6f3bd897e53962c51d..e20e53edfc2d10f06120715a3a826d26b2723ca4 100644 (file)
@@ -32,9 +32,13 @@ config ARCH_DEFCONFIG
        string
        default "arch/x86/configs/x86_64_defconfig"
 
-config INDIRECT_THUNK
+config CC_HAS_INDIRECT_THUNK
        def_bool $(cc-option,-mindirect-branch-register)
 
+config INDIRECT_THUNK
+       def_bool y
+       depends on CC_HAS_INDIRECT_THUNK
+
 config HAS_AS_CET_SS
        # binutils >= 2.29 or LLVM >= 6
        def_bool $(as-instr,wrssq %rax$(comma)0;setssbsy)
index 456e5d5c1ad765a84cb5026f62dcf429bc6619bf..abb55b440838e0e478385a31300e0e09d7179ea1 100644 (file)
@@ -41,10 +41,12 @@ CFLAGS += -mno-red-zone -fpic
 # SSE setup for variadic function calls.
 CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup)
 
-# Compile with thunk-extern, indirect-branch-register if avaiable.
-CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch=thunk-extern
-CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch-register
-CFLAGS-$(CONFIG_INDIRECT_THUNK) += -fno-jump-tables
+ifeq ($(CONFIG_INDIRECT_THUNK),y)
+# Compile with gcc thunk-extern, indirect-branch-register if available.
+CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch=thunk-extern
+CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch-register
+CFLAGS-$(CONFIG_CC_IS_GCC) += -fno-jump-tables
+endif
 
 ifdef CONFIG_XEN_IBT
 # Force -fno-jump-tables to work around