RE: [PATCH v4 13/36] x86/bugs: Restructure spectre_v2 mitigation

From: Kaplan, David
Date: Mon Apr 14 2025 - 15:25:36 EST


[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Sent: Thursday, April 10, 2025 12:09 PM
> To: Kaplan, David <David.Kaplan@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Borislav Petkov <bp@xxxxxxxxx>;
> Peter Zijlstra <peterz@xxxxxxxxxxxxx>; 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; Brendan Jackman
> <jackmanb@xxxxxxxxxx>; Derek Manwaring <derekmn@xxxxxxxxxx>
> Subject: Re: [PATCH v4 13/36] x86/bugs: Restructure spectre_v2 mitigation
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Mon, Mar 10, 2025 at 11:40:00AM -0500, David Kaplan wrote:
> > Restructure spectre_v2 to use select/update/apply functions to create
> > consistent vulnerability handling.
> >
> > The spectre_v2 mitigation may be updated based on the selected
> > retbleed mitigation.
> >
> > Signed-off-by: David Kaplan <david.kaplan@xxxxxxx>
> > ---
> > arch/x86/kernel/cpu/bugs.c | 79
> > +++++++++++++++++++++++---------------
> > 1 file changed, 48 insertions(+), 31 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> > index 96cb2ac70245..b4a72ddf159c 100644
> > --- a/arch/x86/kernel/cpu/bugs.c
> > +++ b/arch/x86/kernel/cpu/bugs.c
> > @@ -56,6 +56,8 @@
> > static void __init spectre_v1_select_mitigation(void);
> > static void __init spectre_v1_apply_mitigation(void);
> > static void __init spectre_v2_select_mitigation(void);
> > +static void __init spectre_v2_update_mitigation(void);
> > +static void __init spectre_v2_apply_mitigation(void);
> > static void __init retbleed_select_mitigation(void); static void
> > __init retbleed_update_mitigation(void); static void __init
> > retbleed_apply_mitigation(void); @@ -212,7 +214,12 @@ void __init
> > cpu_select_mitigations(void)
> > /*
> > * After mitigations are selected, some may need to update their
> > * choices.
> > + *
> > + * Note that retbleed_update_mitigation() relies on the state set by
> > + * spectre_v2_update_mitigation(); specifically it wants to know about
> > + * spectre_v2=ibrs.
> > */
> > + spectre_v2_update_mitigation();
> > retbleed_update_mitigation();
>
> I'd suggest moving that dependency comment to above
> retbleed_update_mitigaton() and making it more concise:
>
> /*
> * After mitigations are selected, some may need to update their
> * choices.
> */
> spectre_v2_update_mitigation();
> /* retbleed_update_mitigation() depends on spectre_v2_update_mitigation() */
> retbleed_update_mitigation();
>

Ack

--David Kaplan