Skip to content

Commit 53cf579

Browse files
Daniel Sneddonhansendc
authored andcommitted
x86/speculation: Add Kconfig option for GDS
Gather Data Sampling (GDS) is mitigated in microcode. However, on systems that haven't received the updated microcode, disabling AVX can act as a mitigation. Add a Kconfig option that uses the microcode mitigation if available and disables AVX otherwise. Setting this option has no effect on systems not affected by GDS. This is the equivalent of setting gather_data_sampling=force. Signed-off-by: Daniel Sneddon <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Josh Poimboeuf <[email protected]>
1 parent 553a5c0 commit 53cf579

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

arch/x86/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,25 @@ config SLS
26032603
against straight line speculation. The kernel image might be slightly
26042604
larger.
26052605

2606+
config GDS_FORCE_MITIGATION
2607+
bool "Force GDS Mitigation"
2608+
depends on CPU_SUP_INTEL
2609+
default n
2610+
help
2611+
Gather Data Sampling (GDS) is a hardware vulnerability which allows
2612+
unprivileged speculative access to data which was previously stored in
2613+
vector registers.
2614+
2615+
This option is equivalent to setting gather_data_sampling=force on the
2616+
command line. The microcode mitigation is used if present, otherwise
2617+
AVX is disabled as a mitigation. On affected systems that are missing
2618+
the microcode any userspace code that unconditionally uses AVX will
2619+
break with this option set.
2620+
2621+
Setting this option on systems not vulnerable to GDS has no effect.
2622+
2623+
If in doubt, say N.
2624+
26062625
endif
26072626

26082627
config ARCH_HAS_ADD_PAGES

arch/x86/kernel/cpu/bugs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,11 @@ enum gds_mitigations {
659659
GDS_MITIGATION_HYPERVISOR,
660660
};
661661

662+
#if IS_ENABLED(CONFIG_GDS_FORCE_MITIGATION)
663+
static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FORCE;
664+
#else
662665
static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FULL;
666+
#endif
663667

664668
static const char * const gds_strings[] = {
665669
[GDS_MITIGATION_OFF] = "Vulnerable",

0 commit comments

Comments
 (0)