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

Kaplan, David
2025-01-09T16:42:46Z

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> Sent: Thursday, January 9, 2025 10:41 AM
> To: Kaplan, David <David.Kaplan@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>; Borislav Petkov <bp@alien8.de>; Peter
> Zijlstra <peterz@infradead.org>; Josh Poimboeuf <jpoimboe@kernel.org>; Ingo
> Molnar <mingo@redhat.com>; Dave Hansen <dave.hansen@linux.intel.com>;
> x86@kernel.org; H . Peter Anvin <hpa@zytor.com>; linux-kernel@vger.kernel.org
> 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