RE: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation

From: Kaplan, David
Date: Thu Jan 09 2025 - 11:43:01 EST


[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
> Sent: Thursday, January 9, 2025 10:41 AM
> To: Kaplan, David <David.Kaplan@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Borislav Petkov <bp@xxxxxxxxx>; Peter
> Zijlstra <peterz@xxxxxxxxxxxxx>; Josh Poimboeuf <jpoimboe@xxxxxxxxxx>; 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 Thu, Jan 09, 2025 at 03:26:58PM +0000, Kaplan, David wrote:
> > The intent was never to allow AUTO to persist, it should always be
> > turned into a real mitigation. However it looks like I did miss a
> > case there, where if the mitigation is AUTO when
> > retbleed_select_mitigation() is called, the bug should be mitigated
> > but the vendor isn't AMD/Hygon, it wasn't being transformed.
> >
> > I'll figure out how to fix this to match the existing functionality,
> > thanks for pointing this out.
>
> Also, adding a guard to ensure AUTO never persists would be good.
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index
> 5bc2782f4ce1..ad63b5678250 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -1383,6 +1383,9 @@ static void __init retbleed_update_mitigation(void)
> }
> }
> out:
> + if (retbleed_mitigation == RETBLEED_MITIGATION_AUTO)
> + retbleed_mitigation = RETBLEED_MITIGATION_NONE;
> +
> pr_info("%s\n", retbleed_strings[retbleed_mitigation]);
> }

I had the same idea, I think to make this work I will let the mitigation stay as AUTO until the end of the update function where it will then be turned into NONE, at least for Intel.

For AMD, I can ensure it always is transformed in the select mitigation function.

Thanks --David Kaplan