All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/spec-ctrl: Disable retpolines with CET-IBT
@ 2022-02-28 22:51 Andrew Cooper
  2022-03-01  7:59 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2022-02-28 22:51 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich, Roger Pau Monné, Wei Liu

CET-IBT depend on executing indirect branches for protections to apply.
Extend the clobber for CET-SS to all of CET.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>

I can't decide if this wants a fixes tag or not.  If I'd remembered during the
CET series, it would have been its own patch.  Functionally, it depends on c/s
cdbe2b0a1aec which sets CR4.CET fairly early during boot.
---
 xen/arch/x86/spec_ctrl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 2d4cf5c7ef80..12bf1c5722f9 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -944,10 +944,11 @@ void __init init_speculation_mitigations(void)
                      boot_cpu_has(X86_FEATURE_IBRS));
 
     /*
-     * First, disable the use of retpolines if Xen is using shadow stacks, as
-     * they are incompatible.
+     * First, disable the use of retpolines if Xen is using CET.  Retpolines
+     * are a ROP gadget so incompatbile with Shadow Stacks, while IBT depends
+     * on executing indirect branches for the safety properties to apply.
      */
-    if ( cpu_has_xen_shstk &&
+    if ( (read_cr4() & X86_CR4_CET) &&
          (opt_thunk == THUNK_DEFAULT || opt_thunk == THUNK_RETPOLINE) )
         thunk = THUNK_JMP;
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/spec-ctrl: Disable retpolines with CET-IBT
  2022-02-28 22:51 [PATCH] x86/spec-ctrl: Disable retpolines with CET-IBT Andrew Cooper
@ 2022-03-01  7:59 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2022-03-01  7:59 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Roger Pau Monné, Wei Liu, Xen-devel

On 28.02.2022 23:51, Andrew Cooper wrote:
> CET-IBT depend on executing indirect branches for protections to apply.
> Extend the clobber for CET-SS to all of CET.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> I can't decide if this wants a fixes tag or not.  If I'd remembered during the
> CET series, it would have been its own patch.

On this basis I'd say no Fixes: tag.

> --- a/xen/arch/x86/spec_ctrl.c
> +++ b/xen/arch/x86/spec_ctrl.c
> @@ -944,10 +944,11 @@ void __init init_speculation_mitigations(void)
>                       boot_cpu_has(X86_FEATURE_IBRS));
>  
>      /*
> -     * First, disable the use of retpolines if Xen is using shadow stacks, as
> -     * they are incompatible.
> +     * First, disable the use of retpolines if Xen is using CET.  Retpolines
> +     * are a ROP gadget so incompatbile with Shadow Stacks, while IBT depends
> +     * on executing indirect branches for the safety properties to apply.
>       */
> -    if ( cpu_has_xen_shstk &&
> +    if ( (read_cr4() & X86_CR4_CET) &&
>           (opt_thunk == THUNK_DEFAULT || opt_thunk == THUNK_RETPOLINE) )
>          thunk = THUNK_JMP;

Just for my own understanding: Why unconditionally THUNK_JMP and not possibly
THUNK_LFENCE?

Jan



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 22:51 [PATCH] x86/spec-ctrl: Disable retpolines with CET-IBT Andrew Cooper
2022-03-01  7:59 ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.