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

Re: [PATCH 2/3] x86/clang: add retpoline support


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 16 Feb 2022 10:47:52 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qJlSCB8e43RnlrcgLKPcBNvQmylBelKT3Fb3SbRaTxw=; b=Hqulem0vlLnEvjgbgpB+aFmX8Y/W3P9k2k36SYw8PUFlzmixQ9n4Myem/YhYnhh6YPVYlgFIE6vutRMjHDqEva9/EPBQFvsPuJPfDZinW/OMWchGi3GFcAV6gCqAazdb3s5yK82xIlKTI+SLbK/D7CebmtcLr2AkVyQlQUZBfeieUb3OCtki3T0sBPQMbSFk/GJx2t1l87CUowx+cTsqblGjj0wgOdSC9Iox9Ezf2Nqrm91kJe3rC6k7q0rnBW/lPJugoZkBj1b5mx1aeBaTsfvCKOfJ1xJEJigArD8Ygptm0Ix9i8aq0nFq/bRmWqMcy2T+Yvhr02K8X7Skjr8j4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k4g78f2Cax6A/43wI2u6/tlL5quJzjcSQ7rNZzbesQoick+YS6QaMEN3qSIByCGRGAdf7T7mbcl9qn6RyIAAkArKZf5dn0iFWLtf9iEc4iNN0B1HqPMvlBmlmHWBpe/AxK4mFa/0Uvb2T+xg5js1Q38W1IJTG4zg9eKHHzzlohoHH/soW9sGNrKVBtBNf5V9VvYoAVpvyh3I6C0NszmLYE5bviKuTUULq4sG/WekikhZfaRsJJOO0cJgi9aCBPZT3svCeknJW2MW1LO7drq0HY9IpBKJlzbi6PloHqEkClB5ZbHkv44MP3Dnmyl6hlxp1v84tfJToSNcGmGWR6jhmQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 16 Feb 2022 09:47:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.02.2022 10:02, Roger Pau Monne wrote:
> 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.

That's one of the secondary gcc side arrangements. What about the other
(-mindirect-branch-register)?

> Reported-by: Jan Beulich <JBeulich@xxxxxxxx>

That's Andrew, not me?

Jan

> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
>  xen/arch/x86/Kconfig | 5 ++++-
>  xen/arch/x86/arch.mk | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
> index 2cd713724f..fe00b4598b 100644
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -35,8 +35,11 @@ config ARCH_DEFCONFIG
>  config GCC_INDIRECT_THUNK
>       def_bool $(cc-option,-mindirect-branch-register)
>  
> +config CLANG_INDIRECT_THUNK
> +     def_bool $(cc-option,-mretpoline-external-thunk)
> +
>  config INDIRECT_THUNK
> -     depends on GCC_INDIRECT_THUNK
> +     depends on GCC_INDIRECT_THUNK || CLANG_INDIRECT_THUNK
>       def_bool y
>  
>  config HAS_AS_CET_SS
> diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
> index 2da4bdb1ed..f2aa2a515f 100644
> --- a/xen/arch/x86/arch.mk
> +++ b/xen/arch/x86/arch.mk
> @@ -47,6 +47,9 @@ CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += 
> -mindirect-branch=thunk-extern
>  CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += -mindirect-branch-register
>  CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += -fno-jump-tables
>  
> +# Enable clang retpoline support if available.
> +CFLAGS-$(CONFIG_CLANG_INDIRECT_THUNK) += -mretpoline-external-thunk
> +
>  # If supported by the compiler, reduce stack alignment to 8 bytes. But allow
>  # this to be overridden elsewhere.
>  $(call cc-option-add,CFLAGS_stack_boundary,CC,-mpreferred-stack-boundary=3)




 


Rackspace

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