Commit ed1dfe83 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Greg Kroah-Hartman

cpu/speculation: Add 'mitigations=' cmdline option

commit 98af8452945c55652de68536afdde3b520fec429 upstream

Keeping track of the number of mitigations for all the CPU speculation
bugs has become overwhelming for many users.  It's getting more and more
complicated to decide which mitigations are needed for a given
architecture.  Complicating matters is the fact that each arch tends to
have its own custom way to mitigate the same vulnerability.

Most users fall into a few basic categories:

a) they want all mitigations off;

b) they want all reasonable mitigations on, with SMT enabled even if
   it's vulnerable; or

c) they want all reasonable mitigations on, with SMT disabled if

Define a set of curated, arch-independent options, each of which is an
aggregation of existing options:

- mitigations=off: Disable all mitigations.

- mitigations=auto: [default] Enable all the default mitigations, but
  leave SMT enabled, even if it's vulnerable.

- mitigations=auto,nosmt: Enable all the default mitigations, disabling
  SMT if needed by a mitigation.

Currently, these options are placeholders which don't actually do
anything.  They will be fleshed out in upcoming patches.
Signed-off-by: default avatarJosh Poimboeuf <>
Signed-off-by: default avatarThomas Gleixner <>
Tested-by: Jiri Kosina <> (on x86)
Reviewed-by: default avatarJiri Kosina <>
Cc: Borislav Petkov <>
Cc: "H . Peter Anvin" <>
Cc: Andy Lutomirski <>
Cc: Peter Zijlstra <>
Cc: Jiri Kosina <>
Cc: Waiman Long <>
Cc: Andrea Arcangeli <>
Cc: Jon Masters <>
Cc: Benjamin Herrenschmidt <>
Cc: Paul Mackerras <>
Cc: Michael Ellerman <>
Cc: Martin Schwidefsky <>
Cc: Heiko Carstens <>
Cc: Catalin Marinas <>
Cc: Will Deacon <>
Cc: Greg Kroah-Hartman <>
Cc: Tyler Hicks <>
Cc: Linus Torvalds <>
Cc: Randy Dunlap <>
Cc: Steven Price <>
Cc: Phil Auld <>
Link: default avatarGreg Kroah-Hartman <>
parent b8615187
......@@ -2388,6 +2388,30 @@
in the "bleeding edge" mini2440 support kernel at
Control optional mitigations for CPU vulnerabilities.
This is a set of curated, arch-independent options, each
of which is an aggregation of existing arch-specific
Disable all optional CPU mitigations. This
improves system performance, but it may also
expose users to several CPU vulnerabilities.
auto (default)
Mitigate all CPU vulnerabilities, but leave SMT
enabled, even if it's vulnerable. This is for
users who don't want to be surprised by SMT
getting disabled across kernel upgrades, or who
have other ways of avoiding SMT-based attacks.
This is the default behavior.
Mitigate all CPU vulnerabilities, disabling SMT
if needed. This is for users who always want to
be fully mitigated, even if it means losing SMT.
parameter allows control of the logging verbosity for
......@@ -197,4 +197,28 @@ static inline void cpu_smt_disable(bool force) { }
static inline void cpu_smt_check_topology(void) { }
* These are used for a global "mitigations=" cmdline option for toggling
* optional CPU mitigations.
enum cpu_mitigations {
extern enum cpu_mitigations cpu_mitigations;
/* mitigations=off */
static inline bool cpu_mitigations_off(void)
return cpu_mitigations == CPU_MITIGATIONS_OFF;
/* mitigations=auto,nosmt */
static inline bool cpu_mitigations_auto_nosmt(void)
return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT;
#endif /* _LINUX_CPU_H_ */
......@@ -2297,3 +2297,18 @@ void __init boot_cpu_hotplug_init(void)
this_cpu_write(cpuhp_state.state, CPUHP_ONLINE);
enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO;
static int __init mitigations_parse_cmdline(char *arg)
if (!strcmp(arg, "off"))
cpu_mitigations = CPU_MITIGATIONS_OFF;
else if (!strcmp(arg, "auto"))
cpu_mitigations = CPU_MITIGATIONS_AUTO;
else if (!strcmp(arg, "auto,nosmt"))
return 0;
early_param("mitigations", mitigations_parse_cmdline);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment