Re: [patch 05/24] x86/speculation: Disable STIBP when enhanced IBRS is in use

From: Thomas Gleixner
Date: Wed Nov 21 2018 - 15:36:57 EST


On Wed, 21 Nov 2018, Borislav Petkov wrote:
> On Wed, Nov 21, 2018 at 09:14:35PM +0100, Thomas Gleixner wrote:
> > From: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
> >
> > If enhanced IBRS is active, STIBP is redundant for mitigating Spectre v2
> > user space exploits from hyperthread sibling.
> >
> > Disable STIBP when enhanced IBRS is used.
> >
> > Signed-off-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
> > Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> >
> > ---
> > arch/x86/kernel/cpu/bugs.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > --- a/arch/x86/kernel/cpu/bugs.c
> > +++ b/arch/x86/kernel/cpu/bugs.c
> > @@ -321,6 +321,10 @@ static bool stibp_needed(void)
> > if (spectre_v2_enabled == SPECTRE_V2_NONE)
> > return false;
> >
> > + /* Enhanced IBRS makes using STIBP unnecessary. */
> > + if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
> > + return false;
> > +
> > if (!boot_cpu_has(X86_FEATURE_STIBP))
> > return false;
> >
> > @@ -846,6 +850,9 @@ static ssize_t l1tf_show_state(char *buf
> >
> > static char *stibp_state(void)
> > {
> > + if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
> > + return "";
>
> If
> spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED
>
> then SPEC_CTRL_STIBP should not be set in x86_spec_ctrl_base
> (stibp_needed() prevents the setting in arch_smt_update()) so the above
> check should not be needed.
>
> I *think*.

Yes, makes sense.

Thanks,

tglx