RE: [PATCH v2 2/5] x86/bugs: Use early_param for spectre_v2

From: Kaplan, David
Date: Fri Aug 22 2025 - 10:16:48 EST


[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Borislav Petkov <bp@xxxxxxxxx>
> Sent: Friday, August 22, 2025 6:49 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 v2 2/5] x86/bugs: Use early_param for spectre_v2
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Tue, Aug 19, 2025 at 02:21:57PM -0500, David Kaplan wrote:
> > +static void __init spectre_v2_check_cmd(void)
>
> Why the separate function?
>
> This can simply go in spectre_v2_select_mitigation() before the switch-case
> like with all the others *_select_mitigation() functions...

It could, but I felt this was a way to logically separate the code vs having one giant function. All the code in spectre_v2_check_cmd() does one thing: verifies if the chosen command is possible on this system. The rest of spectre_v2_select_mitigation() then uses the cmd to actually pick a mitigation.

Since these were two distinct flows, I thought having a separate function made sense to make the code more readable. But that was just my opinion, I won't object if you want to inline it.

--David Kaplan