[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250110203058.66cd7zlajfbpqf5k@desk>
Date: Fri, 10 Jan 2025 12:30:58 -0800
From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To: David Laight <david.laight.linux@...il.com>
Cc: David Kaplan <david.kaplan@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H . Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation
On Fri, Jan 10, 2025 at 06:45:45PM +0000, David Laight wrote:
> On Wed, 8 Jan 2025 21:22:37 -0800
> Pawan Gupta <pawan.kumar.gupta@...ux.intel.com> wrote:
>
> > On Wed, Jan 08, 2025 at 02:24:52PM -0600, David Kaplan wrote:
> > [...]
> > > @@ -1064,6 +1063,7 @@ enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE;
> > >
> > > enum retbleed_mitigation {
> > > RETBLEED_MITIGATION_NONE,
> > > + RETBLEED_MITIGATION_AUTO,
> >
> > This new enum ...
> >
> > > RETBLEED_MITIGATION_UNRET,
> > > RETBLEED_MITIGATION_IBPB,
> > > RETBLEED_MITIGATION_IBRS,
> > > @@ -1071,14 +1071,6 @@ enum retbleed_mitigation {
> > > RETBLEED_MITIGATION_STUFF,
> > > };
> ...
> > > static const char * const retbleed_strings[] = {
> > > [RETBLEED_MITIGATION_NONE] = "Vulnerable",
> > > [RETBLEED_MITIGATION_UNRET] = "Mitigation: untrained return thunk",
> >
> > ... does not have a corresponding entry in the strings array. AUTO is the
> > default, and it is possible that mitigation mode can stay AUTO throughout
> > the retbleed mitigation selection depending on cmdline and CONFIGs. e.g.
> > retbleed=stuff and spectre_v2=off.
>
> It is possible to use 'a bit of cpp magic' to put the definitions on one line.
> Something like:
> #define RETBLEED_MITIGATION(x) \
> x(NONE, "Vulnerable") \
> x(AUTO, "xxxx") \
> x(UNRET, "Mitigation: untrained return thunk") \
> ...
>
> #define X(NAME, msg) RETBLEED_MITIGATION_##NAME),
> enum retbleed_mitigation { RETBLEED_MITIGATION(X) };
> #undef X
>
> #define X(NAME, msg) [RETBLEED_MITIGATION_##NAME] = msg,
> static const char * const retbleed_strings[] = { RETBLEED_MITIGATION(X) };
> #undef X
>
> Then you can't lose message texts even when they are in a different file.
> The lower case name (for the strcmp() loop) can also be added.
>
> (and don't let the rust bindgen near it :-)
Wow, this is mind blowing!
Powered by blists - more mailing lists