RE: [PATCH] x86/bugs: Qualify RETBLEED_INTEL_MSG
From: Kaplan, David
Date: Fri Oct 10 2025 - 17:14:09 EST
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Sent: Friday, October 10, 2025 3:48 PM
> To: Kaplan, David <David.Kaplan@xxxxxxx>
> Cc: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>; Borislav Petkov
> <bp@xxxxxxxxx>; Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Peter Zijlstra
> <peterz@xxxxxxxxxxxxx>; Ingo Molnar <mingo@xxxxxxxxxx>; Dave Hansen
> <dave.hansen@xxxxxxxxxxxxxxx>; x86@xxxxxxxxxx; H . Peter Anvin
> <hpa@xxxxxxxxx>; Klaus Kusche <klaus.kusche@xxxxxxxxxxxxxxx>; linux-
> kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH] x86/bugs: Qualify RETBLEED_INTEL_MSG
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Fri, Oct 10, 2025 at 07:27:22PM +0000, Kaplan, David wrote:
> > > On Fri, Oct 10, 2025 at 11:47:25AM -0700, Pawan Gupta wrote:
> > > > > Instead, CONFIG_MITIGATION_SPECTRE_V2 could enable a submenu
> which
> > > then
> > > > > allows the user to enable retpoline, IBRS on entry, etc, with each
> > > > > having help text describing what generations of CPUs it would be the
> > > > > default for, to help guide the user to choose sane defaults depending on
> > > > > their CPU:
> > > > >
> > > > > * CONFIG_MITIGATION_SPECTRE_V2
> > > > > * CONFIG_MITIGATION_SPECTRE_V2_RETPOLINE
> > > > > select CONFIG_BUILD_INDIRECT_THUNKS
> > > > > * CONFIG_MITIGATION_SPECTRE_V2_IBRS
> > > > > select CONFIG_BUILD_IBRS_ENTRY
> > > >
> > > > That would be good if a kernel is built for certain specific CPU(s). This
> > > > may not be ideal for distro kernels.
> > >
> > > Why not? A distro can just enable everything:
> > >
> > > CONFIG_MITIGATION_SPECTRE_V2=y
> > > CONFIG_MITIGATION_SPECTRE_V2_RETPOLINE=y
> > > CONFIG_MITIGATION_SPECTRE_V2_IBRS=y
> > >
> > > and then if/when some older HW ages out of being supported by the
> > > distro, they can start disabling things.
> > >
> >
> > Is this really improving things?
> >
> > There's already a lot of CONFIG options related to mitigations that
> > make testing a pain, and this seems to just make it worse by now
> > having even more options that may or may not make sense together.
> >
> > I get the value in building a kernel with all mitigations disabled,
> > although frankly I think that only makes sense if it's substantially
> > better than just 'mitigations=off'. But is the cost of only building
> > support for IBRS and not retpoline really buying much?
>
> I think this would add several improvements.
>
> It makes it clearer *why* retpolines are enabled: to mitigate Spectre v2
> for older hardware. (Though, frustratingly, retpolines have made a
> comeback thanks to ITS.)
I don't think you mean 'enabled' here, you mean why they're being built into the kernel? If retpolines are being enabled at runtime, that is reported via sysfs.
>
> If I know I won't be running my kernel on old HW, this would make it
> easy to phase out old mitigations that are no longer needed, that
> otherwise uglify the code and might affect performance even when they're
> disabled at runtime.
To check if I'm understanding right, is the idea that if you have an ALTERNATIVE that is based on some feature flag (like X86_FEATURE_CLEAR_CPU_BUF) but your kernel is built without any support for those mitigations that need that then that macro would essentially get deleted at compile time so you don't have the extra NOPs? That seems useful.
And if you don't need any retpoline support then you remove retpolines from your compile options?
>
> That would be useful for me personally (I don't want that crap in my
> kernel if I don't need it), but also for distros which phase out support
> for older CPUs.
>
> Yes, it does add some config options, but we can counterbalance that by
> removing all the ones which set the defaults, and instead only allow
> changing defaults at the granularity of attack vectors.
I agree that would simplify things
>
> And these MITIGATION config options wouldn't need to be referenced by
> actual code. Their purpose would be to select
> CONFIG_BUILD_INDIRECT_THUNKS and friends, as needed, which are in a
> separate namespace (naming bikeshedding welcome). So overall I think
> there would be a lot less confusion about the purpose of each config
> option.
>
> (Yes, CONFIG_MITIGATION_* could also be used to compile out individual
> mitigations, but I'm not quite convinced that would be worth all the
> ifdeffery)
>
> That's kind of a lot, I can work up some patches to clarify what it all
> would look like.
>
Yeah sounds interesting.
Thanks
--David Kaplan