RE: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation
From: Kaplan, David
Date: Mon Feb 24 2025 - 11:00:36 EST
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Borislav Petkov <bp@xxxxxxxxx>
> Sent: Monday, February 24, 2025 9:45 AM
> To: Kaplan, David <David.Kaplan@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Peter Zijlstra <peterz@xxxxxxxxxxxxx>;
> Josh Poimboeuf <jpoimboe@xxxxxxxxxx>; Pawan Gupta
> <pawan.kumar.gupta@xxxxxxxxxxxxxxx>; Ingo Molnar <mingo@xxxxxxxxxx>; Dave
> Hansen <dave.hansen@xxxxxxxxxxxxxxx>; x86@xxxxxxxxxx; H . Peter Anvin
> <hpa@xxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Wed, Jan 08, 2025 at 02:24:52PM -0600, David Kaplan wrote:
> > +static void __init retbleed_update_mitigation(void) {
> > + if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
> > + return;
> >
> > - break;
> > + if (retbleed_mitigation == RETBLEED_MITIGATION_NONE)
> > + goto out;
> > + /*
> > + * Let IBRS trump all on Intel without affecting the effects of the
> > + * retbleed= cmdline option except for call depth based stuffing
> > + */
> > + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
> > + switch (spectre_v2_enabled) {
> > + case SPECTRE_V2_IBRS:
> > + retbleed_mitigation = RETBLEED_MITIGATION_IBRS;
> > + break;
> > + case SPECTRE_V2_EIBRS:
> > + case SPECTRE_V2_EIBRS_RETPOLINE:
> > + case SPECTRE_V2_EIBRS_LFENCE:
> > + retbleed_mitigation = RETBLEED_MITIGATION_EIBRS;
> > + break;
> > + default:
> > + if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
> > + pr_err(RETBLEED_INTEL_MSG);
> > + }
> > }
> >
> > + if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF) {
> > + if (spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
> > + pr_err("WARNING: retbleed=stuff depends on
> spectre_v2=retpoline\n");
> > + retbleed_mitigation = RETBLEED_MITIGATION_AUTO;
> > + /* Try again */
> > + retbleed_select_mitigation();
>
> Err, why?
>
> spectre_v2 and spectre_v2_enabled cannot change anymore - the select function
> has set them. Why try again here?
>
> This kinda defeats the whole purpose of having the select -> update -> apply
> rounds...
>
This code is gone from the latest version, I was able to simplify this and it only mattered for some corner cases related to Intel retbleed. Now the update function no longer has to re-call the select function.
--David Kaplan