Re: [PATCH 3/3] x86/bugs: Remove support for Spectre v2 LFENCE "retpolines"

From: Josh Poimboeuf
Date: Sat Apr 13 2024 - 00:21:45 EST


On Fri, Apr 12, 2024 at 11:10:34AM -0700, Josh Poimboeuf wrote:
> I found several bugs where code assumes that X86_FEATURE_RETPOLINE
> actually means retpolines (imagine that!). In fact that feature also
> includes the original AMD LFENCE "retpolines", which aren't in fact
> retpolines.
>
> Really, those "retpolines" should just be removed. They're already
> considered vulnerable due to the fact that the speculative window after
> the indirect branch can still be long enough to do multiple dependent
> loads. And recent tooling makes such gadgets easier to find.
>
> Also, EIBRS_LFENCE tests worse in real-world benchmarks than the actual
> BHI mitigations, so it's both slower and less secure.
>
> Specifically this removes support for the following cmdline options:
>
> - spectre_v2=retpoline,amd
> - spectre_v2=retpoline,lfence
> - spectre_v2=eibrs,lfence
>
> Now when any of those options are used, it will print an error and fall
> back to the defaults (spectre_v2=auto spectre_bhi=on).
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

Compile fix:

diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h
index e1c421282a78..3a1349c0f225 100644
--- a/arch/x86/include/asm/disabled-features.h
+++ b/arch/x86/include/asm/disabled-features.h
@@ -53,7 +53,7 @@
#ifdef CONFIG_MITIGATION_RETPOLINE
# define DISABLE_RETPOLINE 0
#else
-# define DISABLE_RETPOLINE (1 << (X86_FEATURE_RETPOLINE & 31)
+# define DISABLE_RETPOLINE (1 << (X86_FEATURE_RETPOLINE & 31))
#endif

#ifdef CONFIG_MITIGATION_RETHUNK