[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250110184545.2c7a9976@pumpkin>
Date: Fri, 10 Jan 2025 18:45:45 +0000
From: David Laight <david.laight.linux@...il.com>
To: Pawan Gupta <pawan.kumar.gupta@...ux.intel.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 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 :-)
David
Powered by blists - more mailing lists