mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-02 18:17:50 -04:00
cpu: Ignore "mitigations" kernel parameter if CPU_MITIGATIONS=n
Explicitly disallow enabling mitigations at runtime for kernels that were built with CONFIG_CPU_MITIGATIONS=n, as some architectures may omit code entirely if mitigations are disabled at compile time. E.g. on x86, a large pile of Kconfigs are buried behind CPU_MITIGATIONS, and trying to provide sane behavior for retroactively enabling mitigations is extremely difficult, bordering on impossible. E.g. page table isolation and call depth tracking require build-time support, BHI mitigations will still be off without additional kernel parameters, etc. [ bp: Touchups. ] Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240420000556.2645001-3-seanjc@google.com
This commit is contained in:
committed by
Borislav Petkov (AMD)
parent
fe42754b94
commit
ce0abef6a1
14
kernel/cpu.c
14
kernel/cpu.c
@@ -3196,6 +3196,7 @@ void __init boot_cpu_hotplug_init(void)
|
||||
this_cpu_write(cpuhp_state.target, CPUHP_ONLINE);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CPU_MITIGATIONS
|
||||
/*
|
||||
* These are used for a global "mitigations=" cmdline option for toggling
|
||||
* optional CPU mitigations.
|
||||
@@ -3206,9 +3207,7 @@ enum cpu_mitigations {
|
||||
CPU_MITIGATIONS_AUTO_NOSMT,
|
||||
};
|
||||
|
||||
static enum cpu_mitigations cpu_mitigations __ro_after_init =
|
||||
IS_ENABLED(CONFIG_CPU_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
|
||||
CPU_MITIGATIONS_OFF;
|
||||
static enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO;
|
||||
|
||||
static int __init mitigations_parse_cmdline(char *arg)
|
||||
{
|
||||
@@ -3224,7 +3223,6 @@ static int __init mitigations_parse_cmdline(char *arg)
|
||||
|
||||
return 0;
|
||||
}
|
||||
early_param("mitigations", mitigations_parse_cmdline);
|
||||
|
||||
/* mitigations=off */
|
||||
bool cpu_mitigations_off(void)
|
||||
@@ -3239,3 +3237,11 @@ bool cpu_mitigations_auto_nosmt(void)
|
||||
return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpu_mitigations_auto_nosmt);
|
||||
#else
|
||||
static int __init mitigations_parse_cmdline(char *arg)
|
||||
{
|
||||
pr_crit("Kernel compiled without mitigations, ignoring 'mitigations'; system may still be vulnerable\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
early_param("mitigations", mitigations_parse_cmdline);
|
||||
|
||||
Reference in New Issue
Block a user