Re: [PATCH] x86/bugs: Qualify RETBLEED_INTEL_MSG
From: Pawan Gupta
Date: Fri Oct 10 2025 - 14:47:44 EST
On Thu, Oct 09, 2025 at 06:10:42PM -0700, Josh Poimboeuf wrote:
> On Wed, Oct 08, 2025 at 10:33:36PM -0700, Pawan Gupta wrote:
> > On Tue, Oct 07, 2025 at 05:14:29PM -0700, Josh Poimboeuf wrote:
> > > On Tue, Oct 07, 2025 at 04:08:21PM -0700, Pawan Gupta wrote:
> > > MITIGATION_RETPOLINE -> X86_UGLY_INDIRECT_THUNKS
> > > MITIGATION_RETHUNK -> X86_UGLY_RETURN_THUNKS
> > >
> > > etc...
> > >
> > > Then one only needs to grep their .config file for UGLY to understand
> > > why their disassembly is so inscrutable ;-)
> >
> > :-) Agree, this is ugly. One way to handle this could be two levels of
> > Kconfig options like below:
> >
> > * CONFIG_MITIGATION_FOO - Compiles out the mitigation
>
> Maybe, though compiling out individual features would be complicated by
> the fact that we have dependencies between several of the mitigations,
> as evidenced by *_update_mitigation().
My thought was separate them out as:
- Generic mitigation like,
CONFIG_MITIGATION_CLEAR_CPU_BUFFERS
...
which are not directly user selectable.
- Vulnerability based mitigation like,
CONFIG_MITIGATION_MDS
CONFIG_MITIGATION_TAA
CONFIG_MITIGATION_MMIO
CONFIG_MITIGATION_TSA
...
which are user selectable, and does:
select CONFIG_MITIGATION_CLEAR_CPU_BUFFERS
When none from this category is selected,
CONFIG_MITIGATION_CLEAR_CPU_BUFFERS stays unset. All of VERW sites can
then use CONFIG_MITIGATION_CLEAR_CPU_BUFFERS to not generate NOPs/JMPs as
well.
> > * CONFIG_MITIGATION_FOO_DEFAULT - Sets the bootup default
>
> I'm wondering if we can just get rid of the compiled-in defaults. Do
> people really need that anymore, now that we have the attack vector
> controls? We could instead have
>
> CONFIG_CPU_MITIGATIONS_OFF
> CONFIG_CPU_MITIGATIONS_AUTO
> CONFIG_CPU_MITIGATIONS_AUTO_NOSMT
>
> CONFIG_CPU_MITIGATIONS_USER_USER
> CONFIG_CPU_MITIGATIONS_USER_KERNEL
> CONFIG_CPU_MITIGATIONS_GUEST_HOST
> CONFIG_CPU_MITIGATIONS_GUEST_GUEST
>
> ... which should cover the main cases. And of course there's always
> CONFIG_CMDLINE for more customization.
That works too.
> > select X86_UGLY_INDIRECT_THUNKS
>
> Unfortunately it's not always straightforward enough to say "mitigation
> FOO always needs X ugly feature".
>
> For example, newer CPUs mitigate Spectre v2 with enhanced IBRS, so they
> don't necessarily need all the retpoline and legacy IBRS stuff. So
> CONFIG_MITIGATION_SPECTRE_V2 shouldn't enable those unconditionally.
A more conservative approach can work here that selects a supporting
mitigation even though not all CPUs need it.
> 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.