[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.16] x86/clang: add retpoline support



commit dc24f4342b718c570ec794a0fc953e82e894ee3c
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Thu Mar 31 10:56:34 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Mar 31 10:56:34 2022 +0200

    x86/clang: add retpoline support
    
    Detect whether the compiler supports clang retpoline option and enable
    by default if available, just like it's done for gcc.
    
    Note clang already disables jump tables when retpoline is enabled, so
    there's no need to also pass the fno-jump-tables parameter. Also clang
    already passes the return address in a register always on amd64, so
    there's no need for any equivalent mindirect-branch-register
    parameter.
    
    Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: 9412486707f8f1ca2eb31c2ef330c5e39c0a2f30
    master date: 2022-02-21 18:17:56 +0000
---
 xen/arch/x86/Kconfig | 3 ++-
 xen/arch/x86/arch.mk | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index e20e53edfc..34dcb47ecd 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -33,7 +33,8 @@ config ARCH_DEFCONFIG
        default "arch/x86/configs/x86_64_defconfig"
 
 config CC_HAS_INDIRECT_THUNK
-       def_bool $(cc-option,-mindirect-branch-register)
+       def_bool $(cc-option,-mindirect-branch-register) || \
+                $(cc-option,-mretpoline-external-thunk)
 
 config INDIRECT_THUNK
        def_bool y
diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index abb55b4408..976ac5aafe 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -46,6 +46,9 @@ ifeq ($(CONFIG_INDIRECT_THUNK),y)
 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
+
+# Enable clang retpoline support if available.
+CFLAGS-$(CONFIG_CC_IS_CLANG) += -mretpoline-external-thunk
 endif
 
 ifdef CONFIG_XEN_IBT
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.16



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.