x86/spec_store_bypass: Provide boot parameters to select Mitigation
Subsystems (3)
PATCH 6/7 x86/spec_store_bypass: Provide boot parameters to select Mitigation
Contemporary high performance processors use a common industry-wide optimization known as "Speculative Store Bypass" in which loads from addresses to which a recent store has occurred may (speculatively) see an older value. Intel refers to this feature as "Memory Disambiguation", which is part of their "Smart Memory Access" capability in Nehalem and later generation processors.
Some processors have an implementation bug that enables a cache side-channel attack against such speculatively read values. An attacker can create exploit code that allows them to read memory outside of a sandbox environment (for example, malicious JavaScript in a web page), or to perform more complex attacks against code running within the same privilege level, e.g. via the stack.
We provide two command line control knobs:
nospec_store_bypass_disable
spec_store_bypass_disable=[off,auto,on]
By default affected x86 processors will power on with Speculative Store Bypass (Memory Disambiguation) enabled. Hence the provided kernel parameters are written from the point of view of whether to enable a mitigation or not. The parameters are as follows:
- auto - if possible will disable Speculative Store Bypass (Memory Disambiguation) at boot if CPU is vulnerable to exploit
- on - disable Speculative Store Bypass (Memory Disambiguation)
- off - enable Speculative Store Bypass (Memory Disambiguation)
And as mentioned - some CPUs may have a Speculative Store Bypass implementation which is not vulnerable to the described attacks. For those, the 'auto' (default) option will pick the right choice.
---
v1.3:
- Wrong array was used when figuring mdd_v4= arguments
- If broken microcode found, also disable MD feature.
- s/mdd_v4/mdd/
- s/kernel/userpsace/
- Fix up the commit description
v1.4:
- Incorporate various feedback and suggestions from Jon Masters
- Change mdd parameters to allow only big hammer on/off for now
- Introduce "ssbd" industry standard term for cross-architecture
- Use mdd_ and MDD_ prefixes to clearly spell out that "enable" means we are actually disabling a CPU processor feature (MD)
v2:
- s/mdd/ssb/ in the x86 code to match with the 'ssb' part
v2.1:
- s/ssb/spec_store_bypass/ and various other cleanups (Jon Masters)
--- Documentation/admin-guide/kernel-parameters.txt | 32 ++++++++ arch/x86/include/asm/cpufeatures.h | 3 + arch/x86/include/asm/nospec-branch.h | 6 ++ arch/x86/kernel/cpu/bugs.c | 100 ++++++++++++++++++++++++ arch/x86/kernel/cpu/intel.c | 1 + 5 files changed, 142 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +32 -0
@@ -2680,6 +2680,9 @@ allow data leaks with this option, which is equivalent to spectre_v2=off. + nospec_store_disable + [HW] Disable all mitigations for the Speculative Store Bypass vulnerability + noxsave [BUGS=X86] Disables x86 extended register state save and restore using xsave. The kernel will fallback to enabling legacy floating-point and sse state.
@@ -4025,6 +4028,35 @@ Not specifying this option is equivalent to spectre_v2=auto. + spec_store_bypass_disable= + [HW] Control Speculative Store Bypass (SSB) Disable mitigation + (Speculative Store Bypass vulnerability) + Certain CPUs are vulnerable to an exploit against a + a common industry wide performance optimization known + as "Speculative Store Bypass" in which recent stores + to the same memory location may not be observed by + later loads during speculative execution. The idea + is that such stores are unlikely and that they can + be detected prior to instruction retirement at the + end of a particular speculation execution window. + + In vulnerable processors, the speculatively forwarded + store can be used in a cache side channel attack, for + example to read memory to which the attacker does not + directly have access (e.g. inside sandboxed code). + + This parameter controls whether the Speculative Store + Bypass optimization is used. + + on - unconditionally disable Speculative Store Bypass + off - unconditionally enable Speculative Store Bypass + auto - kernel detects whether your CPU model contains a + vulnerable implementation of Speculative Store + Bypass and picks the most appropriate mitigation + + Not specifying this option is equivalent to + spec_store_bypass_disable=auto. + spia_io_base= [HW,MTD] spia_fio_base= spia_pedr=
arch/x86/include/asm/cpufeatures.h +3 -0
@@ -215,6 +215,8 @@#define X86_FEATURE_USE_IBPB ( 7*32+21)/* "" Indirect Branch Prediction Barrier enabled */ #define X86_FEATURE_USE_IBRS_FW ( 7*32+22)/* "" Use IBRS during runtime firmware calls */ +#define X86_FEATURE_USE_MDD ( 7*32+23)/* "" Use MDD to disable Memory Disambiguation */ +/* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0)/* Intel TPR Shadow */ #define X86_FEATURE_VNMI ( 8*32+ 1)/* Intel Virtual NMI */
@@ -333,6 +335,7 @@#define X86_FEATURE_SPEC_CTRL (18*32+26)/* "" Speculation Control (IBRS + IBPB) */ #define X86_FEATURE_INTEL_STIBP (18*32+27)/* "" Single Thread Indirect Branch Predictors */ #define X86_FEATURE_ARCH_CAPABILITIES (18*32+29)/* IA32_ARCH_CAPABILITIES MSR (Intel) */ +#define X86_FEATURE_MDD (18*32+31)/* "" Memory Disambiguation Disable */ /* * BUG word(s)
arch/x86/include/asm/nospec-branch.h +6 -0
@@ -237,6 +237,12 @@ enum spectre_v2_mitigation {extern void x86_set_guest_spec_ctrl (u64 );extern void x86_restore_kernel_spec_ctrl (u64 ); +/* The Speculative Store Bypass disable variants */ +enum spec_store_bypass_mitigation { +SPEC_STORE_BYPASS_NONE , +SPEC_STORE_BYPASS_DISABLE , +}; +extern char __indirect_thunk_start[];extern char __indirect_thunk_end[];
arch/x86/kernel/cpu/bugs.c +100 -0
124 lines not on this page · raw message
arch/x86/kernel/cpu/intel.c +1 -0
@@ -189,6 +189,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)setup_clear_cpu_cap (X86_FEATURE_STIBP );setup_clear_cpu_cap (X86_FEATURE_SPEC_CTRL );setup_clear_cpu_cap (X86_FEATURE_INTEL_STIBP ); +setup_clear_cpu_cap (X86_FEATURE_MDD ); }/*
Signature · 1 line
1.8.3.1
Quoted 1 line · speck for jcm_at_redhat.com
+#define
X86_FEATURE_MDD(18*32+31) /* "" Memory Disambiguation Disable */
The official name now on Intel side is: Reduced Data speculation (RDS)
Tim
Quoted 5 lines · speck for Tim Chen
Quoted 1 line · speck for jcm_at_redhat.com
+#define
X86_FEATURE_MDD(18*32+31) /* "" Memory Disambiguation Disable */The official name now on Intel side is: Reduced Data speculation (RDS)
Thanks. And thanks for the update on the call. Aside from the name of this bit changing, I know of no changes to the actual MSR, correct?
Separate -Can you followup on the ask (and some others) have had for an ability to mask/protect the SPEC_CTRL MSR so that we can prevent guests from controlling all of the bits? Ideally it'd have been a full shadow (but that's not going to happen now), or things like MDD wouldn't be right next to IBRS and other things guests are going to whack :)
Jon.
Signature · 1 line
Computer Architect | Sent from my Fedora powered laptop
Quoted 5 lines · speck for Tim Chen
Quoted 1 line · speck for jcm_at_redhat.com
+#define
X86_FEATURE_MDD(18*32+31) /* "" Memory Disambiguation Disable */The official name now on Intel side is: Reduced Data speculation (RDS)
Also for the SPEC_CTRL MSR Bit(2)? Aka:
#define SPEC_CTRL_IBRS (1 << 0) /* Indirect Branch Restricted Speculation */
#define SPEC_CTRL_STIBP (1 << 1) /* Single Thread Indirect Branch Predictors */
+#define SPEC_CTRL_RDS (1 << 2) /* Reduced Data Speculation */
?
Quoted 2 lines
Tim