Skip to content

Commit fe42754

Browse files
sean-jcbp3tk0v
authored andcommitted
cpu: Re-enable CPU mitigations by default for !X86 architectures
Rename x86's to CPU_MITIGATIONS, define it in generic code, and force it on for all architectures exception x86. A recent commit to turn mitigations off by default if SPECULATION_MITIGATIONS=n kinda sorta missed that "cpu_mitigations" is completely generic, whereas SPECULATION_MITIGATIONS is x86-specific. Rename x86's SPECULATIVE_MITIGATIONS instead of keeping both and have it select CPU_MITIGATIONS, as having two configs for the same thing is unnecessary and confusing. This will also allow x86 to use the knob to manage mitigations that aren't strictly related to speculative execution. Use another Kconfig to communicate to common code that CPU_MITIGATIONS is already defined instead of having x86's menu depend on the common CPU_MITIGATIONS. This allows keeping a single point of contact for all of x86's mitigations, and it's not clear that other architectures *want* to allow disabling mitigations at compile-time. Fixes: f337a6a ("x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n") Closes: https://lkml.kernel.org/r/20240413115324.53303a68%40canb.auug.org.au Reported-by: Stephen Rothwell <[email protected]> Reported-by: Michael Ellerman <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Acked-by: Borislav Petkov (AMD) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent a0a8d15 commit fe42754

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

arch/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
#
1010
source "arch/$(SRCARCH)/Kconfig"
1111

12+
config ARCH_CONFIGURES_CPU_MITIGATIONS
13+
bool
14+
15+
if !ARCH_CONFIGURES_CPU_MITIGATIONS
16+
config CPU_MITIGATIONS
17+
def_bool y
18+
endif
19+
1220
menu "General architecture-dependent options"
1321

1422
config ARCH_HAS_SUBPAGE_FAULTS

arch/x86/Kconfig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ config X86
6262
select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
6363
select ARCH_32BIT_OFF_T if X86_32
6464
select ARCH_CLOCKSOURCE_INIT
65+
select ARCH_CONFIGURES_CPU_MITIGATIONS
6566
select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
6667
select ARCH_ENABLE_HUGEPAGE_MIGRATION if X86_64 && HUGETLB_PAGE && MIGRATION
6768
select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64
@@ -2488,17 +2489,17 @@ config PREFIX_SYMBOLS
24882489
def_bool y
24892490
depends on CALL_PADDING && !CFI_CLANG
24902491

2491-
menuconfig SPECULATION_MITIGATIONS
2492-
bool "Mitigations for speculative execution vulnerabilities"
2492+
menuconfig CPU_MITIGATIONS
2493+
bool "Mitigations for CPU vulnerabilities"
24932494
default y
24942495
help
2495-
Say Y here to enable options which enable mitigations for
2496-
speculative execution hardware vulnerabilities.
2496+
Say Y here to enable options which enable mitigations for hardware
2497+
vulnerabilities (usually related to speculative execution).
24972498

24982499
If you say N, all mitigations will be disabled. You really
24992500
should know what you are doing to say so.
25002501

2501-
if SPECULATION_MITIGATIONS
2502+
if CPU_MITIGATIONS
25022503

25032504
config MITIGATION_PAGE_TABLE_ISOLATION
25042505
bool "Remove the kernel mapping in user mode"

kernel/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,8 +3207,8 @@ enum cpu_mitigations {
32073207
};
32083208

32093209
static enum cpu_mitigations cpu_mitigations __ro_after_init =
3210-
IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
3211-
CPU_MITIGATIONS_OFF;
3210+
IS_ENABLED(CONFIG_CPU_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
3211+
CPU_MITIGATIONS_OFF;
32123212

32133213
static int __init mitigations_parse_cmdline(char *arg)
32143214
{

0 commit comments

Comments
 (0)