[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<LV3PR12MB9265290D1539EE8FAECD1F9294B32@LV3PR12MB9265.namprd12.prod.outlook.com>
Date: Mon, 14 Apr 2025 19:20:17 +0000
From: "Kaplan, David" <David.Kaplan@....com>
To: Josh Poimboeuf <jpoimboe@...nel.org>
CC: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>, Pawan Gupta
<pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar <mingo@...hat.com>, Dave
Hansen <dave.hansen@...ux.intel.com>, "x86@...nel.org" <x86@...nel.org>, "H .
Peter Anvin" <hpa@...or.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, Brendan Jackman <jackmanb@...gle.com>, Derek
Manwaring <derekmn@...zon.com>
Subject: RE: [PATCH v4 11/36] x86/bugs: Restructure spectre_v2_user mitigation
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Josh Poimboeuf <jpoimboe@...nel.org>
> Sent: Thursday, April 10, 2025 11:26 AM
> To: Kaplan, David <David.Kaplan@....com>
> Cc: Thomas Gleixner <tglx@...utronix.de>; Borislav Petkov <bp@...en8.de>;
> Peter Zijlstra <peterz@...radead.org>; Pawan Gupta
> <pawan.kumar.gupta@...ux.intel.com>; Ingo Molnar <mingo@...hat.com>; Dave
> Hansen <dave.hansen@...ux.intel.com>; x86@...nel.org; H . Peter Anvin
> <hpa@...or.com>; linux-kernel@...r.kernel.org; Brendan Jackman
> <jackmanb@...gle.com>; Derek Manwaring <derekmn@...zon.com>
> Subject: Re: [PATCH v4 11/36] x86/bugs: Restructure spectre_v2_user mitigation
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Mon, Mar 10, 2025 at 11:39:58AM -0500, David Kaplan wrote:
> > static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation
> > mode) @@ -1446,10 +1436,10 @@ static inline bool
> spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode)
> > return spectre_v2_in_eibrs_mode(mode) || mode ==
> > SPECTRE_V2_IBRS; }
> >
> > +
>
> Extra newline here.
Ack
>
> > case SPECTRE_V2_USER_CMD_SECCOMP:
> > - case SPECTRE_V2_USER_CMD_SECCOMP_IBPB:
> > if (IS_ENABLED(CONFIG_SECCOMP))
> > - mode = SPECTRE_V2_USER_SECCOMP;
> > + spectre_v2_user_ibpb = SPECTRE_V2_USER_SECCOMP;
> > else
> > - mode = SPECTRE_V2_USER_PRCTL;
> > + spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
> > + spectre_v2_user_stibp = spectre_v2_user_ibpb;
> > + break;
> > + case SPECTRE_V2_USER_CMD_SECCOMP_IBPB:
> > + spectre_v2_user_ibpb = SPECTRE_V2_USER_STRICT;
> > + spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
> > break;
> > }
>
> For SPECTRE_V2_USER_CMD_SECCOMP_IBPB, shouldn't
> spectre_v2_user_stibp be SPECTRE_V2_USER_SECCOMP if
> CONFIG_SECCOMP?
Yes, you're right.
>
> Also I think spectre_v2_user_ibpb needs to be cleared here if
> X86_FEATURE_IBPB isn't set. And similar for spectre_v2_user_stibp and
> X86_FEATURE_STIBP.
Ack.
>
> > - /* Initialize Indirect Branch Prediction Barrier */
> > - if (boot_cpu_has(X86_FEATURE_IBPB)) {
> > - static_branch_enable(&switch_vcpu_ibpb);
> > + /*
> > + * At this point, an STIBP mode other than "off" has been set.
> > + * If STIBP support is not being forced, check if STIBP always-on
> > + * is preferred.
> > + */
> > + if (spectre_v2_user_stibp != SPECTRE_V2_USER_STRICT &&
> > + boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
> > + spectre_v2_user_stibp =
> > + SPECTRE_V2_USER_STRICT_PREFERRED;
>
> Instead of checking for !SPECTRE_V2_USER_STRICT it would probably be
> better to check for SPECTRE_V2_USER_PRCTL or
> SPECTRE_V2_USER_SECCOMP directly.
>
> Then the returns added to the SPECTRE_V2_USER_CMD_AUTO case in
> "x86/bugs: Add attack vector controls for spectre_v2_user" can be converted to
> breaks, which simplifies the control flow and also allows the above-suggested
> X86_FEATURE_IBPB/X86_FEATURE_STIBP checks to keep working.
>
Got it, yeah will do that.
Thanks --David Kaplan
Powered by blists - more mailing lists