RE: [PATCH v5 04/16] x86/bugs: Restructure RFDS mitigation

Kaplan, David
2025-04-28T13:42:10Z

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Sunday, April 27, 2025 10:09 AM
> To: Kaplan, David <David.Kaplan@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>; Peter Zijlstra <peterz@infradead.org>;
> Josh Poimboeuf <jpoimboe@kernel.org>; Pawan Gupta
> <pawan.kumar.gupta@linux.intel.com>; 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 v5 04/16] x86/bugs: Restructure RFDS mitigation
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Fri, Apr 18, 2025 at 11:17:09AM -0500, David Kaplan wrote:
> > +static bool __init rfds_has_ucode(void) {
> > + return (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR); }
>
> Might as well call it what the bit means and then the code reads a bit better:
>
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index
> e668ccccd8c7..2705105d9a5e 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -630,7 +630,7 @@ static const char * const rfds_strings[] = {
> [RFDS_MITIGATION_UCODE_NEEDED] = "Vulnerable: No microcode",
> };
>
> -static bool __init rfds_has_ucode(void)
> +static inline bool __init verw_clears_cpu_reg_file(void)
> {
> return (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR); } @@ -648,7
> +648,7 @@ static void __init rfds_select_mitigation(void)
> if (rfds_mitigation == RFDS_MITIGATION_OFF)
> return;
>
> - if (rfds_has_ucode())
> + if (verw_clears_cpu_reg_file())
> verw_clear_cpu_buf_mitigation_selected = true; }
>
> @@ -661,7 +661,7 @@ static void __init rfds_update_mitigation(void)
> rfds_mitigation = RFDS_MITIGATION_VERW;
>
> if (rfds_mitigation == RFDS_MITIGATION_VERW) {
> - if (!rfds_has_ucode())
> + if (!verw_clears_cpu_reg_file())
> rfds_mitigation = RFDS_MITIGATION_UCODE_NEEDED;
> }
>
>

Makes sense to me, thanks.

--David Kaplan