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

Re: [PATCH v2 06/70] x86: Introduce support for CET-IBT


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 15 Feb 2022 15:01:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; 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=HHsgt/pCVOD8X4+s5UZ1Dj1Y4nRKXR4uUA1dt6XbSfY=; b=cAp9uG1VLhkPFIxGm19hulH0XhAroKWNzn61zT/1h4YLM4Ok8n1iFn2uR/cGGYOJELIOATl7lZy/nWczx1sFImz0dtLSKVesl9tvIJWskpD1WhC5nApgoDNLR3MnOQLPxFkOza1c4WEu+8ZuqBPv1cVPibEP9Hwow1oMxatbmL4QeMiykFkAI3IVYf2/c6vqQHaiXJJVq0iuCcOO+e/gz6xK24a0qum/w6gC3MfQ7EWOPaJtIy2gVoozCgCVC3yqSCM7KMOO/VlK1crv2k8zw187v3gqcKW/D2A5aDWFFdt4DmHL6pMPP6rVHjzghZn13sFbL5fM3SQIGOZGvLeyTQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RY9jKxhT6nP1ubwZ9g9jjkWsOvLo8oLoj00ogOjXei7RHoCHC5dYmdpu4J/RkOrMmrzbYdiv2SFSdUZsLkRRlt/I3o3FtioAV/iXzFgR66eW0lT/xFr8j6kchjCxGTfKunJNPFLk6+yfvCXp01GLWKEgLHSJ+h5jrN6hqVWnyPcB8Kvjar43iAUQx92LRlYb6bJPcnwiVUMKplkvJ8fRKC60OO+aKBwdiaFgB4a70XBQz3L8U9djKLSaUxfp3EawOlBtOaRKUvLxIR9IdggMXBK/ncY/NquhbkCN90JzlYq1rKIIV9K0e6isq0WxayKXtX0V5Vq2xTa/8te1vp0ORw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 15 Feb 2022 14:02:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.02.2022 13:50, Andrew Cooper wrote:
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -39,6 +39,11 @@ config HAS_AS_CET_SS
>       # binutils >= 2.29 or LLVM >= 6
>       def_bool $(as-instr,wrssq %rax$(comma)0;setssbsy)
>  
> +config HAS_CC_CET_IBT
> +     # GCC >= 9 and binutils >= 2.29
> +     # Retpoline check to work around 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654
> +     def_bool $(cc-option,-fcf-protection=branch -mmanual-endbr 
> -mindirect-branch=thunk-extern) && $(as-instr,endbr64)

At the top of asm-defns.h we have a number of similarly operand-less
instructions expressed via .macro expanding to .byte. I don't see why
we couldn't do so here as well, eliminating the need for the
$(as-instr ...). In fact ...

> --- a/xen/arch/x86/include/asm/asm-defns.h
> +++ b/xen/arch/x86/include/asm/asm-defns.h
> @@ -57,6 +57,12 @@
>      INDIRECT_BRANCH jmp \arg
>  .endm
>  
> +#ifdef CONFIG_XEN_IBT
> +# define ENDBR64 endbr64
> +#else
> +# define ENDBR64
> +#endif

... it could also be this macro which ends up conditionally empty,
but would then want expressing as an assembler macro. Albeit no, the
lower case form would probably still be needed to deal with compiler
emitted insns, as the compiler doesn't appear to make recognition of
the command line option dependent on the underlying assembler's
capabilities.

> --- a/xen/arch/x86/include/asm/cpufeatures.h
> +++ b/xen/arch/x86/include/asm/cpufeatures.h
> @@ -39,6 +39,7 @@ XEN_CPUFEATURE(SC_VERW_PV,        X86_SYNTH(23)) /* VERW 
> used by Xen for PV */
>  XEN_CPUFEATURE(SC_VERW_HVM,       X86_SYNTH(24)) /* VERW used by Xen for HVM 
> */
>  XEN_CPUFEATURE(SC_VERW_IDLE,      X86_SYNTH(25)) /* VERW used by Xen for 
> idle */
>  XEN_CPUFEATURE(XEN_SHSTK,         X86_SYNTH(26)) /* Xen uses CET Shadow 
> Stacks */
> +XEN_CPUFEATURE(XEN_IBT,           X86_SYNTH(27)) /* Xen uses CET Indirect 
> Branch Tracking */

Is a feature flag actually warranted here, rather than a single
global boolean? You don't key any alternatives patching to this
bit, unlike was the case for XEN_SHSTK. And the only consumer is
cpu_has_xen_ibt, expanding to the boot CPU's instance of the bit.

Jan




 


Rackspace

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