* [PATCH v6 00/21] Attack vector controls (part 2)
@ 2025-07-07 18:32 David Kaplan
2025-07-07 18:32 ` [PATCH v6 01/21] Documentation/x86: Document new attack vector controls David Kaplan
` (21 more replies)
0 siblings, 22 replies; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:32 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
This is an updated version of the second half of the attack vector
series which adds new attack vector command line options designed to make
it easier to control which CPU mitigations are enabled.
The first half of this series focused on bugs.c restructuring and was
merged on May 2. Link:
https://lore.kernel.org/all/20250418161721.1855190-1-david.kaplan@amd.com/
Attack vector options are designed to make it easier to select appropriate
mitigations based on the usage of the system. While many users may not be
intimately familiar with the details of these CPU vulnerabilities, they are
likely better able to understand the intended usage of their system. As a
result, unneeded mitigations may be disabled, allowing users to recoup more
performance. New documentation is included with recommendations on what to
consider when choosing which attack vectors to enable/disable.
In this series, attack vector options are chosen using the mitigations=
command line. Attack vectors may be individually disabled such as
'mitigations=auto;no_user_kernel,no_user_user'. The 'mitigations=off'
option is equivalent to disabling all attack vectors. 'mitigations=off'
therefore disables all mitigations, unless bug-specific command line
options are used to re-enable some.
Note that this patch series does not change any of the existing
mitigation defaults.
Changes in v6:
- Added ITS attack vector support
- Removed new BHI user->kernel only mitigation (can be added later if
desired)
Changes in v5:
- Updated table layout in documentation file
- Minor clean up
David Kaplan (21):
Documentation/x86: Document new attack vector controls
cpu: Define attack vectors
x86/Kconfig: Add arch attack vector support
x86/bugs: Define attack vectors relevant for each bug
x86/bugs: Add attack vector controls for MDS
x86/bugs: Add attack vector controls for TAA
x86/bugs: Add attack vector controls for MMIO
x86/bugs: Add attack vector controls for RFDS
x86/bugs: Add attack vector controls for SRBDS
x86/bugs: Add attack vector controls for GDS
x86/bugs: Add attack vector controls for spectre_v1
x86/bugs: Add attack vector controls for retbleed
x86/bugs: Add attack vector controls for spectre_v2_user
x86/bugs: Add attack vector controls for BHI
x86/bugs: Add attack vector controls for spectre_v2
x86/bugs: Add attack vector controls for L1TF
x86/bugs: Add attack vector controls for SRSO
x86/bugs: Add attack vector controls for ITS
x86/pti: Add attack vector controls for PTI
x86/bugs: Print enabled attack vectors
cpu: Show attack vectors in sysfs
.../hw-vuln/attack_vector_controls.rst | 237 +++++++++++++++
Documentation/admin-guide/hw-vuln/index.rst | 1 +
.../admin-guide/kernel-parameters.txt | 4 +
arch/Kconfig | 3 +
arch/x86/Kconfig | 1 +
arch/x86/kernel/cpu/bugs.c | 269 ++++++++++++++----
arch/x86/mm/pti.c | 4 +-
drivers/base/cpu.c | 67 +++++
include/linux/cpu.h | 21 ++
kernel/cpu.c | 130 ++++++++-
10 files changed, 668 insertions(+), 69 deletions(-)
create mode 100644 Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
base-commit: f339770f60d9c3312133cfe6a349476848d9b128
--
2.34.1
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v6 01/21] Documentation/x86: Document new attack vector controls
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
@ 2025-07-07 18:32 ` David Kaplan
2025-07-09 15:57 ` [PATCH v7 01/22] " David Kaplan
2025-07-07 18:32 ` [PATCH v6 02/21] cpu: Define attack vectors David Kaplan
` (20 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:32 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Document the 5 new attack vector command line options, how they
interact with existing vulnerability controls, and recommendations on when
they can be disabled.
Note that while mitigating against untrusted userspace requires both
user-to-kernel and user-to-user protection, these are kept separate. The
kernel can control what code executes inside of it and that may affect the
risk associated with vulnerabilities especially if new kernel mitigations
are implemented. The same isn't typically true of userspace.
In other words, the risk associated with user-to-user or guest-to-guest
attacks is unlikely to change over time. While the risk associated with
user-to-kernel or guest-to-host attacks may change. Therefore, these
controls are separated.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
.../hw-vuln/attack_vector_controls.rst | 237 ++++++++++++++++++
Documentation/admin-guide/hw-vuln/index.rst | 1 +
.../admin-guide/kernel-parameters.txt | 4 +
3 files changed, 242 insertions(+)
create mode 100644 Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
diff --git a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
new file mode 100644
index 000000000000..b5e465e618f0
--- /dev/null
+++ b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
@@ -0,0 +1,237 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Attack Vector Controls
+======================
+
+Attack vector controls provide a simple method to configure only the mitigations
+for CPU vulnerabilities which are relevant given the intended use of a system.
+Administrators are encouraged to consider which attack vectors are relevant and
+disable all others in order to recoup system performance.
+
+When new relevant CPU vulnerabilities are found, they will be added to these
+attack vector controls so administrators will likely not need to reconfigure
+their command line parameters as mitigations will continue to be correctly
+applied based on the chosen attack vector controls.
+
+Attack Vectors
+--------------
+
+There are 5 sets of attack-vector mitigations currently supported by the kernel:
+
+#. :ref:`user_kernel`
+#. :ref:`user_user`
+#. :ref:`guest_host`
+#. :ref:`guest_guest`
+#. :ref:`smt`
+
+To control the enabled attack vectors, see :ref:`cmdline`.
+
+.. _user_kernel:
+
+User-to-Kernel
+^^^^^^^^^^^^^^
+
+The user-to-kernel attack vector involves a malicious userspace program
+attempting to leak kernel data into userspace by exploiting a CPU vulnerability.
+The kernel data involved might be limited to certain kernel memory, or include
+all memory in the system, depending on the vulnerability exploited.
+
+If no untrusted userspace applications are being run, such as with single-user
+systems, consider disabling user-to-kernel mitigations.
+
+Note that the CPU vulnerabilities mitigated by Linux have generally not been
+shown to be exploitable from browser-based sandboxes. User-to-kernel
+mitigations are therefore mostly relevant if unknown userspace applications may
+be run by untrusted users.
+
+*user-to-kernel mitigations are enabled by default*
+
+.. _user_user:
+
+User-to-User
+^^^^^^^^^^^^
+
+The user-to-user attack vector involves a malicious userspace program attempting
+to influence the behavior of another unsuspecting userspace program in order to
+exfiltrate data. The vulnerability of a userspace program is based on the
+program itself and the interfaces it provides.
+
+If no untrusted userspace applications are being run, consider disabling
+user-to-user mitigations.
+
+Note that because the Linux kernel contains a mapping of all physical memory,
+preventing a malicious userspace program from leaking data from another
+userspace program requires mitigating user-to-kernel attacks as well for
+complete protection.
+
+*user-to-user mitigations are enabled by default*
+
+.. _guest_host:
+
+Guest-to-Host
+^^^^^^^^^^^^^
+
+The guest-to-host attack vector involves a malicious VM attempting to leak
+hypervisor data into the VM. The data involved may be limited, or may
+potentially include all memory in the system, depending on the vulnerability
+exploited.
+
+If no untrusted VMs are being run, consider disabling guest-to-host mitigations.
+
+*guest-to-host mitigations are enabled by default if KVM support is present*
+
+.. _guest_guest:
+
+Guest-to-Guest
+^^^^^^^^^^^^^^
+
+The guest-to-guest attack vector involves a malicious VM attempting to influence
+the behavior of another unsuspecting VM in order to exfiltrate data. The
+vulnerability of a VM is based on the code inside the VM itself and the
+interfaces it provides.
+
+If no untrusted VMs, or only a single VM is being run, consider disabling
+guest-to-guest mitigations.
+
+Similar to the user-to-user attack vector, preventing a malicious VM from
+leaking data from another VM requires mitigating guest-to-host attacks as well
+due to the Linux kernel phys map.
+
+*guest-to-guest mitigations are enabled by default if KVM support is present*
+
+.. _smt:
+
+Cross-Thread
+^^^^^^^^^^^^
+
+The cross-thread attack vector involves a malicious userspace program or
+malicious VM either observing or attempting to influence the behavior of code
+running on the SMT sibling thread in order to exfiltrate data.
+
+Many cross-thread attacks can only be mitigated if SMT is disabled, which will
+result in reduced CPU core count and reduced performance.
+
+If cross-thread mitigations are fully enabled ('auto,nosmt'), all mitigations
+for cross-thread attacks will be enabled. SMT may be disabled depending on
+which vulnerabilities are present in the CPU.
+
+If cross-thread mitigations are partially enabled ('auto'), mitigations for
+cross-thread attacks will be enabled but SMT will not be disabled.
+
+If cross-thread mitigations are disabled, no mitigations for cross-thread
+attacks will be enabled.
+
+Cross-thread mitigation may not be required if core-scheduling or similar
+techniques are used to prevent untrusted workloads from running on SMT siblings.
+
+*cross-thread mitigations default to partially enabled*
+
+.. _cmdline:
+
+Command Line Controls
+---------------------
+
+Attack vectors are controlled through the mitigations= command line option. The
+value provided begins with a global option and then may optionally include one
+or more options to disable various attack vectors.
+
+Format:
+ | ``mitigations=[global]``
+ | ``mitigations=[global];[attack vectors]``
+
+Global options:
+
+============ =============================================================
+Option Description
+============ =============================================================
+'off' All attack vectors disabled.
+'auto' All attack vectors enabled, partial cross-thread mitigations.
+'auto,nosmt' All attack vectors enabled, full cross-thread mitigations.
+============ =============================================================
+
+Attack vector options:
+
+================= =======================================
+Option Description
+================= =======================================
+'no_user_kernel' Disables user-to-kernel mitigations.
+'no_user_user' Disables user-to-user mitigations.
+'no_guest_host' Disables guest-to-host mitigations.
+'no_guest_guest' Disables guest-to-guest mitigations
+'no_cross_thread' Disables all cross-thread mitigations.
+================= =======================================
+
+Multiple attack vector options may be specified in a comma-separated list. If
+the global option is not specified, it defaults to 'auto'. The global option
+'off' is equivalent to disabling all attack vectors.
+
+Examples:
+ | ``mitigations=auto;no_user_kernel``
+
+ Enable all attack vectors except user-to-kernel. Partial cross-thread
+ mitigations.
+
+ | ``mitigations=auto,nosmt;no_guest_host,no_guest_guest``
+
+ Enable all attack vectors and cross-thread mitigations except for
+ guest-to-host and guest-to-guest mitigations.
+
+ | ``mitigations=;no_cross_thread``
+
+ Enable all attack vectors but not cross-thread mitigations.
+
+Interactions with command-line options
+--------------------------------------
+
+Vulnerability-specific controls (e.g. "retbleed=off") take precedence over all
+attack vector controls. Mitigations for individual vulnerabilities may be
+turned on or off via their command-line options regardless of the attack vector
+controls.
+
+Summary of attack-vector mitigations
+------------------------------------
+
+When a vulnerability is mitigated due to an attack-vector control, the default
+mitigation option for that particular vulnerability is used. To use a different
+mitigation, please use the vulnerability-specific command line option.
+
+The table below summarizes which vulnerabilities are mitigated when different
+attack vectors are enabled and assuming the CPU is vulnerable.
+
+=============== ============== ============ ============= ============== ============ ========
+Vulnerability User-to-Kernel User-to-User Guest-to-Host Guest-to-Guest Cross-Thread Notes
+=============== ============== ============ ============= ============== ============ ========
+BHI X X
+ITS X X
+GDS X X X X * (Note 1)
+L1TF X X * (Note 2)
+MDS X X X X * (Note 2)
+MMIO X X X X * (Note 2)
+Meltdown X
+Retbleed X X * (Note 3)
+RFDS X X X X
+Spectre_v1 X
+Spectre_v2 X X
+Spectre_v2_user X X * (Note 1)
+SRBDS X X X X
+SRSO X X
+SSB (Note 4)
+TAA X X X X * (Note 2)
+=============== ============== ============ ============= ============== ============ ========
+
+Notes:
+ 1 -- Can be mitigated without disabling SMT.
+
+ 2 -- Disables SMT if cross-thread mitigations are fully enabled and the CPU
+ is vulnerable
+
+ 3 -- Disables SMT if cross-thread mitigations are fully enabled, the CPU is
+ vulnerable, and STIBP is not supported
+
+ 4 -- Speculative store bypass is always enabled by default (no kernel
+ mitigation applied) unless overridden with spec_store_bypass_disable option
+
+When an attack-vector is disabled, all mitigations for the vulnerabilities
+listed in the above table are disabled, unless mitigation is required for a
+different enabled attack-vector or a mitigation is explicitly selected via a
+vulnerability-specific command line option.
diff --git a/Documentation/admin-guide/hw-vuln/index.rst b/Documentation/admin-guide/hw-vuln/index.rst
index 09890a8f3ee9..89ca636081b7 100644
--- a/Documentation/admin-guide/hw-vuln/index.rst
+++ b/Documentation/admin-guide/hw-vuln/index.rst
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time.
.. toctree::
:maxdepth: 1
+ attack_vector_controls
spectre
l1tf
mds
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index f1f2c0874da9..c540e9eb721a 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3790,6 +3790,10 @@
mmio_stale_data=full,nosmt [X86]
retbleed=auto,nosmt [X86]
+ [X86] After one of the above options, additionally
+ supports attack-vector based controls as documented in
+ Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+
mminit_loglevel=
[KNL,EARLY] When CONFIG_DEBUG_MEMORY_INIT is set, this
parameter allows control of the logging verbosity for
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 02/21] cpu: Define attack vectors
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
2025-07-07 18:32 ` [PATCH v6 01/21] Documentation/x86: Document new attack vector controls David Kaplan
@ 2025-07-07 18:32 ` David Kaplan
2025-07-10 10:42 ` Borislav Petkov
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:32 ` [PATCH v6 03/21] x86/Kconfig: Add arch attack vector support David Kaplan
` (19 subsequent siblings)
21 siblings, 2 replies; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:32 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Define 4 new attack vectors that are used for controlling CPU speculation
mitigations. These may be individually disabled as part of the
mitigations= command line. Attack vector controls are combined with global
options like 'auto' or 'auto,nosmt' like 'mitigations=auto;no_user_kernel'.
Cross-thread mitigations can either remain enabled fully, including
potentially disabling SMT ('auto,nosmt'), remain enabled except for
disabling SMT ('auto'), or entirely disabled through the new
'no_cross_thread' attack vector option.
The default settings for these attack vectors are consistent with existing
kernel defaults, other than the automatic disabling of VM-based attack
vectors if KVM support is not present.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
include/linux/cpu.h | 21 +++++++
kernel/cpu.c | 130 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 140 insertions(+), 11 deletions(-)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 96a3a0d6a60e..29adac00c6e5 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -197,9 +197,25 @@ void cpuhp_report_idle_dead(void);
static inline void cpuhp_report_idle_dead(void) { }
#endif /* #ifdef CONFIG_HOTPLUG_CPU */
+enum cpu_attack_vectors {
+ CPU_MITIGATE_USER_KERNEL,
+ CPU_MITIGATE_USER_USER,
+ CPU_MITIGATE_GUEST_HOST,
+ CPU_MITIGATE_GUEST_GUEST,
+ NR_CPU_ATTACK_VECTORS,
+};
+
+enum smt_mitigations {
+ SMT_MITIGATIONS_OFF,
+ SMT_MITIGATIONS_AUTO,
+ SMT_MITIGATIONS_ON,
+};
+
#ifdef CONFIG_CPU_MITIGATIONS
extern bool cpu_mitigations_off(void);
extern bool cpu_mitigations_auto_nosmt(void);
+extern bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v);
+extern enum smt_mitigations smt_mitigations;
#else
static inline bool cpu_mitigations_off(void)
{
@@ -209,6 +225,11 @@ static inline bool cpu_mitigations_auto_nosmt(void)
{
return false;
}
+static inline bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
+{
+ return false;
+}
+#define smt_mitigations SMT_MITIGATIONS_OFF
#endif
#endif /* _LINUX_CPU_H_ */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a59e009e0be4..be25543567c0 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -37,6 +37,7 @@
#include <linux/cpuset.h>
#include <linux/random.h>
#include <linux/cc_platform.h>
+#include <linux/parser.h>
#include <trace/events/power.h>
#define CREATE_TRACE_POINTS
@@ -3174,8 +3175,38 @@ void __init boot_cpu_hotplug_init(void)
#ifdef CONFIG_CPU_MITIGATIONS
/*
- * These are used for a global "mitigations=" cmdline option for toggling
- * optional CPU mitigations.
+ * All except the cross-thread attack vector are mitigated by default.
+ * Cross-thread mitigation often requires disabling SMT which is expensive
+ * so cross-thread mitigations are only partially enabled by default.
+ *
+ * Guest-to-Host and Guest-to-Guest vectors are only needed if KVM support is
+ * present.
+ */
+static bool attack_vectors[NR_CPU_ATTACK_VECTORS] __ro_after_init = {
+ [CPU_MITIGATE_USER_KERNEL] = true,
+ [CPU_MITIGATE_USER_USER] = true,
+ [CPU_MITIGATE_GUEST_HOST] = IS_ENABLED(CONFIG_KVM),
+ [CPU_MITIGATE_GUEST_GUEST] = IS_ENABLED(CONFIG_KVM),
+};
+
+bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
+{
+ if (v < NR_CPU_ATTACK_VECTORS)
+ return attack_vectors[v];
+
+ WARN_ONCE(1, "Invalid attack vector %d\n", v);
+ return false;
+}
+
+/*
+ * There are 3 global options, 'off', 'auto', 'auto,nosmt'.
+ * These may optionally be combined with attack-vector disables after a ';'.
+ *
+ * Examples:
+ * mitigations=auto;no_user_kernel,no_user_user,no_cross_thread
+ * mitigations=auto,nosmt;no_guest_host,no_guest_guest
+ *
+ * mitigations=off is equivalent to disabling all attack vectors.
*/
enum cpu_mitigations {
CPU_MITIGATIONS_OFF,
@@ -3183,19 +3214,96 @@ enum cpu_mitigations {
CPU_MITIGATIONS_AUTO_NOSMT,
};
+enum {
+ NO_USER_KERNEL,
+ NO_USER_USER,
+ NO_GUEST_HOST,
+ NO_GUEST_GUEST,
+ NO_CROSS_THREAD,
+ NR_VECTOR_PARAMS,
+};
+
+enum smt_mitigations smt_mitigations __ro_after_init = SMT_MITIGATIONS_AUTO;
static enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO;
+static const match_table_t global_mitigations = {
+ { CPU_MITIGATIONS_AUTO_NOSMT, "auto,nosmt"},
+ { CPU_MITIGATIONS_AUTO, "auto"},
+ { CPU_MITIGATIONS_OFF, "off"},
+};
+
+static const match_table_t vector_mitigations = {
+ { NO_USER_KERNEL, "no_user_kernel"},
+ { NO_USER_USER, "no_user_user"},
+ { NO_GUEST_HOST, "no_guest_host"},
+ { NO_GUEST_GUEST, "no_guest_guest"},
+ { NO_CROSS_THREAD, "no_cross_thread"},
+ { NR_VECTOR_PARAMS, NULL},
+};
+
+static int __init mitigations_parse_global_opt(char *arg)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(global_mitigations); i++) {
+ const char *pattern = global_mitigations[i].pattern;
+
+ if (!strncmp(arg, pattern, strlen(pattern))) {
+ cpu_mitigations = global_mitigations[i].token;
+ return strlen(pattern);
+ }
+ }
+
+ return 0;
+}
+
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"))
- cpu_mitigations = CPU_MITIGATIONS_AUTO_NOSMT;
- else
- pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n",
- arg);
+ char *s, *p;
+ int len;
+
+ len = mitigations_parse_global_opt(arg);
+
+ if (cpu_mitigations_off()) {
+ memset(attack_vectors, 0, sizeof(attack_vectors));
+ smt_mitigations = SMT_MITIGATIONS_OFF;
+ } else if (cpu_mitigations_auto_nosmt()) {
+ smt_mitigations = SMT_MITIGATIONS_ON;
+ }
+
+ p = arg + len;
+
+ if (!*p)
+ return 0;
+
+ /* Attack vector controls may come after a ';' */
+ if (*p++ != ';' || !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
+ pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n", arg);
+ return 0;
+ }
+
+ while ((s = strsep(&p, ",")) != NULL) {
+ switch (match_token(s, vector_mitigations, NULL)) {
+ case NO_USER_KERNEL:
+ attack_vectors[CPU_MITIGATE_USER_KERNEL] = false;
+ break;
+ case NO_USER_USER:
+ attack_vectors[CPU_MITIGATE_USER_USER] = false;
+ break;
+ case NO_GUEST_HOST:
+ attack_vectors[CPU_MITIGATE_GUEST_HOST] = false;
+ break;
+ case NO_GUEST_GUEST:
+ attack_vectors[CPU_MITIGATE_GUEST_GUEST] = false;
+ break;
+ case NO_CROSS_THREAD:
+ smt_mitigations = SMT_MITIGATIONS_OFF;
+ break;
+ default:
+ pr_crit("Unsupported mitigations options %s\n", s);
+ return 0;
+ }
+ }
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 03/21] x86/Kconfig: Add arch attack vector support
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
2025-07-07 18:32 ` [PATCH v6 01/21] Documentation/x86: Document new attack vector controls David Kaplan
2025-07-07 18:32 ` [PATCH v6 02/21] cpu: Define attack vectors David Kaplan
@ 2025-07-07 18:32 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:32 ` [PATCH v6 04/21] x86/bugs: Define attack vectors relevant for each bug David Kaplan
` (18 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:32 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
ARCH_HAS_CPU_ATTACK_VECTORS should be set for architectures which implement
the new attack-vector based controls for CPU mitigations. If an arch does
not support attack-vector based controls then an attempt to use them
results in a warning.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/Kconfig | 3 +++
arch/x86/Kconfig | 1 +
2 files changed, 4 insertions(+)
diff --git a/arch/Kconfig b/arch/Kconfig
index 9233fbfd8dd3..79668e95c199 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1772,4 +1772,7 @@ config ARCH_WANTS_PRE_LINK_VMLINUX
An architecture can select this if it provides arch/<arch>/tools/Makefile
with .arch.vmlinux.o target to be linked into vmlinux.
+config ARCH_HAS_CPU_ATTACK_VECTORS
+ bool
+
endmenu
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 71019b3b54ea..49e30254d426 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -75,6 +75,7 @@ config X86
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
+ select ARCH_HAS_CPU_ATTACK_VECTORS if CPU_MITIGATIONS
select ARCH_HAS_CACHE_LINE_SIZE
select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
select ARCH_HAS_CPU_FINALIZE_INIT
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 04/21] x86/bugs: Define attack vectors relevant for each bug
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (2 preceding siblings ...)
2025-07-07 18:32 ` [PATCH v6 03/21] x86/Kconfig: Add arch attack vector support David Kaplan
@ 2025-07-07 18:32 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 05/21] x86/bugs: Add attack vector controls for MDS David Kaplan
` (17 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:32 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Add a function which defines which vulnerabilities should be mitigated
based on the selected attack vector controls. The selections here are
based on the individual characteristics of each vulnerability.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 56 ++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index e2a8a21efb10..1fa0704a8694 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -328,6 +328,62 @@ static void x86_amd_ssb_disable(void)
#undef pr_fmt
#define pr_fmt(fmt) "MDS: " fmt
+/*
+ * Returns true if vulnerability should be mitigated based on the
+ * selected attack vector controls.
+ *
+ * See Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+ */
+static bool __init should_mitigate_vuln(unsigned int bug)
+{
+ switch (bug) {
+ /*
+ * The only runtime-selected spectre_v1 mitigations in the kernel are
+ * related to SWAPGS protection on kernel entry. Therefore, protection
+ * is only required for the user->kernel attack vector.
+ */
+ case X86_BUG_SPECTRE_V1:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL);
+
+ case X86_BUG_SPECTRE_V2:
+ case X86_BUG_RETBLEED:
+ case X86_BUG_SRSO:
+ case X86_BUG_L1TF:
+ case X86_BUG_ITS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST);
+
+ case X86_BUG_SPECTRE_V2_USER:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST);
+
+ /*
+ * All the vulnerabilities below allow potentially leaking data
+ * across address spaces. Therefore, mitigation is required for
+ * any of these 4 attack vectors.
+ */
+ case X86_BUG_MDS:
+ case X86_BUG_TAA:
+ case X86_BUG_MMIO_STALE_DATA:
+ case X86_BUG_RFDS:
+ case X86_BUG_SRBDS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST);
+
+ case X86_BUG_GDS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST) ||
+ (smt_mitigations != SMT_MITIGATIONS_OFF);
+ default:
+ WARN(1, "Unknown bug %x\n", bug);
+ return false;
+ }
+}
+
/* Default mitigation for MDS-affected CPUs */
static enum mds_mitigations mds_mitigation __ro_after_init =
IS_ENABLED(CONFIG_MITIGATION_MDS) ? MDS_MITIGATION_AUTO : MDS_MITIGATION_OFF;
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 05/21] x86/bugs: Add attack vector controls for MDS
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (3 preceding siblings ...)
2025-07-07 18:32 ` [PATCH v6 04/21] x86/bugs: Define attack vectors relevant for each bug David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 06/21] x86/bugs: Add attack vector controls for TAA David Kaplan
` (16 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if MDS mitigation is required.
The global mitigations=off command now simply disables all attack vectors
so explicit checking of mitigations=off is no longer needed.
If cross-thread attack mitigations are required, disable SMT.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 1fa0704a8694..65d482aa450f 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -437,13 +437,17 @@ static bool verw_clear_cpu_buf_mitigation_selected __ro_after_init;
static void __init mds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_MDS)) {
mds_mitigation = MDS_MITIGATION_OFF;
return;
}
- if (mds_mitigation == MDS_MITIGATION_AUTO)
- mds_mitigation = MDS_MITIGATION_FULL;
+ if (mds_mitigation == MDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_MDS))
+ mds_mitigation = MDS_MITIGATION_FULL;
+ else
+ mds_mitigation = MDS_MITIGATION_OFF;
+ }
if (mds_mitigation == MDS_MITIGATION_OFF)
return;
@@ -453,7 +457,7 @@ static void __init mds_select_mitigation(void)
static void __init mds_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_MDS))
return;
/* If TAA, MMIO, or RFDS are being mitigated, MDS gets mitigated too. */
@@ -474,7 +478,7 @@ static void __init mds_apply_mitigation(void)
mds_mitigation == MDS_MITIGATION_VMWERV) {
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
if (!boot_cpu_has(X86_BUG_MSBDS_ONLY) &&
- (mds_nosmt || cpu_mitigations_auto_nosmt()))
+ (mds_nosmt || smt_mitigations == SMT_MITIGATIONS_ON))
cpu_smt_disable(false);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 06/21] x86/bugs: Add attack vector controls for TAA
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (4 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 05/21] x86/bugs: Add attack vector controls for MDS David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 07/21] x86/bugs: Add attack vector controls for MMIO David Kaplan
` (15 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if TAA mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 65d482aa450f..527ea049d4cd 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -534,12 +534,13 @@ static void __init taa_select_mitigation(void)
return;
}
- if (cpu_mitigations_off())
- taa_mitigation = TAA_MITIGATION_OFF;
-
/* Microcode will be checked in taa_update_mitigation(). */
- if (taa_mitigation == TAA_MITIGATION_AUTO)
- taa_mitigation = TAA_MITIGATION_VERW;
+ if (taa_mitigation == TAA_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_TAA))
+ taa_mitigation = TAA_MITIGATION_VERW;
+ else
+ taa_mitigation = TAA_MITIGATION_OFF;
+ }
if (taa_mitigation != TAA_MITIGATION_OFF)
verw_clear_cpu_buf_mitigation_selected = true;
@@ -547,7 +548,7 @@ static void __init taa_select_mitigation(void)
static void __init taa_update_mitigation(void)
{
- if (!taa_vulnerable() || cpu_mitigations_off())
+ if (!taa_vulnerable())
return;
if (verw_clear_cpu_buf_mitigation_selected)
@@ -588,7 +589,7 @@ static void __init taa_apply_mitigation(void)
*/
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
- if (taa_nosmt || cpu_mitigations_auto_nosmt())
+ if (taa_nosmt || smt_mitigations == SMT_MITIGATIONS_ON)
cpu_smt_disable(false);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 07/21] x86/bugs: Add attack vector controls for MMIO
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (5 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 06/21] x86/bugs: Add attack vector controls for TAA David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 08/21] x86/bugs: Add attack vector controls for RFDS David Kaplan
` (14 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vectors controls to determine if MMIO mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 527ea049d4cd..9f81a236735f 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -635,8 +635,12 @@ static void __init mmio_select_mitigation(void)
}
/* Microcode will be checked in mmio_update_mitigation(). */
- if (mmio_mitigation == MMIO_MITIGATION_AUTO)
- mmio_mitigation = MMIO_MITIGATION_VERW;
+ if (mmio_mitigation == MMIO_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_MMIO_STALE_DATA))
+ mmio_mitigation = MMIO_MITIGATION_VERW;
+ else
+ mmio_mitigation = MMIO_MITIGATION_OFF;
+ }
if (mmio_mitigation == MMIO_MITIGATION_OFF)
return;
@@ -651,7 +655,7 @@ static void __init mmio_select_mitigation(void)
static void __init mmio_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
return;
if (verw_clear_cpu_buf_mitigation_selected)
@@ -699,7 +703,7 @@ static void __init mmio_apply_mitigation(void)
if (!(x86_arch_cap_msr & ARCH_CAP_FBSDP_NO))
static_branch_enable(&mds_idle_clear);
- if (mmio_nosmt || cpu_mitigations_auto_nosmt())
+ if (mmio_nosmt || smt_mitigations == SMT_MITIGATIONS_ON)
cpu_smt_disable(false);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 08/21] x86/bugs: Add attack vector controls for RFDS
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (6 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 07/21] x86/bugs: Add attack vector controls for MMIO David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 09/21] x86/bugs: Add attack vector controls for SRBDS David Kaplan
` (13 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if RFDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 9f81a236735f..cf7d010931b9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -744,13 +744,17 @@ static inline bool __init verw_clears_cpu_reg_file(void)
static void __init rfds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RFDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_RFDS)) {
rfds_mitigation = RFDS_MITIGATION_OFF;
return;
}
- if (rfds_mitigation == RFDS_MITIGATION_AUTO)
- rfds_mitigation = RFDS_MITIGATION_VERW;
+ if (rfds_mitigation == RFDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_RFDS))
+ rfds_mitigation = RFDS_MITIGATION_VERW;
+ else
+ rfds_mitigation = RFDS_MITIGATION_OFF;
+ }
if (rfds_mitigation == RFDS_MITIGATION_OFF)
return;
@@ -761,7 +765,7 @@ static void __init rfds_select_mitigation(void)
static void __init rfds_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RFDS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_RFDS))
return;
if (verw_clear_cpu_buf_mitigation_selected)
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 09/21] x86/bugs: Add attack vector controls for SRBDS
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (7 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 08/21] x86/bugs: Add attack vector controls for RFDS David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 10/21] x86/bugs: Add attack vector controls for GDS David Kaplan
` (12 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if SRBDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index cf7d010931b9..e01fb83daa07 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -866,13 +866,19 @@ void update_srbds_msr(void)
static void __init srbds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SRBDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_SRBDS)) {
srbds_mitigation = SRBDS_MITIGATION_OFF;
return;
}
- if (srbds_mitigation == SRBDS_MITIGATION_AUTO)
- srbds_mitigation = SRBDS_MITIGATION_FULL;
+ if (srbds_mitigation == SRBDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_SRBDS))
+ srbds_mitigation = SRBDS_MITIGATION_FULL;
+ else {
+ srbds_mitigation = SRBDS_MITIGATION_OFF;
+ return;
+ }
+ }
/*
* Check to see if this is one of the MDS_NO systems supporting TSX that
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 10/21] x86/bugs: Add attack vector controls for GDS
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (8 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 09/21] x86/bugs: Add attack vector controls for SRBDS David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 11/21] x86/bugs: Add attack vector controls for spectre_v1 David Kaplan
` (11 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if GDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index e01fb83daa07..dc3f9a2e6984 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1026,12 +1026,15 @@ static void __init gds_select_mitigation(void)
return;
}
- if (cpu_mitigations_off())
- gds_mitigation = GDS_MITIGATION_OFF;
/* Will verify below that mitigation _can_ be disabled */
-
- if (gds_mitigation == GDS_MITIGATION_AUTO)
- gds_mitigation = GDS_MITIGATION_FULL;
+ if (gds_mitigation == GDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_GDS))
+ gds_mitigation = GDS_MITIGATION_FULL;
+ else {
+ gds_mitigation = GDS_MITIGATION_OFF;
+ return;
+ }
+ }
/* No microcode */
if (!(x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 11/21] x86/bugs: Add attack vector controls for spectre_v1
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (9 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 10/21] x86/bugs: Add attack vector controls for GDS David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 12/21] x86/bugs: Add attack vector controls for retbleed David Kaplan
` (10 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if spectre_v1 mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index dc3f9a2e6984..f4b3d879ba38 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1140,13 +1140,16 @@ static bool smap_works_speculatively(void)
static void __init spectre_v1_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
+ spectre_v1_mitigation = SPECTRE_V1_MITIGATION_NONE;
+
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V1))
spectre_v1_mitigation = SPECTRE_V1_MITIGATION_NONE;
}
static void __init spectre_v1_apply_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
return;
if (spectre_v1_mitigation == SPECTRE_V1_MITIGATION_AUTO) {
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 12/21] x86/bugs: Add attack vector controls for retbleed
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (10 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 11/21] x86/bugs: Add attack vector controls for spectre_v1 David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 13/21] x86/bugs: Add attack vector controls for spectre_v2_user David Kaplan
` (9 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if retbleed mitigation is
required.
Disable SMT if cross-thread protection is desired and STIBP is not
available.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index f4b3d879ba38..1e2dab9be7db 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1309,7 +1309,7 @@ early_param("retbleed", retbleed_parse_cmdline);
static void __init retbleed_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_RETBLEED)) {
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
return;
}
@@ -1346,6 +1346,11 @@ static void __init retbleed_select_mitigation(void)
if (retbleed_mitigation != RETBLEED_MITIGATION_AUTO)
return;
+ if (!should_mitigate_vuln(X86_BUG_RETBLEED)) {
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
+ return;
+ }
+
/* Intel mitigation selected in retbleed_update_mitigation() */
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
@@ -1369,7 +1374,7 @@ static void __init retbleed_select_mitigation(void)
static void __init retbleed_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_RETBLEED))
return;
/* ITS can also enable stuffing */
@@ -1464,7 +1469,7 @@ static void __init retbleed_apply_mitigation(void)
}
if (mitigate_smt && !boot_cpu_has(X86_FEATURE_STIBP) &&
- (retbleed_nosmt || cpu_mitigations_auto_nosmt()))
+ (retbleed_nosmt || smt_mitigations == SMT_MITIGATIONS_ON))
cpu_smt_disable(false);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 13/21] x86/bugs: Add attack vector controls for spectre_v2_user
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (11 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 12/21] x86/bugs: Add attack vector controls for retbleed David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 14/21] x86/bugs: Add attack vector controls for BHI David Kaplan
` (8 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if spectre_v2_user mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 1e2dab9be7db..f331cd70b0b4 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1725,7 +1725,7 @@ static enum spectre_v2_user_cmd __init spectre_v2_parse_user_cmdline(void)
char arg[20];
int ret, i;
- if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
+ if (!IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
return SPECTRE_V2_USER_CMD_NONE;
ret = cmdline_find_option(boot_command_line, "spectre_v2_user",
@@ -1763,6 +1763,13 @@ static void __init spectre_v2_user_select_mitigation(void)
spectre_v2_user_stibp = SPECTRE_V2_USER_STRICT;
break;
case SPECTRE_V2_USER_CMD_AUTO:
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2_USER))
+ break;
+ spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
+ if (smt_mitigations == SMT_MITIGATIONS_OFF)
+ break;
+ spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
+ break;
case SPECTRE_V2_USER_CMD_PRCTL:
spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 14/21] x86/bugs: Add attack vector controls for BHI
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (12 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 13/21] x86/bugs: Add attack vector controls for spectre_v2_user David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 15/21] x86/bugs: Add attack vector controls for spectre_v2 David Kaplan
` (7 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if BHI mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index f331cd70b0b4..adc563443c9d 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2125,11 +2125,20 @@ early_param("spectre_bhi", spectre_bhi_parse_cmdline);
static void __init bhi_select_mitigation(void)
{
- if (!boot_cpu_has(X86_BUG_BHI) || cpu_mitigations_off())
+ if (!boot_cpu_has(X86_BUG_BHI))
bhi_mitigation = BHI_MITIGATION_OFF;
- if (bhi_mitigation == BHI_MITIGATION_AUTO)
- bhi_mitigation = BHI_MITIGATION_ON;
+ if (bhi_mitigation != BHI_MITIGATION_AUTO)
+ return;
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST)) {
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
+ bhi_mitigation = BHI_MITIGATION_ON;
+ else
+ bhi_mitigation = BHI_MITIGATION_VMEXIT_ONLY;
+ } else {
+ bhi_mitigation = BHI_MITIGATION_OFF;
+ }
}
static void __init bhi_update_mitigation(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 15/21] x86/bugs: Add attack vector controls for spectre_v2
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (13 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 14/21] x86/bugs: Add attack vector controls for BHI David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 16/21] x86/bugs: Add attack vector controls for L1TF David Kaplan
` (6 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if spectre_v2 mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index adc563443c9d..2168e75bc1ac 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1921,8 +1921,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
int ret, i;
cmd = IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2) ? SPECTRE_V2_CMD_AUTO : SPECTRE_V2_CMD_NONE;
- if (cmdline_find_option_bool(boot_command_line, "nospectre_v2") ||
- cpu_mitigations_off())
+ if (cmdline_find_option_bool(boot_command_line, "nospectre_v2"))
return SPECTRE_V2_CMD_NONE;
ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
@@ -2194,8 +2193,11 @@ static void __init spectre_v2_select_mitigation(void)
case SPECTRE_V2_CMD_NONE:
return;
- case SPECTRE_V2_CMD_FORCE:
case SPECTRE_V2_CMD_AUTO:
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2))
+ break;
+ fallthrough;
+ case SPECTRE_V2_CMD_FORCE:
if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
spectre_v2_enabled = SPECTRE_V2_EIBRS;
break;
@@ -2249,7 +2251,7 @@ static void __init spectre_v2_update_mitigation(void)
}
}
- if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2) && !cpu_mitigations_off())
+ if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
pr_info("%s\n", spectre_v2_strings[spectre_v2_enabled]);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 16/21] x86/bugs: Add attack vector controls for L1TF
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (14 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 15/21] x86/bugs: Add attack vector controls for spectre_v2 David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 17/21] x86/bugs: Add attack vector controls for SRSO David Kaplan
` (5 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if L1TF mitigation is required.
Disable SMT if cross-thread protection is desired.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 2168e75bc1ac..ecfd7d728ac5 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2884,17 +2884,23 @@ static void override_cache_bits(struct cpuinfo_x86 *c)
static void __init l1tf_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_L1TF) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_L1TF)) {
l1tf_mitigation = L1TF_MITIGATION_OFF;
return;
}
- if (l1tf_mitigation == L1TF_MITIGATION_AUTO) {
- if (cpu_mitigations_auto_nosmt())
- l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
- else
- l1tf_mitigation = L1TF_MITIGATION_FLUSH;
+ if (l1tf_mitigation != L1TF_MITIGATION_AUTO)
+ return;
+
+ if (!should_mitigate_vuln(X86_BUG_L1TF)) {
+ l1tf_mitigation = L1TF_MITIGATION_OFF;
+ return;
}
+
+ if (smt_mitigations == SMT_MITIGATIONS_ON)
+ l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
+ else
+ l1tf_mitigation = L1TF_MITIGATION_FLUSH;
}
static void __init l1tf_apply_mitigation(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 17/21] x86/bugs: Add attack vector controls for SRSO
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (15 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 16/21] x86/bugs: Add attack vector controls for L1TF David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 18/21] x86/bugs: Add attack vector controls for ITS David Kaplan
` (4 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if SRSO mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index ecfd7d728ac5..c0e23e625b6f 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3012,14 +3012,19 @@ early_param("spec_rstack_overflow", srso_parse_cmdline);
static void __init srso_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SRSO)) {
srso_mitigation = SRSO_MITIGATION_NONE;
-
- if (srso_mitigation == SRSO_MITIGATION_NONE)
return;
+ }
- if (srso_mitigation == SRSO_MITIGATION_AUTO)
- srso_mitigation = SRSO_MITIGATION_SAFE_RET;
+ if (srso_mitigation == SRSO_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_SRSO)) {
+ srso_mitigation = SRSO_MITIGATION_SAFE_RET;
+ } else {
+ srso_mitigation = SRSO_MITIGATION_NONE;
+ return;
+ }
+ }
/* Zen1/2 with SMT off aren't vulnerable to SRSO. */
if (boot_cpu_data.x86 < 0x19 && !cpu_smt_possible()) {
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 18/21] x86/bugs: Add attack vector controls for ITS
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (16 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 17/21] x86/bugs: Add attack vector controls for SRSO David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 19/21] x86/pti: Add attack vector controls for PTI David Kaplan
` (3 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine if ITS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index c0e23e625b6f..7972c9b16e8a 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1514,13 +1514,17 @@ early_param("indirect_target_selection", its_parse_cmdline);
static void __init its_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_ITS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_ITS)) {
its_mitigation = ITS_MITIGATION_OFF;
return;
}
- if (its_mitigation == ITS_MITIGATION_AUTO)
- its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
+ if (its_mitigation == ITS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_ITS))
+ its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
+ else
+ its_mitigation = ITS_MITIGATION_OFF;
+ }
if (its_mitigation == ITS_MITIGATION_OFF)
return;
@@ -1551,12 +1555,13 @@ static void __init its_select_mitigation(void)
static void __init its_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_ITS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_ITS))
return;
switch (spectre_v2_enabled) {
case SPECTRE_V2_NONE:
- pr_err("WARNING: Spectre-v2 mitigation is off, disabling ITS\n");
+ if (its_mitigation != ITS_MITIGATION_OFF)
+ pr_err("WARNING: Spectre-v2 mitigation is off, disabling ITS\n");
its_mitigation = ITS_MITIGATION_OFF;
break;
case SPECTRE_V2_RETPOLINE:
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 19/21] x86/pti: Add attack vector controls for PTI
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (17 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 18/21] x86/bugs: Add attack vector controls for ITS David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 20/21] x86/bugs: Print enabled attack vectors David Kaplan
` (2 subsequent siblings)
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Disable PTI mitigation if user->kernel attack vector mitigations are
disabled.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/mm/pti.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index c0c40b67524e..b10d4d131dce 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -38,6 +38,7 @@
#include <asm/desc.h>
#include <asm/sections.h>
#include <asm/set_memory.h>
+#include <asm/bugs.h>
#undef pr_fmt
#define pr_fmt(fmt) "Kernel/User page tables isolation: " fmt
@@ -84,7 +85,8 @@ void __init pti_check_boottime_disable(void)
return;
}
- if (cpu_mitigations_off())
+ if (pti_mode == PTI_AUTO &&
+ !cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
pti_mode = PTI_FORCE_OFF;
if (pti_mode == PTI_FORCE_OFF) {
pti_print_if_insecure("disabled on command line.");
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 20/21] x86/bugs: Print enabled attack vectors
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (18 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 19/21] x86/pti: Add attack vector controls for PTI David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 21/21] cpu: Show attack vectors in sysfs David Kaplan
2025-07-09 15:58 ` [PATCH v7 19/22] x86/bugs: Add attack vector controls for TSA David Kaplan
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Print the status of enabled attack vectors and SMT mitigation status in the
boot log for easier reporting and debugging. This information will also be
available through sysfs.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 7972c9b16e8a..917acf99eb6a 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -187,6 +187,39 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
DEFINE_STATIC_KEY_FALSE(cpu_buf_vm_clear);
EXPORT_SYMBOL_GPL(cpu_buf_vm_clear);
+#undef pr_fmt
+#define pr_fmt(fmt) "mitigations: " fmt
+
+static void __init cpu_print_attack_vectors(void)
+{
+ pr_info("Enabled attack vectors: ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
+ pr_cont("user_kernel, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER))
+ pr_cont("user_user, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST))
+ pr_cont("guest_host, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST))
+ pr_cont("guest_guest, ");
+
+ pr_cont("SMT mitigations: ");
+
+ switch (smt_mitigations) {
+ case SMT_MITIGATIONS_OFF:
+ pr_cont("off\n");
+ break;
+ case SMT_MITIGATIONS_AUTO:
+ pr_cont("auto\n");
+ break;
+ case SMT_MITIGATIONS_ON:
+ pr_cont("on\n");
+ }
+}
+
void __init cpu_select_mitigations(void)
{
/*
@@ -207,6 +240,8 @@ void __init cpu_select_mitigations(void)
x86_arch_cap_msr = x86_read_arch_cap_msr();
+ cpu_print_attack_vectors();
+
/* Select the proper CPU mitigations before patching alternatives: */
spectre_v1_select_mitigation();
spectre_v2_select_mitigation();
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v6 21/21] cpu: Show attack vectors in sysfs
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (19 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 20/21] x86/bugs: Print enabled attack vectors David Kaplan
@ 2025-07-07 18:33 ` David Kaplan
2025-07-09 18:47 ` Borislav Petkov
2025-07-09 15:58 ` [PATCH v7 19/22] x86/bugs: Add attack vector controls for TSA David Kaplan
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-07 18:33 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Show the status of currently mitigated attack vectors in
/sys/devices/system/cpu/vector_mitigations/.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
drivers/base/cpu.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 7779ab0ca7ce..0b76213ea70e 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -20,6 +20,7 @@
#include <linux/tick.h>
#include <linux/pm_qos.h>
#include <linux/delay.h>
+#include <linux/string_choices.h>
#include <linux/sched/isolation.h>
#include "base.h"
@@ -647,6 +648,70 @@ static const struct attribute_group cpu_root_vulnerabilities_group = {
.attrs = cpu_root_vulnerabilities_attrs,
};
+static const char *attack_vector_state(enum cpu_attack_vectors v)
+{
+ return str_on_off(cpu_attack_vector_mitigated(v));
+}
+
+static ssize_t cpu_show_user_kernel_vector(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sysfs_emit(buf, "%s\n", attack_vector_state(CPU_MITIGATE_USER_KERNEL));
+}
+
+static ssize_t cpu_show_user_user_vector(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sysfs_emit(buf, "%s\n", attack_vector_state(CPU_MITIGATE_USER_USER));
+}
+
+static ssize_t cpu_show_guest_host_vector(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sysfs_emit(buf, "%s\n", attack_vector_state(CPU_MITIGATE_GUEST_HOST));
+}
+
+static ssize_t cpu_show_guest_guest_vector(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sysfs_emit(buf, "%s\n", attack_vector_state(CPU_MITIGATE_GUEST_GUEST));
+}
+
+static ssize_t cpu_show_smt_vector(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ switch (smt_mitigations) {
+ case SMT_MITIGATIONS_OFF:
+ return sysfs_emit(buf, "off\n");
+ case SMT_MITIGATIONS_ON:
+ return sysfs_emit(buf, "on\n");
+ case SMT_MITIGATIONS_AUTO:
+ return sysfs_emit(buf, "auto\n");
+ }
+
+ return 0;
+}
+
+static DEVICE_ATTR(user_kernel, 0444, cpu_show_user_kernel_vector, NULL);
+static DEVICE_ATTR(user_user, 0444, cpu_show_user_user_vector, NULL);
+static DEVICE_ATTR(guest_host, 0444, cpu_show_guest_host_vector, NULL);
+static DEVICE_ATTR(guest_guest, 0444, cpu_show_guest_guest_vector, NULL);
+static DEVICE_ATTR(smt, 0444, cpu_show_smt_vector, NULL);
+
+static struct attribute *cpu_vector_mitigations_attrs[] = {
+ &dev_attr_user_kernel.attr,
+ &dev_attr_user_user.attr,
+ &dev_attr_guest_host.attr,
+ &dev_attr_guest_guest.attr,
+ &dev_attr_smt.attr,
+ NULL
+};
+
+static const struct attribute_group cpu_vector_mitigations_group = {
+ .name = "vector_mitigations",
+ .attrs = cpu_vector_mitigations_attrs,
+};
+
static void __init cpu_register_vulnerabilities(void)
{
struct device *dev = bus_get_dev_root(&cpu_subsys);
@@ -654,6 +719,8 @@ static void __init cpu_register_vulnerabilities(void)
if (dev) {
if (sysfs_create_group(&dev->kobj, &cpu_root_vulnerabilities_group))
pr_err("Unable to register CPU vulnerabilities\n");
+ if (sysfs_create_group(&dev->kobj, &cpu_vector_mitigations_group))
+ pr_err("Unable to register CPU attack vectors\n");
put_device(dev);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v7 01/22] Documentation/x86: Document new attack vector controls
2025-07-07 18:32 ` [PATCH v6 01/21] Documentation/x86: Document new attack vector controls David Kaplan
@ 2025-07-09 15:57 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
0 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-09 15:57 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Document the 5 new attack vector command line options, how they
interact with existing vulnerability controls, and recommendations on when
they can be disabled.
Note that while mitigating against untrusted userspace requires both
user-to-kernel and user-to-user protection, these are kept separate. The
kernel can control what code executes inside of it and that may affect the
risk associated with vulnerabilities especially if new kernel mitigations
are implemented. The same isn't typically true of userspace.
In other words, the risk associated with user-to-user or guest-to-guest
attacks is unlikely to change over time. While the risk associated with
user-to-kernel or guest-to-host attacks may change. Therefore, these
controls are separated.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
.../hw-vuln/attack_vector_controls.rst | 238 ++++++++++++++++++
Documentation/admin-guide/hw-vuln/index.rst | 1 +
.../admin-guide/kernel-parameters.txt | 4 +
3 files changed, 243 insertions(+)
create mode 100644 Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
diff --git a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
new file mode 100644
index 000000000000..ee56e849616f
--- /dev/null
+++ b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
@@ -0,0 +1,238 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Attack Vector Controls
+======================
+
+Attack vector controls provide a simple method to configure only the mitigations
+for CPU vulnerabilities which are relevant given the intended use of a system.
+Administrators are encouraged to consider which attack vectors are relevant and
+disable all others in order to recoup system performance.
+
+When new relevant CPU vulnerabilities are found, they will be added to these
+attack vector controls so administrators will likely not need to reconfigure
+their command line parameters as mitigations will continue to be correctly
+applied based on the chosen attack vector controls.
+
+Attack Vectors
+--------------
+
+There are 5 sets of attack-vector mitigations currently supported by the kernel:
+
+#. :ref:`user_kernel`
+#. :ref:`user_user`
+#. :ref:`guest_host`
+#. :ref:`guest_guest`
+#. :ref:`smt`
+
+To control the enabled attack vectors, see :ref:`cmdline`.
+
+.. _user_kernel:
+
+User-to-Kernel
+^^^^^^^^^^^^^^
+
+The user-to-kernel attack vector involves a malicious userspace program
+attempting to leak kernel data into userspace by exploiting a CPU vulnerability.
+The kernel data involved might be limited to certain kernel memory, or include
+all memory in the system, depending on the vulnerability exploited.
+
+If no untrusted userspace applications are being run, such as with single-user
+systems, consider disabling user-to-kernel mitigations.
+
+Note that the CPU vulnerabilities mitigated by Linux have generally not been
+shown to be exploitable from browser-based sandboxes. User-to-kernel
+mitigations are therefore mostly relevant if unknown userspace applications may
+be run by untrusted users.
+
+*user-to-kernel mitigations are enabled by default*
+
+.. _user_user:
+
+User-to-User
+^^^^^^^^^^^^
+
+The user-to-user attack vector involves a malicious userspace program attempting
+to influence the behavior of another unsuspecting userspace program in order to
+exfiltrate data. The vulnerability of a userspace program is based on the
+program itself and the interfaces it provides.
+
+If no untrusted userspace applications are being run, consider disabling
+user-to-user mitigations.
+
+Note that because the Linux kernel contains a mapping of all physical memory,
+preventing a malicious userspace program from leaking data from another
+userspace program requires mitigating user-to-kernel attacks as well for
+complete protection.
+
+*user-to-user mitigations are enabled by default*
+
+.. _guest_host:
+
+Guest-to-Host
+^^^^^^^^^^^^^
+
+The guest-to-host attack vector involves a malicious VM attempting to leak
+hypervisor data into the VM. The data involved may be limited, or may
+potentially include all memory in the system, depending on the vulnerability
+exploited.
+
+If no untrusted VMs are being run, consider disabling guest-to-host mitigations.
+
+*guest-to-host mitigations are enabled by default if KVM support is present*
+
+.. _guest_guest:
+
+Guest-to-Guest
+^^^^^^^^^^^^^^
+
+The guest-to-guest attack vector involves a malicious VM attempting to influence
+the behavior of another unsuspecting VM in order to exfiltrate data. The
+vulnerability of a VM is based on the code inside the VM itself and the
+interfaces it provides.
+
+If no untrusted VMs, or only a single VM is being run, consider disabling
+guest-to-guest mitigations.
+
+Similar to the user-to-user attack vector, preventing a malicious VM from
+leaking data from another VM requires mitigating guest-to-host attacks as well
+due to the Linux kernel phys map.
+
+*guest-to-guest mitigations are enabled by default if KVM support is present*
+
+.. _smt:
+
+Cross-Thread
+^^^^^^^^^^^^
+
+The cross-thread attack vector involves a malicious userspace program or
+malicious VM either observing or attempting to influence the behavior of code
+running on the SMT sibling thread in order to exfiltrate data.
+
+Many cross-thread attacks can only be mitigated if SMT is disabled, which will
+result in reduced CPU core count and reduced performance.
+
+If cross-thread mitigations are fully enabled ('auto,nosmt'), all mitigations
+for cross-thread attacks will be enabled. SMT may be disabled depending on
+which vulnerabilities are present in the CPU.
+
+If cross-thread mitigations are partially enabled ('auto'), mitigations for
+cross-thread attacks will be enabled but SMT will not be disabled.
+
+If cross-thread mitigations are disabled, no mitigations for cross-thread
+attacks will be enabled.
+
+Cross-thread mitigation may not be required if core-scheduling or similar
+techniques are used to prevent untrusted workloads from running on SMT siblings.
+
+*cross-thread mitigations default to partially enabled*
+
+.. _cmdline:
+
+Command Line Controls
+---------------------
+
+Attack vectors are controlled through the mitigations= command line option. The
+value provided begins with a global option and then may optionally include one
+or more options to disable various attack vectors.
+
+Format:
+ | ``mitigations=[global]``
+ | ``mitigations=[global];[attack vectors]``
+
+Global options:
+
+============ =============================================================
+Option Description
+============ =============================================================
+'off' All attack vectors disabled.
+'auto' All attack vectors enabled, partial cross-thread mitigations.
+'auto,nosmt' All attack vectors enabled, full cross-thread mitigations.
+============ =============================================================
+
+Attack vector options:
+
+================= =======================================
+Option Description
+================= =======================================
+'no_user_kernel' Disables user-to-kernel mitigations.
+'no_user_user' Disables user-to-user mitigations.
+'no_guest_host' Disables guest-to-host mitigations.
+'no_guest_guest' Disables guest-to-guest mitigations
+'no_cross_thread' Disables all cross-thread mitigations.
+================= =======================================
+
+Multiple attack vector options may be specified in a comma-separated list. If
+the global option is not specified, it defaults to 'auto'. The global option
+'off' is equivalent to disabling all attack vectors.
+
+Examples:
+ | ``mitigations=auto;no_user_kernel``
+
+ Enable all attack vectors except user-to-kernel. Partial cross-thread
+ mitigations.
+
+ | ``mitigations=auto,nosmt;no_guest_host,no_guest_guest``
+
+ Enable all attack vectors and cross-thread mitigations except for
+ guest-to-host and guest-to-guest mitigations.
+
+ | ``mitigations=;no_cross_thread``
+
+ Enable all attack vectors but not cross-thread mitigations.
+
+Interactions with command-line options
+--------------------------------------
+
+Vulnerability-specific controls (e.g. "retbleed=off") take precedence over all
+attack vector controls. Mitigations for individual vulnerabilities may be
+turned on or off via their command-line options regardless of the attack vector
+controls.
+
+Summary of attack-vector mitigations
+------------------------------------
+
+When a vulnerability is mitigated due to an attack-vector control, the default
+mitigation option for that particular vulnerability is used. To use a different
+mitigation, please use the vulnerability-specific command line option.
+
+The table below summarizes which vulnerabilities are mitigated when different
+attack vectors are enabled and assuming the CPU is vulnerable.
+
+=============== ============== ============ ============= ============== ============ ========
+Vulnerability User-to-Kernel User-to-User Guest-to-Host Guest-to-Guest Cross-Thread Notes
+=============== ============== ============ ============= ============== ============ ========
+BHI X X
+ITS X X
+GDS X X X X * (Note 1)
+L1TF X X * (Note 2)
+MDS X X X X * (Note 2)
+MMIO X X X X * (Note 2)
+Meltdown X
+Retbleed X X * (Note 3)
+RFDS X X X X
+Spectre_v1 X
+Spectre_v2 X X
+Spectre_v2_user X X * (Note 1)
+SRBDS X X X X
+SRSO X X
+SSB (Note 4)
+TAA X X X X * (Note 2)
+TSA X X X X
+=============== ============== ============ ============= ============== ============ ========
+
+Notes:
+ 1 -- Can be mitigated without disabling SMT.
+
+ 2 -- Disables SMT if cross-thread mitigations are fully enabled and the CPU
+ is vulnerable
+
+ 3 -- Disables SMT if cross-thread mitigations are fully enabled, the CPU is
+ vulnerable, and STIBP is not supported
+
+ 4 -- Speculative store bypass is always enabled by default (no kernel
+ mitigation applied) unless overridden with spec_store_bypass_disable option
+
+When an attack-vector is disabled, all mitigations for the vulnerabilities
+listed in the above table are disabled, unless mitigation is required for a
+different enabled attack-vector or a mitigation is explicitly selected via a
+vulnerability-specific command line option.
diff --git a/Documentation/admin-guide/hw-vuln/index.rst b/Documentation/admin-guide/hw-vuln/index.rst
index 09890a8f3ee9..89ca636081b7 100644
--- a/Documentation/admin-guide/hw-vuln/index.rst
+++ b/Documentation/admin-guide/hw-vuln/index.rst
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time.
.. toctree::
:maxdepth: 1
+ attack_vector_controls
spectre
l1tf
mds
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 07e22ba5bfe3..baa1d6ad1dc8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3790,6 +3790,10 @@
mmio_stale_data=full,nosmt [X86]
retbleed=auto,nosmt [X86]
+ [X86] After one of the above options, additionally
+ supports attack-vector based controls as documented in
+ Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+
mminit_loglevel=
[KNL,EARLY] When CONFIG_DEBUG_MEMORY_INIT is set, this
parameter allows control of the logging verbosity for
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v7 19/22] x86/bugs: Add attack vector controls for TSA
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
` (20 preceding siblings ...)
2025-07-07 18:33 ` [PATCH v6 21/21] cpu: Show attack vectors in sysfs David Kaplan
@ 2025-07-09 15:58 ` David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
21 siblings, 1 reply; 50+ messages in thread
From: David Kaplan @ 2025-07-09 15:58 UTC (permalink / raw)
To: Thomas Gleixner, Borislav Petkov, Peter Zijlstra, Josh Poimboeuf,
Pawan Gupta, Ingo Molnar, Dave Hansen, x86, H . Peter Anvin
Cc: linux-kernel
Use attack vector controls to determine which TSA mitigation to use.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index f41d871f0622..e02b232fcc6e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1657,28 +1657,38 @@ early_param("tsa", tsa_parse_cmdline);
static void __init tsa_select_mitigation(void)
{
- if (cpu_mitigations_off() || !boot_cpu_has_bug(X86_BUG_TSA)) {
+ if (!boot_cpu_has_bug(X86_BUG_TSA)) {
tsa_mitigation = TSA_MITIGATION_NONE;
return;
}
+ if (tsa_mitigation == TSA_MITIGATION_AUTO) {
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER)) {
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST))
+ tsa_mitigation = TSA_MITIGATION_FULL;
+ else
+ tsa_mitigation = TSA_MITIGATION_USER_KERNEL;
+ } else if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST)) {
+ tsa_mitigation = TSA_MITIGATION_VM;
+ } else {
+ tsa_mitigation = TSA_MITIGATION_NONE;
+ }
+ }
+
if (tsa_mitigation == TSA_MITIGATION_NONE)
return;
- if (!boot_cpu_has(X86_FEATURE_VERW_CLEAR)) {
+ if (!boot_cpu_has(X86_FEATURE_VERW_CLEAR))
tsa_mitigation = TSA_MITIGATION_UCODE_NEEDED;
- goto out;
- }
-
- if (tsa_mitigation == TSA_MITIGATION_AUTO)
- tsa_mitigation = TSA_MITIGATION_FULL;
/*
* No need to set verw_clear_cpu_buf_mitigation_selected - it
* doesn't fit all cases here and it is not needed because this
* is the only VERW-based mitigation on AMD.
*/
-out:
pr_info("%s\n", tsa_strings[tsa_mitigation]);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH v6 21/21] cpu: Show attack vectors in sysfs
2025-07-07 18:33 ` [PATCH v6 21/21] cpu: Show attack vectors in sysfs David Kaplan
@ 2025-07-09 18:47 ` Borislav Petkov
0 siblings, 0 replies; 50+ messages in thread
From: Borislav Petkov @ 2025-07-09 18:47 UTC (permalink / raw)
To: David Kaplan
Cc: Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Ingo Molnar, Dave Hansen, x86, H . Peter Anvin, linux-kernel
On Mon, Jul 07, 2025 at 01:33:16PM -0500, David Kaplan wrote:
> Show the status of currently mitigated attack vectors in
> /sys/devices/system/cpu/vector_mitigations/.
Right, as discussed offlist, let's delay that one for now.
The question is: should this rather be inside
/sys/devices/system/cpu/vulnerabilities/, as it belongs there conceptually?
I wanted to have a subdir:
/sys/devices/system/cpu/vulnerabilities/vectors/
but that needs a bit more glue to create the struct device, etc. Not sure if
we need all that.
And the sysfs stuff needs documentation in Documentation/ABI/...
So, let's discuss this properly first as it is user-visible and then do it
when everyone agrees. It can go in later as it is only informational anyway.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v6 02/21] cpu: Define attack vectors
2025-07-07 18:32 ` [PATCH v6 02/21] cpu: Define attack vectors David Kaplan
@ 2025-07-10 10:42 ` Borislav Petkov
2025-07-10 14:02 ` Kaplan, David
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
1 sibling, 1 reply; 50+ messages in thread
From: Borislav Petkov @ 2025-07-10 10:42 UTC (permalink / raw)
To: David Kaplan
Cc: Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Ingo Molnar, Dave Hansen, x86, H . Peter Anvin, linux-kernel
On Mon, Jul 07, 2025 at 01:32:57PM -0500, David Kaplan wrote:
> + /* Attack vector controls may come after a ';' */
> + if (*p++ != ';' || !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
Right, so the ; separator causes problems with grub and its shell-like
grub.cfg file. If I put there:
... mitigations=auto;no_guest_host
it says
error: can't find command `no_guest_host'.
because it thinks it is a bash command.
We could do
... 'mitigations=auto;no_guest_host'
but that's non-intuitive and it'll cause problems left'n'right.
Using ':' as a separator instead seems to work so if people agree, I'd switch
to ':'...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 50+ messages in thread
* RE: [PATCH v6 02/21] cpu: Define attack vectors
2025-07-10 10:42 ` Borislav Petkov
@ 2025-07-10 14:02 ` Kaplan, David
2025-07-10 15:17 ` Borislav Petkov
0 siblings, 1 reply; 50+ messages in thread
From: Kaplan, David @ 2025-07-10 14:02 UTC (permalink / raw)
To: Borislav Petkov
Cc: Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Ingo Molnar, Dave Hansen, x86@kernel.org, H . Peter Anvin,
linux-kernel@vger.kernel.org
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Thursday, July 10, 2025 5:43 AM
> To: Kaplan, David <David.Kaplan@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>; Peter Zijlstra <peterz@infradead.org>;
> Josh Poimboeuf <jpoimboe@kernel.org>; Pawan Gupta
> <pawan.kumar.gupta@linux.intel.com>; Ingo Molnar <mingo@redhat.com>; Dave
> Hansen <dave.hansen@linux.intel.com>; x86@kernel.org; H . Peter Anvin
> <hpa@zytor.com>; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v6 02/21] cpu: Define attack vectors
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Mon, Jul 07, 2025 at 01:32:57PM -0500, David Kaplan wrote:
> > + /* Attack vector controls may come after a ';' */
> > + if (*p++ != ';' ||
> !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
>
> Right, so the ; separator causes problems with grub and its shell-like
> grub.cfg file. If I put there:
>
> ... mitigations=auto;no_guest_host
>
> it says
>
> error: can't find command `no_guest_host'.
>
> because it thinks it is a bash command.
>
> We could do
>
> ... 'mitigations=auto;no_guest_host'
>
> but that's non-intuitive and it'll cause problems left'n'right.
>
> Using ':' as a separator instead seems to work so if people agree, I'd switch
> to ':'...
>
Interesting. I would suggest a comma instead, so you have things like "mitigations=auto,no_user_kernel". That's somewhat consistent with the existing 'auto,nosmt' option as well.
Still you would have global options come first, and then the attack vector options. But since commas are already used to separate tokens, that seems cleaner to me.
If you're going to edit the patch directly, just please remember to update the documentation file accordingly too.
Thanks
--David Kaplan
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v6 02/21] cpu: Define attack vectors
2025-07-10 14:02 ` Kaplan, David
@ 2025-07-10 15:17 ` Borislav Petkov
2025-07-10 15:22 ` Kaplan, David
0 siblings, 1 reply; 50+ messages in thread
From: Borislav Petkov @ 2025-07-10 15:17 UTC (permalink / raw)
To: Kaplan, David
Cc: Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Ingo Molnar, Dave Hansen, x86@kernel.org, H . Peter Anvin,
linux-kernel@vger.kernel.org
On Thu, Jul 10, 2025 at 02:02:56PM +0000, Kaplan, David wrote:
> Interesting. I would suggest a comma instead, so you have things like
> "mitigations=auto,no_user_kernel". That's somewhat consistent with the
> existing 'auto,nosmt' option as well.
Ack, see below.
> Still you would have global options come first, and then the attack vector
> options. But since commas are already used to separate tokens, that seems
> cleaner to me.
>
> If you're going to edit the patch directly, just please remember to update
> the documentation file accordingly too.
Yeah, and the commit messages.
This is just the patche(es), I'll go over the commit messages too.
---
diff --git a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
index ee56e849616f..b4de16f5ec44 100644
--- a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+++ b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
@@ -137,7 +137,7 @@ or more options to disable various attack vectors.
Format:
| ``mitigations=[global]``
- | ``mitigations=[global];[attack vectors]``
+ | ``mitigations=[global],[attack vectors]``
Global options:
@@ -166,17 +166,17 @@ the global option is not specified, it defaults to 'auto'. The global option
'off' is equivalent to disabling all attack vectors.
Examples:
- | ``mitigations=auto;no_user_kernel``
+ | ``mitigations=auto,no_user_kernel``
Enable all attack vectors except user-to-kernel. Partial cross-thread
mitigations.
- | ``mitigations=auto,nosmt;no_guest_host,no_guest_guest``
+ | ``mitigations=auto,nosmt,no_guest_host,no_guest_guest``
Enable all attack vectors and cross-thread mitigations except for
guest-to-host and guest-to-guest mitigations.
- | ``mitigations=;no_cross_thread``
+ | ``mitigations=,no_cross_thread``
Enable all attack vectors but not cross-thread mitigations.
diff --git a/kernel/cpu.c b/kernel/cpu.c
index be25543567c0..c976a6686d8b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3276,8 +3276,8 @@ static int __init mitigations_parse_cmdline(char *arg)
if (!*p)
return 0;
- /* Attack vector controls may come after a ';' */
- if (*p++ != ';' || !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
+ /* Attack vector controls may come after the ',' */
+ if (*p++ != ',' || !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n", arg);
return 0;
}
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply related [flat|nested] 50+ messages in thread
* RE: [PATCH v6 02/21] cpu: Define attack vectors
2025-07-10 15:17 ` Borislav Petkov
@ 2025-07-10 15:22 ` Kaplan, David
0 siblings, 0 replies; 50+ messages in thread
From: Kaplan, David @ 2025-07-10 15:22 UTC (permalink / raw)
To: Borislav Petkov
Cc: Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Ingo Molnar, Dave Hansen, x86@kernel.org, H . Peter Anvin,
linux-kernel@vger.kernel.org
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Thursday, July 10, 2025 10:17 AM
> To: Kaplan, David <David.Kaplan@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>; Peter Zijlstra <peterz@infradead.org>;
> Josh Poimboeuf <jpoimboe@kernel.org>; Pawan Gupta
> <pawan.kumar.gupta@linux.intel.com>; Ingo Molnar <mingo@redhat.com>; Dave
> Hansen <dave.hansen@linux.intel.com>; x86@kernel.org; H . Peter Anvin
> <hpa@zytor.com>; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v6 02/21] cpu: Define attack vectors
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Thu, Jul 10, 2025 at 02:02:56PM +0000, Kaplan, David wrote:
> > Interesting. I would suggest a comma instead, so you have things like
> > "mitigations=auto,no_user_kernel". That's somewhat consistent with the
> > existing 'auto,nosmt' option as well.
>
> Ack, see below.
>
> > Still you would have global options come first, and then the attack vector
> > options. But since commas are already used to separate tokens, that seems
> > cleaner to me.
> >
> > If you're going to edit the patch directly, just please remember to update
> > the documentation file accordingly too.
>
> Yeah, and the commit messages.
>
> This is just the patche(es), I'll go over the commit messages too.
>
> ---
>
> diff --git a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
> b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
> index ee56e849616f..b4de16f5ec44 100644
> --- a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
> +++ b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
> @@ -137,7 +137,7 @@ or more options to disable various attack vectors.
>
> Format:
> | ``mitigations=[global]``
> - | ``mitigations=[global];[attack vectors]``
> + | ``mitigations=[global],[attack vectors]``
>
> Global options:
>
> @@ -166,17 +166,17 @@ the global option is not specified, it defaults to 'auto'.
> The global option
> 'off' is equivalent to disabling all attack vectors.
>
> Examples:
> - | ``mitigations=auto;no_user_kernel``
> + | ``mitigations=auto,no_user_kernel``
>
> Enable all attack vectors except user-to-kernel. Partial cross-thread
> mitigations.
>
> - | ``mitigations=auto,nosmt;no_guest_host,no_guest_guest``
> + | ``mitigations=auto,nosmt,no_guest_host,no_guest_guest``
>
> Enable all attack vectors and cross-thread mitigations except for
> guest-to-host and guest-to-guest mitigations.
>
> - | ``mitigations=;no_cross_thread``
> + | ``mitigations=,no_cross_thread``
>
> Enable all attack vectors but not cross-thread mitigations.
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index be25543567c0..c976a6686d8b 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -3276,8 +3276,8 @@ static int __init mitigations_parse_cmdline(char *arg)
> if (!*p)
> return 0;
>
> - /* Attack vector controls may come after a ';' */
> - if (*p++ != ';' ||
> !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
> + /* Attack vector controls may come after the ',' */
> + if (*p++ != ',' ||
> !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
> pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n",
> arg);
> return 0;
> }
>
Yeah that looks good to me. I did testing on this locally and it seemed to work fine.
Thanks
--David Kaplan
^ permalink raw reply [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Print enabled attack vectors
2025-07-07 18:33 ` [PATCH v6 20/21] x86/bugs: Print enabled attack vectors David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: a026dc61cffd98541e048f3c88d3280bcd105bd4
Gitweb: https://git.kernel.org/tip/a026dc61cffd98541e048f3c88d3280bcd105bd4
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:15 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Print enabled attack vectors
Print the status of enabled attack vectors and SMT mitigation status in the
boot log for easier reporting and debugging. This information will also be
available through sysfs.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-21-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b9d0509..b74bf93 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -189,6 +189,39 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
DEFINE_STATIC_KEY_FALSE(cpu_buf_vm_clear);
EXPORT_SYMBOL_GPL(cpu_buf_vm_clear);
+#undef pr_fmt
+#define pr_fmt(fmt) "mitigations: " fmt
+
+static void __init cpu_print_attack_vectors(void)
+{
+ pr_info("Enabled attack vectors: ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
+ pr_cont("user_kernel, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER))
+ pr_cont("user_user, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST))
+ pr_cont("guest_host, ");
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST))
+ pr_cont("guest_guest, ");
+
+ pr_cont("SMT mitigations: ");
+
+ switch (smt_mitigations) {
+ case SMT_MITIGATIONS_OFF:
+ pr_cont("off\n");
+ break;
+ case SMT_MITIGATIONS_AUTO:
+ pr_cont("auto\n");
+ break;
+ case SMT_MITIGATIONS_ON:
+ pr_cont("on\n");
+ }
+}
+
void __init cpu_select_mitigations(void)
{
/*
@@ -209,6 +242,8 @@ void __init cpu_select_mitigations(void)
x86_arch_cap_msr = x86_read_arch_cap_msr();
+ cpu_print_attack_vectors();
+
/* Select the proper CPU mitigations before patching alternatives: */
spectre_v1_select_mitigation();
spectre_v2_select_mitigation();
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for TSA
2025-07-09 15:58 ` [PATCH v7 19/22] x86/bugs: Add attack vector controls for TSA David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 6b21d2f0dc73699e468c877515472c52a5837f8f
Gitweb: https://git.kernel.org/tip/6b21d2f0dc73699e468c877515472c52a5837f8f
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Wed, 09 Jul 2025 10:58:44 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for TSA
Use attack vector controls to determine which TSA mitigation to use.
[ bp: Simplify the condition in the select function for better
readability. ]
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250709155844.3279471-1-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index f41d871..b9d0509 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1657,28 +1657,43 @@ early_param("tsa", tsa_parse_cmdline);
static void __init tsa_select_mitigation(void)
{
- if (cpu_mitigations_off() || !boot_cpu_has_bug(X86_BUG_TSA)) {
+ if (!boot_cpu_has_bug(X86_BUG_TSA)) {
tsa_mitigation = TSA_MITIGATION_NONE;
return;
}
+ if (tsa_mitigation == TSA_MITIGATION_AUTO) {
+ bool vm = false, uk = false;
+
+ tsa_mitigation = TSA_MITIGATION_NONE;
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER)) {
+ tsa_mitigation = TSA_MITIGATION_USER_KERNEL;
+ uk = true;
+ }
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST)) {
+ tsa_mitigation = TSA_MITIGATION_VM;
+ vm = true;
+ }
+
+ if (uk && vm)
+ tsa_mitigation = TSA_MITIGATION_FULL;
+ }
+
if (tsa_mitigation == TSA_MITIGATION_NONE)
return;
- if (!boot_cpu_has(X86_FEATURE_VERW_CLEAR)) {
+ if (!boot_cpu_has(X86_FEATURE_VERW_CLEAR))
tsa_mitigation = TSA_MITIGATION_UCODE_NEEDED;
- goto out;
- }
-
- if (tsa_mitigation == TSA_MITIGATION_AUTO)
- tsa_mitigation = TSA_MITIGATION_FULL;
/*
* No need to set verw_clear_cpu_buf_mitigation_selected - it
* doesn't fit all cases here and it is not needed because this
* is the only VERW-based mitigation on AMD.
*/
-out:
pr_info("%s\n", tsa_strings[tsa_mitigation]);
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/pti: Add attack vector controls for PTI
2025-07-07 18:33 ` [PATCH v6 19/21] x86/pti: Add attack vector controls for PTI David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 02c7d5b8e0d123185817f533ed12622ed1c695e5
Gitweb: https://git.kernel.org/tip/02c7d5b8e0d123185817f533ed12622ed1c695e5
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:14 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/pti: Add attack vector controls for PTI
Disable PTI mitigation if user->kernel attack vector mitigations are
disabled.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-20-david.kaplan@amd.com
---
arch/x86/mm/pti.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 1902998..6dba18f 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -38,6 +38,7 @@
#include <asm/desc.h>
#include <asm/sections.h>
#include <asm/set_memory.h>
+#include <asm/bugs.h>
#undef pr_fmt
#define pr_fmt(fmt) "Kernel/User page tables isolation: " fmt
@@ -84,7 +85,8 @@ void __init pti_check_boottime_disable(void)
return;
}
- if (cpu_mitigations_off())
+ if (pti_mode == PTI_AUTO &&
+ !cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
pti_mode = PTI_FORCE_OFF;
if (pti_mode == PTI_FORCE_OFF) {
pti_print_if_insecure("disabled on command line.");
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for ITS
2025-07-07 18:33 ` [PATCH v6 18/21] x86/bugs: Add attack vector controls for ITS David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 0cdd2c4f35cf9bb9466b36724b658d11ff453f04
Gitweb: https://git.kernel.org/tip/0cdd2c4f35cf9bb9466b36724b658d11ff453f04
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:13 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for ITS
Use attack vector controls to determine if ITS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-19-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index eef6ccd..f41d871 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1518,13 +1518,17 @@ early_param("indirect_target_selection", its_parse_cmdline);
static void __init its_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_ITS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_ITS)) {
its_mitigation = ITS_MITIGATION_OFF;
return;
}
- if (its_mitigation == ITS_MITIGATION_AUTO)
- its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
+ if (its_mitigation == ITS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_ITS))
+ its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
+ else
+ its_mitigation = ITS_MITIGATION_OFF;
+ }
if (its_mitigation == ITS_MITIGATION_OFF)
return;
@@ -1555,12 +1559,13 @@ static void __init its_select_mitigation(void)
static void __init its_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_ITS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_ITS))
return;
switch (spectre_v2_enabled) {
case SPECTRE_V2_NONE:
- pr_err("WARNING: Spectre-v2 mitigation is off, disabling ITS\n");
+ if (its_mitigation != ITS_MITIGATION_OFF)
+ pr_err("WARNING: Spectre-v2 mitigation is off, disabling ITS\n");
its_mitigation = ITS_MITIGATION_OFF;
break;
case SPECTRE_V2_RETPOLINE:
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for SRSO
2025-07-07 18:33 ` [PATCH v6 17/21] x86/bugs: Add attack vector controls for SRSO David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: eda718fde6159b2e64978637ebb3f1ae98180555
Gitweb: https://git.kernel.org/tip/eda718fde6159b2e64978637ebb3f1ae98180555
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:12 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for SRSO
Use attack vector controls to determine if SRSO mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-18-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 2128623..eef6ccd 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3123,14 +3123,19 @@ early_param("spec_rstack_overflow", srso_parse_cmdline);
static void __init srso_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SRSO)) {
srso_mitigation = SRSO_MITIGATION_NONE;
-
- if (srso_mitigation == SRSO_MITIGATION_NONE)
return;
+ }
- if (srso_mitigation == SRSO_MITIGATION_AUTO)
- srso_mitigation = SRSO_MITIGATION_SAFE_RET;
+ if (srso_mitigation == SRSO_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_SRSO)) {
+ srso_mitigation = SRSO_MITIGATION_SAFE_RET;
+ } else {
+ srso_mitigation = SRSO_MITIGATION_NONE;
+ return;
+ }
+ }
/* Zen1/2 with SMT off aren't vulnerable to SRSO. */
if (boot_cpu_data.x86 < 0x19 && !cpu_smt_possible()) {
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for L1TF
2025-07-07 18:33 ` [PATCH v6 16/21] x86/bugs: Add attack vector controls for L1TF David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 2f970a526975f4437bdc9a4ba550ecc7e66d861d
Gitweb: https://git.kernel.org/tip/2f970a526975f4437bdc9a4ba550ecc7e66d861d
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:11 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for L1TF
Use attack vector controls to determine if L1TF mitigation is required.
Disable SMT if cross-thread protection is desired.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-17-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 94c72f4..2128623 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2995,17 +2995,23 @@ static void override_cache_bits(struct cpuinfo_x86 *c)
static void __init l1tf_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_L1TF) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_L1TF)) {
l1tf_mitigation = L1TF_MITIGATION_OFF;
return;
}
- if (l1tf_mitigation == L1TF_MITIGATION_AUTO) {
- if (cpu_mitigations_auto_nosmt())
- l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
- else
- l1tf_mitigation = L1TF_MITIGATION_FLUSH;
+ if (l1tf_mitigation != L1TF_MITIGATION_AUTO)
+ return;
+
+ if (!should_mitigate_vuln(X86_BUG_L1TF)) {
+ l1tf_mitigation = L1TF_MITIGATION_OFF;
+ return;
}
+
+ if (smt_mitigations == SMT_MITIGATIONS_ON)
+ l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
+ else
+ l1tf_mitigation = L1TF_MITIGATION_FLUSH;
}
static void __init l1tf_apply_mitigation(void)
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v2
2025-07-07 18:33 ` [PATCH v6 15/21] x86/bugs: Add attack vector controls for spectre_v2 David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: fdf99228e2f4e0486dc629e87fcece42abfe3f9c
Gitweb: https://git.kernel.org/tip/fdf99228e2f4e0486dc629e87fcece42abfe3f9c
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:10 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for spectre_v2
Use attack vector controls to determine if spectre_v2 mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-16-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 2022f05..94c72f4 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2013,8 +2013,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
int ret, i;
cmd = IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2) ? SPECTRE_V2_CMD_AUTO : SPECTRE_V2_CMD_NONE;
- if (cmdline_find_option_bool(boot_command_line, "nospectre_v2") ||
- cpu_mitigations_off())
+ if (cmdline_find_option_bool(boot_command_line, "nospectre_v2"))
return SPECTRE_V2_CMD_NONE;
ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
@@ -2286,8 +2285,11 @@ static void __init spectre_v2_select_mitigation(void)
case SPECTRE_V2_CMD_NONE:
return;
- case SPECTRE_V2_CMD_FORCE:
case SPECTRE_V2_CMD_AUTO:
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2))
+ break;
+ fallthrough;
+ case SPECTRE_V2_CMD_FORCE:
if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
spectre_v2_enabled = SPECTRE_V2_EIBRS;
break;
@@ -2341,7 +2343,7 @@ static void __init spectre_v2_update_mitigation(void)
}
}
- if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2) && !cpu_mitigations_off())
+ if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
pr_info("%s\n", spectre_v2_strings[spectre_v2_enabled]);
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for BHI
2025-07-07 18:33 ` [PATCH v6 14/21] x86/bugs: Add attack vector controls for BHI David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ddcd4d3cb37c8ad60cdbaaffe93f85e15e2babb5
Gitweb: https://git.kernel.org/tip/ddcd4d3cb37c8ad60cdbaaffe93f85e15e2babb5
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:09 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for BHI
Use attack vector controls to determine if BHI mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-15-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index ff56251..2022f05 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2217,11 +2217,20 @@ early_param("spectre_bhi", spectre_bhi_parse_cmdline);
static void __init bhi_select_mitigation(void)
{
- if (!boot_cpu_has(X86_BUG_BHI) || cpu_mitigations_off())
+ if (!boot_cpu_has(X86_BUG_BHI))
bhi_mitigation = BHI_MITIGATION_OFF;
- if (bhi_mitigation == BHI_MITIGATION_AUTO)
- bhi_mitigation = BHI_MITIGATION_ON;
+ if (bhi_mitigation != BHI_MITIGATION_AUTO)
+ return;
+
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST)) {
+ if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
+ bhi_mitigation = BHI_MITIGATION_ON;
+ else
+ bhi_mitigation = BHI_MITIGATION_VMEXIT_ONLY;
+ } else {
+ bhi_mitigation = BHI_MITIGATION_OFF;
+ }
}
static void __init bhi_update_mitigation(void)
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v2_user
2025-07-07 18:33 ` [PATCH v6 13/21] x86/bugs: Add attack vector controls for spectre_v2_user David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 07a659edcf6eb56f7906fc415f46e3a7f37d5383
Gitweb: https://git.kernel.org/tip/07a659edcf6eb56f7906fc415f46e3a7f37d5383
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:08 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for spectre_v2_user
Use attack vector controls to determine if spectre_v2_user mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-14-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index de6eb59..ff56251 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1817,7 +1817,7 @@ static enum spectre_v2_user_cmd __init spectre_v2_parse_user_cmdline(void)
char arg[20];
int ret, i;
- if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
+ if (!IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
return SPECTRE_V2_USER_CMD_NONE;
ret = cmdline_find_option(boot_command_line, "spectre_v2_user",
@@ -1855,6 +1855,13 @@ static void __init spectre_v2_user_select_mitigation(void)
spectre_v2_user_stibp = SPECTRE_V2_USER_STRICT;
break;
case SPECTRE_V2_USER_CMD_AUTO:
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2_USER))
+ break;
+ spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
+ if (smt_mitigations == SMT_MITIGATIONS_OFF)
+ break;
+ spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
+ break;
case SPECTRE_V2_USER_CMD_PRCTL:
spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for retbleed
2025-07-07 18:33 ` [PATCH v6 12/21] x86/bugs: Add attack vector controls for retbleed David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 9687eb2399379ae4e5b5cc1bccdf893c753dcffb
Gitweb: https://git.kernel.org/tip/9687eb2399379ae4e5b5cc1bccdf893c753dcffb
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:07 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for retbleed
Use attack vector controls to determine if retbleed mitigation is
required.
Disable SMT if cross-thread protection is desired and STIBP is not
available.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-13-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 130db82..de6eb59 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1313,7 +1313,7 @@ early_param("retbleed", retbleed_parse_cmdline);
static void __init retbleed_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_RETBLEED)) {
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
return;
}
@@ -1350,6 +1350,11 @@ static void __init retbleed_select_mitigation(void)
if (retbleed_mitigation != RETBLEED_MITIGATION_AUTO)
return;
+ if (!should_mitigate_vuln(X86_BUG_RETBLEED)) {
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
+ return;
+ }
+
/* Intel mitigation selected in retbleed_update_mitigation() */
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
@@ -1373,7 +1378,7 @@ static void __init retbleed_select_mitigation(void)
static void __init retbleed_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_RETBLEED))
return;
/* ITS can also enable stuffing */
@@ -1468,7 +1473,7 @@ static void __init retbleed_apply_mitigation(void)
}
if (mitigate_smt && !boot_cpu_has(X86_FEATURE_STIBP) &&
- (retbleed_nosmt || cpu_mitigations_auto_nosmt()))
+ (retbleed_nosmt || smt_mitigations == SMT_MITIGATIONS_ON))
cpu_smt_disable(false);
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v1
2025-07-07 18:33 ` [PATCH v6 11/21] x86/bugs: Add attack vector controls for spectre_v1 David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 19a5f3ea4394bf813a03d1ff0efe59a7f74cc12c
Gitweb: https://git.kernel.org/tip/19a5f3ea4394bf813a03d1ff0efe59a7f74cc12c
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:06 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for spectre_v1
Use attack vector controls to determine if spectre_v1 mitigation is
required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-12-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index e9227e4..130db82 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1144,13 +1144,16 @@ static bool smap_works_speculatively(void)
static void __init spectre_v1_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
+ spectre_v1_mitigation = SPECTRE_V1_MITIGATION_NONE;
+
+ if (!should_mitigate_vuln(X86_BUG_SPECTRE_V1))
spectre_v1_mitigation = SPECTRE_V1_MITIGATION_NONE;
}
static void __init spectre_v1_apply_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
return;
if (spectre_v1_mitigation == SPECTRE_V1_MITIGATION_AUTO) {
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for GDS
2025-07-07 18:33 ` [PATCH v6 10/21] x86/bugs: Add attack vector controls for GDS David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8c7261abcb7ad1df493773fd52ff3ddce37a25e6
Gitweb: https://git.kernel.org/tip/8c7261abcb7ad1df493773fd52ff3ddce37a25e6
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:05 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:41 +02:00
x86/bugs: Add attack vector controls for GDS
Use attack vector controls to determine if GDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-11-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index de0b5ef..e9227e4 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1030,12 +1030,15 @@ static void __init gds_select_mitigation(void)
return;
}
- if (cpu_mitigations_off())
- gds_mitigation = GDS_MITIGATION_OFF;
/* Will verify below that mitigation _can_ be disabled */
-
- if (gds_mitigation == GDS_MITIGATION_AUTO)
- gds_mitigation = GDS_MITIGATION_FULL;
+ if (gds_mitigation == GDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_GDS))
+ gds_mitigation = GDS_MITIGATION_FULL;
+ else {
+ gds_mitigation = GDS_MITIGATION_OFF;
+ return;
+ }
+ }
/* No microcode */
if (!(x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)) {
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for SRBDS
2025-07-07 18:33 ` [PATCH v6 09/21] x86/bugs: Add attack vector controls for SRBDS David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 71dc301c26e9503350cf4e736022cc1eb8e986a7
Gitweb: https://git.kernel.org/tip/71dc301c26e9503350cf4e736022cc1eb8e986a7
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:04 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Add attack vector controls for SRBDS
Use attack vector controls to determine if SRBDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-10-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a557d17..de0b5ef 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -870,13 +870,19 @@ void update_srbds_msr(void)
static void __init srbds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_SRBDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_SRBDS)) {
srbds_mitigation = SRBDS_MITIGATION_OFF;
return;
}
- if (srbds_mitigation == SRBDS_MITIGATION_AUTO)
- srbds_mitigation = SRBDS_MITIGATION_FULL;
+ if (srbds_mitigation == SRBDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_SRBDS))
+ srbds_mitigation = SRBDS_MITIGATION_FULL;
+ else {
+ srbds_mitigation = SRBDS_MITIGATION_OFF;
+ return;
+ }
+ }
/*
* Check to see if this is one of the MDS_NO systems supporting TSX that
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for RFDS
2025-07-07 18:33 ` [PATCH v6 08/21] x86/bugs: Add attack vector controls for RFDS David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 54b53dca650bb273655a9a9b5a5b5a3fced0bcc1
Gitweb: https://git.kernel.org/tip/54b53dca650bb273655a9a9b5a5b5a3fced0bcc1
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:03 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Add attack vector controls for RFDS
Use attack vector controls to determine if RFDS mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-9-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 39ff556..a557d17 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -748,13 +748,17 @@ static inline bool __init verw_clears_cpu_reg_file(void)
static void __init rfds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RFDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_RFDS)) {
rfds_mitigation = RFDS_MITIGATION_OFF;
return;
}
- if (rfds_mitigation == RFDS_MITIGATION_AUTO)
- rfds_mitigation = RFDS_MITIGATION_VERW;
+ if (rfds_mitigation == RFDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_RFDS))
+ rfds_mitigation = RFDS_MITIGATION_VERW;
+ else
+ rfds_mitigation = RFDS_MITIGATION_OFF;
+ }
if (rfds_mitigation == RFDS_MITIGATION_OFF)
return;
@@ -765,7 +769,7 @@ static void __init rfds_select_mitigation(void)
static void __init rfds_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_RFDS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_RFDS))
return;
if (verw_clear_cpu_buf_mitigation_selected)
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for MMIO
2025-07-07 18:33 ` [PATCH v6 07/21] x86/bugs: Add attack vector controls for MMIO David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: de6f0921ba49f5e07f57eb227dcb69ebb4776911
Gitweb: https://git.kernel.org/tip/de6f0921ba49f5e07f57eb227dcb69ebb4776911
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:02 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Add attack vector controls for MMIO
Use attack vectors controls to determine if MMIO mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-8-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 438c482..39ff556 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -639,8 +639,12 @@ static void __init mmio_select_mitigation(void)
}
/* Microcode will be checked in mmio_update_mitigation(). */
- if (mmio_mitigation == MMIO_MITIGATION_AUTO)
- mmio_mitigation = MMIO_MITIGATION_VERW;
+ if (mmio_mitigation == MMIO_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_MMIO_STALE_DATA))
+ mmio_mitigation = MMIO_MITIGATION_VERW;
+ else
+ mmio_mitigation = MMIO_MITIGATION_OFF;
+ }
if (mmio_mitigation == MMIO_MITIGATION_OFF)
return;
@@ -655,7 +659,7 @@ static void __init mmio_select_mitigation(void)
static void __init mmio_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
return;
if (verw_clear_cpu_buf_mitigation_selected)
@@ -703,7 +707,7 @@ static void __init mmio_apply_mitigation(void)
if (!(x86_arch_cap_msr & ARCH_CAP_FBSDP_NO))
static_branch_enable(&cpu_buf_idle_clear);
- if (mmio_nosmt || cpu_mitigations_auto_nosmt())
+ if (mmio_nosmt || smt_mitigations == SMT_MITIGATIONS_ON)
cpu_smt_disable(false);
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for TAA
2025-07-07 18:33 ` [PATCH v6 06/21] x86/bugs: Add attack vector controls for TAA David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 736565d4edcd8b6dad50fca0c0134e7918e3d61c
Gitweb: https://git.kernel.org/tip/736565d4edcd8b6dad50fca0c0134e7918e3d61c
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:01 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Add attack vector controls for TAA
Use attack vector controls to determine if TAA mitigation is required.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-7-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 31e0cf8..438c482 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -538,12 +538,13 @@ static void __init taa_select_mitigation(void)
return;
}
- if (cpu_mitigations_off())
- taa_mitigation = TAA_MITIGATION_OFF;
-
/* Microcode will be checked in taa_update_mitigation(). */
- if (taa_mitigation == TAA_MITIGATION_AUTO)
- taa_mitigation = TAA_MITIGATION_VERW;
+ if (taa_mitigation == TAA_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_TAA))
+ taa_mitigation = TAA_MITIGATION_VERW;
+ else
+ taa_mitigation = TAA_MITIGATION_OFF;
+ }
if (taa_mitigation != TAA_MITIGATION_OFF)
verw_clear_cpu_buf_mitigation_selected = true;
@@ -551,7 +552,7 @@ static void __init taa_select_mitigation(void)
static void __init taa_update_mitigation(void)
{
- if (!taa_vulnerable() || cpu_mitigations_off())
+ if (!taa_vulnerable())
return;
if (verw_clear_cpu_buf_mitigation_selected)
@@ -592,7 +593,7 @@ static void __init taa_apply_mitigation(void)
*/
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
- if (taa_nosmt || cpu_mitigations_auto_nosmt())
+ if (taa_nosmt || smt_mitigations == SMT_MITIGATIONS_ON)
cpu_smt_disable(false);
}
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Add attack vector controls for MDS
2025-07-07 18:33 ` [PATCH v6 05/21] x86/bugs: Add attack vector controls for MDS David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e3a88d4c068242c00a1d6ddfd3c711fc22983f75
Gitweb: https://git.kernel.org/tip/e3a88d4c068242c00a1d6ddfd3c711fc22983f75
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:33:00 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Add attack vector controls for MDS
Use attack vector controls to determine if MDS mitigation is required.
The global mitigations=off command now simply disables all attack vectors
so explicit checking of mitigations=off is no longer needed.
If cross-thread attack mitigations are required, disable SMT.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-6-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b083e7e..31e0cf8 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -441,13 +441,17 @@ static bool verw_clear_cpu_buf_mitigation_selected __ro_after_init;
static void __init mds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_MDS)) {
mds_mitigation = MDS_MITIGATION_OFF;
return;
}
- if (mds_mitigation == MDS_MITIGATION_AUTO)
- mds_mitigation = MDS_MITIGATION_FULL;
+ if (mds_mitigation == MDS_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(X86_BUG_MDS))
+ mds_mitigation = MDS_MITIGATION_FULL;
+ else
+ mds_mitigation = MDS_MITIGATION_OFF;
+ }
if (mds_mitigation == MDS_MITIGATION_OFF)
return;
@@ -457,7 +461,7 @@ static void __init mds_select_mitigation(void)
static void __init mds_update_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off())
+ if (!boot_cpu_has_bug(X86_BUG_MDS))
return;
/* If TAA, MMIO, or RFDS are being mitigated, MDS gets mitigated too. */
@@ -478,7 +482,7 @@ static void __init mds_apply_mitigation(void)
mds_mitigation == MDS_MITIGATION_VMWERV) {
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
if (!boot_cpu_has(X86_BUG_MSBDS_ONLY) &&
- (mds_nosmt || cpu_mitigations_auto_nosmt()))
+ (mds_nosmt || smt_mitigations == SMT_MITIGATIONS_ON))
cpu_smt_disable(false);
}
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/bugs: Define attack vectors relevant for each bug
2025-07-07 18:32 ` [PATCH v6 04/21] x86/bugs: Define attack vectors relevant for each bug David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 2d31d2874663cde2cab8c18bfb52ed8be6dfa958
Gitweb: https://git.kernel.org/tip/2d31d2874663cde2cab8c18bfb52ed8be6dfa958
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:32:59 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/bugs: Define attack vectors relevant for each bug
Add a function which defines which vulnerabilities should be mitigated
based on the selected attack vector controls. The selections here are
based on the individual characteristics of each vulnerability.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-5-david.kaplan@amd.com
---
arch/x86/kernel/cpu/bugs.c | 56 +++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 88769c4..b083e7e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -332,6 +332,62 @@ static void x86_amd_ssb_disable(void)
#undef pr_fmt
#define pr_fmt(fmt) "MDS: " fmt
+/*
+ * Returns true if vulnerability should be mitigated based on the
+ * selected attack vector controls.
+ *
+ * See Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+ */
+static bool __init should_mitigate_vuln(unsigned int bug)
+{
+ switch (bug) {
+ /*
+ * The only runtime-selected spectre_v1 mitigations in the kernel are
+ * related to SWAPGS protection on kernel entry. Therefore, protection
+ * is only required for the user->kernel attack vector.
+ */
+ case X86_BUG_SPECTRE_V1:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL);
+
+ case X86_BUG_SPECTRE_V2:
+ case X86_BUG_RETBLEED:
+ case X86_BUG_SRSO:
+ case X86_BUG_L1TF:
+ case X86_BUG_ITS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST);
+
+ case X86_BUG_SPECTRE_V2_USER:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST);
+
+ /*
+ * All the vulnerabilities below allow potentially leaking data
+ * across address spaces. Therefore, mitigation is required for
+ * any of these 4 attack vectors.
+ */
+ case X86_BUG_MDS:
+ case X86_BUG_TAA:
+ case X86_BUG_MMIO_STALE_DATA:
+ case X86_BUG_RFDS:
+ case X86_BUG_SRBDS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST);
+
+ case X86_BUG_GDS:
+ return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
+ cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST) ||
+ (smt_mitigations != SMT_MITIGATIONS_OFF);
+ default:
+ WARN(1, "Unknown bug %x\n", bug);
+ return false;
+ }
+}
+
/* Default mitigation for MDS-affected CPUs */
static enum mds_mitigations mds_mitigation __ro_after_init =
IS_ENABLED(CONFIG_MITIGATION_MDS) ? MDS_MITIGATION_AUTO : MDS_MITIGATION_OFF;
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] x86/Kconfig: Add arch attack vector support
2025-07-07 18:32 ` [PATCH v6 03/21] x86/Kconfig: Add arch attack vector support David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 735e59204b5eb5aa55ba64be5d8ff4223b197816
Gitweb: https://git.kernel.org/tip/735e59204b5eb5aa55ba64be5d8ff4223b197816
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:32:58 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:56:40 +02:00
x86/Kconfig: Add arch attack vector support
ARCH_HAS_CPU_ATTACK_VECTORS should be set for architectures which implement
the new attack-vector based controls for CPU mitigations. If an arch does
not support attack-vector based controls then an attempt to use them
results in a warning.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-4-david.kaplan@amd.com
---
arch/Kconfig | 3 +++
arch/x86/Kconfig | 1 +
2 files changed, 4 insertions(+)
diff --git a/arch/Kconfig b/arch/Kconfig
index a3308a2..7d8a4e7 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1763,4 +1763,7 @@ config ARCH_WANTS_PRE_LINK_VMLINUX
An architecture can select this if it provides arch/<arch>/tools/Makefile
with .arch.vmlinux.o target to be linked into vmlinux.
+config ARCH_HAS_CPU_ATTACK_VECTORS
+ bool
+
endmenu
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 71dfe7d..6c20adb 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -75,6 +75,7 @@ config X86
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
+ select ARCH_HAS_CPU_ATTACK_VECTORS if CPU_MITIGATIONS
select ARCH_HAS_CACHE_LINE_SIZE
select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
select ARCH_HAS_CPU_FINALIZE_INIT
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] cpu: Define attack vectors
2025-07-07 18:32 ` [PATCH v6 02/21] cpu: Define attack vectors David Kaplan
2025-07-10 10:42 ` Borislav Petkov
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
1 sibling, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 19c24f7ee39af503b9731067b91add627b70ecb6
Gitweb: https://git.kernel.org/tip/19c24f7ee39af503b9731067b91add627b70ecb6
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Mon, 07 Jul 2025 13:32:57 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:55:16 +02:00
cpu: Define attack vectors
Define 4 new attack vectors that are used for controlling CPU speculation
mitigations. These may be individually disabled as part of the
mitigations= command line. Attack vector controls are combined with global
options like 'auto' or 'auto,nosmt' like 'mitigations=auto,no_user_kernel'.
The global options come first in the mitigations= string.
Cross-thread mitigations can either remain enabled fully, including
potentially disabling SMT ('auto,nosmt'), remain enabled except for
disabling SMT ('auto'), or entirely disabled through the new
'no_cross_thread' attack vector option.
The default settings for these attack vectors are consistent with existing
kernel defaults, other than the automatic disabling of VM-based attack
vectors if KVM support is not present.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250707183316.1349127-3-david.kaplan@amd.com
---
include/linux/cpu.h | 21 +++++++-
kernel/cpu.c | 130 +++++++++++++++++++++++++++++++++++++++----
2 files changed, 140 insertions(+), 11 deletions(-)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 6378370..1fb143e 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -198,9 +198,25 @@ void cpuhp_report_idle_dead(void);
static inline void cpuhp_report_idle_dead(void) { }
#endif /* #ifdef CONFIG_HOTPLUG_CPU */
+enum cpu_attack_vectors {
+ CPU_MITIGATE_USER_KERNEL,
+ CPU_MITIGATE_USER_USER,
+ CPU_MITIGATE_GUEST_HOST,
+ CPU_MITIGATE_GUEST_GUEST,
+ NR_CPU_ATTACK_VECTORS,
+};
+
+enum smt_mitigations {
+ SMT_MITIGATIONS_OFF,
+ SMT_MITIGATIONS_AUTO,
+ SMT_MITIGATIONS_ON,
+};
+
#ifdef CONFIG_CPU_MITIGATIONS
extern bool cpu_mitigations_off(void);
extern bool cpu_mitigations_auto_nosmt(void);
+extern bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v);
+extern enum smt_mitigations smt_mitigations;
#else
static inline bool cpu_mitigations_off(void)
{
@@ -210,6 +226,11 @@ static inline bool cpu_mitigations_auto_nosmt(void)
{
return false;
}
+static inline bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
+{
+ return false;
+}
+#define smt_mitigations SMT_MITIGATIONS_OFF
#endif
#endif /* _LINUX_CPU_H_ */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a59e009..faf0f23 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -37,6 +37,7 @@
#include <linux/cpuset.h>
#include <linux/random.h>
#include <linux/cc_platform.h>
+#include <linux/parser.h>
#include <trace/events/power.h>
#define CREATE_TRACE_POINTS
@@ -3174,8 +3175,38 @@ void __init boot_cpu_hotplug_init(void)
#ifdef CONFIG_CPU_MITIGATIONS
/*
- * These are used for a global "mitigations=" cmdline option for toggling
- * optional CPU mitigations.
+ * All except the cross-thread attack vector are mitigated by default.
+ * Cross-thread mitigation often requires disabling SMT which is expensive
+ * so cross-thread mitigations are only partially enabled by default.
+ *
+ * Guest-to-Host and Guest-to-Guest vectors are only needed if KVM support is
+ * present.
+ */
+static bool attack_vectors[NR_CPU_ATTACK_VECTORS] __ro_after_init = {
+ [CPU_MITIGATE_USER_KERNEL] = true,
+ [CPU_MITIGATE_USER_USER] = true,
+ [CPU_MITIGATE_GUEST_HOST] = IS_ENABLED(CONFIG_KVM),
+ [CPU_MITIGATE_GUEST_GUEST] = IS_ENABLED(CONFIG_KVM),
+};
+
+bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
+{
+ if (v < NR_CPU_ATTACK_VECTORS)
+ return attack_vectors[v];
+
+ WARN_ONCE(1, "Invalid attack vector %d\n", v);
+ return false;
+}
+
+/*
+ * There are 3 global options, 'off', 'auto', 'auto,nosmt'. These may optionally
+ * be combined with attack-vector disables which follow them.
+ *
+ * Examples:
+ * mitigations=auto,no_user_kernel,no_user_user,no_cross_thread
+ * mitigations=auto,nosmt,no_guest_host,no_guest_guest
+ *
+ * mitigations=off is equivalent to disabling all attack vectors.
*/
enum cpu_mitigations {
CPU_MITIGATIONS_OFF,
@@ -3183,19 +3214,96 @@ enum cpu_mitigations {
CPU_MITIGATIONS_AUTO_NOSMT,
};
+enum {
+ NO_USER_KERNEL,
+ NO_USER_USER,
+ NO_GUEST_HOST,
+ NO_GUEST_GUEST,
+ NO_CROSS_THREAD,
+ NR_VECTOR_PARAMS,
+};
+
+enum smt_mitigations smt_mitigations __ro_after_init = SMT_MITIGATIONS_AUTO;
static enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO;
+static const match_table_t global_mitigations = {
+ { CPU_MITIGATIONS_AUTO_NOSMT, "auto,nosmt"},
+ { CPU_MITIGATIONS_AUTO, "auto"},
+ { CPU_MITIGATIONS_OFF, "off"},
+};
+
+static const match_table_t vector_mitigations = {
+ { NO_USER_KERNEL, "no_user_kernel"},
+ { NO_USER_USER, "no_user_user"},
+ { NO_GUEST_HOST, "no_guest_host"},
+ { NO_GUEST_GUEST, "no_guest_guest"},
+ { NO_CROSS_THREAD, "no_cross_thread"},
+ { NR_VECTOR_PARAMS, NULL},
+};
+
+static int __init mitigations_parse_global_opt(char *arg)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(global_mitigations); i++) {
+ const char *pattern = global_mitigations[i].pattern;
+
+ if (!strncmp(arg, pattern, strlen(pattern))) {
+ cpu_mitigations = global_mitigations[i].token;
+ return strlen(pattern);
+ }
+ }
+
+ return 0;
+}
+
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"))
- cpu_mitigations = CPU_MITIGATIONS_AUTO_NOSMT;
- else
- pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n",
- arg);
+ char *s, *p;
+ int len;
+
+ len = mitigations_parse_global_opt(arg);
+
+ if (cpu_mitigations_off()) {
+ memset(attack_vectors, 0, sizeof(attack_vectors));
+ smt_mitigations = SMT_MITIGATIONS_OFF;
+ } else if (cpu_mitigations_auto_nosmt()) {
+ smt_mitigations = SMT_MITIGATIONS_ON;
+ }
+
+ p = arg + len;
+
+ if (!*p)
+ return 0;
+
+ /* Attack vector controls may come after the ',' */
+ if (*p++ != ',' || !IS_ENABLED(CONFIG_ARCH_HAS_CPU_ATTACK_VECTORS)) {
+ pr_crit("Unsupported mitigations=%s, system may still be vulnerable\n", arg);
+ return 0;
+ }
+
+ while ((s = strsep(&p, ",")) != NULL) {
+ switch (match_token(s, vector_mitigations, NULL)) {
+ case NO_USER_KERNEL:
+ attack_vectors[CPU_MITIGATE_USER_KERNEL] = false;
+ break;
+ case NO_USER_USER:
+ attack_vectors[CPU_MITIGATE_USER_USER] = false;
+ break;
+ case NO_GUEST_HOST:
+ attack_vectors[CPU_MITIGATE_GUEST_HOST] = false;
+ break;
+ case NO_GUEST_GUEST:
+ attack_vectors[CPU_MITIGATE_GUEST_GUEST] = false;
+ break;
+ case NO_CROSS_THREAD:
+ smt_mitigations = SMT_MITIGATIONS_OFF;
+ break;
+ default:
+ pr_crit("Unsupported mitigations options %s\n", s);
+ return 0;
+ }
+ }
return 0;
}
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [tip: x86/bugs] Documentation/x86: Document new attack vector controls
2025-07-09 15:57 ` [PATCH v7 01/22] " David Kaplan
@ 2025-07-11 16:09 ` tip-bot2 for David Kaplan
0 siblings, 0 replies; 50+ messages in thread
From: tip-bot2 for David Kaplan @ 2025-07-11 16:09 UTC (permalink / raw)
To: linux-tip-commits; +Cc: David Kaplan, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 1caa1b0509eaec2ea111b875da4eddb44edc9ea5
Gitweb: https://git.kernel.org/tip/1caa1b0509eaec2ea111b875da4eddb44edc9ea5
Author: David Kaplan <david.kaplan@amd.com>
AuthorDate: Wed, 09 Jul 2025 10:57:31 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 11 Jul 2025 17:51:43 +02:00
Documentation/x86: Document new attack vector controls
Document the 5 new attack vector command line options, how they
interact with existing vulnerability controls, and recommendations on when
they can be disabled.
Note that while mitigating against untrusted userspace requires both
user-to-kernel and user-to-user protection, these are kept separate. The
kernel can control what code executes inside of it and that may affect the
risk associated with vulnerabilities especially if new kernel mitigations
are implemented. The same isn't typically true of userspace.
In other words, the risk associated with user-to-user or guest-to-guest
attacks is unlikely to change over time. While the risk associated with
user-to-kernel or guest-to-host attacks may change. Therefore, these
controls are separated.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250709155731.3279419-1-david.kaplan@amd.com
---
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst | 238 +++++++-
Documentation/admin-guide/hw-vuln/index.rst | 1 +-
Documentation/admin-guide/kernel-parameters.txt | 4 +-
3 files changed, 243 insertions(+)
create mode 100644 Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
diff --git a/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
new file mode 100644
index 0000000..b4de16f
--- /dev/null
+++ b/Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
@@ -0,0 +1,238 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Attack Vector Controls
+======================
+
+Attack vector controls provide a simple method to configure only the mitigations
+for CPU vulnerabilities which are relevant given the intended use of a system.
+Administrators are encouraged to consider which attack vectors are relevant and
+disable all others in order to recoup system performance.
+
+When new relevant CPU vulnerabilities are found, they will be added to these
+attack vector controls so administrators will likely not need to reconfigure
+their command line parameters as mitigations will continue to be correctly
+applied based on the chosen attack vector controls.
+
+Attack Vectors
+--------------
+
+There are 5 sets of attack-vector mitigations currently supported by the kernel:
+
+#. :ref:`user_kernel`
+#. :ref:`user_user`
+#. :ref:`guest_host`
+#. :ref:`guest_guest`
+#. :ref:`smt`
+
+To control the enabled attack vectors, see :ref:`cmdline`.
+
+.. _user_kernel:
+
+User-to-Kernel
+^^^^^^^^^^^^^^
+
+The user-to-kernel attack vector involves a malicious userspace program
+attempting to leak kernel data into userspace by exploiting a CPU vulnerability.
+The kernel data involved might be limited to certain kernel memory, or include
+all memory in the system, depending on the vulnerability exploited.
+
+If no untrusted userspace applications are being run, such as with single-user
+systems, consider disabling user-to-kernel mitigations.
+
+Note that the CPU vulnerabilities mitigated by Linux have generally not been
+shown to be exploitable from browser-based sandboxes. User-to-kernel
+mitigations are therefore mostly relevant if unknown userspace applications may
+be run by untrusted users.
+
+*user-to-kernel mitigations are enabled by default*
+
+.. _user_user:
+
+User-to-User
+^^^^^^^^^^^^
+
+The user-to-user attack vector involves a malicious userspace program attempting
+to influence the behavior of another unsuspecting userspace program in order to
+exfiltrate data. The vulnerability of a userspace program is based on the
+program itself and the interfaces it provides.
+
+If no untrusted userspace applications are being run, consider disabling
+user-to-user mitigations.
+
+Note that because the Linux kernel contains a mapping of all physical memory,
+preventing a malicious userspace program from leaking data from another
+userspace program requires mitigating user-to-kernel attacks as well for
+complete protection.
+
+*user-to-user mitigations are enabled by default*
+
+.. _guest_host:
+
+Guest-to-Host
+^^^^^^^^^^^^^
+
+The guest-to-host attack vector involves a malicious VM attempting to leak
+hypervisor data into the VM. The data involved may be limited, or may
+potentially include all memory in the system, depending on the vulnerability
+exploited.
+
+If no untrusted VMs are being run, consider disabling guest-to-host mitigations.
+
+*guest-to-host mitigations are enabled by default if KVM support is present*
+
+.. _guest_guest:
+
+Guest-to-Guest
+^^^^^^^^^^^^^^
+
+The guest-to-guest attack vector involves a malicious VM attempting to influence
+the behavior of another unsuspecting VM in order to exfiltrate data. The
+vulnerability of a VM is based on the code inside the VM itself and the
+interfaces it provides.
+
+If no untrusted VMs, or only a single VM is being run, consider disabling
+guest-to-guest mitigations.
+
+Similar to the user-to-user attack vector, preventing a malicious VM from
+leaking data from another VM requires mitigating guest-to-host attacks as well
+due to the Linux kernel phys map.
+
+*guest-to-guest mitigations are enabled by default if KVM support is present*
+
+.. _smt:
+
+Cross-Thread
+^^^^^^^^^^^^
+
+The cross-thread attack vector involves a malicious userspace program or
+malicious VM either observing or attempting to influence the behavior of code
+running on the SMT sibling thread in order to exfiltrate data.
+
+Many cross-thread attacks can only be mitigated if SMT is disabled, which will
+result in reduced CPU core count and reduced performance.
+
+If cross-thread mitigations are fully enabled ('auto,nosmt'), all mitigations
+for cross-thread attacks will be enabled. SMT may be disabled depending on
+which vulnerabilities are present in the CPU.
+
+If cross-thread mitigations are partially enabled ('auto'), mitigations for
+cross-thread attacks will be enabled but SMT will not be disabled.
+
+If cross-thread mitigations are disabled, no mitigations for cross-thread
+attacks will be enabled.
+
+Cross-thread mitigation may not be required if core-scheduling or similar
+techniques are used to prevent untrusted workloads from running on SMT siblings.
+
+*cross-thread mitigations default to partially enabled*
+
+.. _cmdline:
+
+Command Line Controls
+---------------------
+
+Attack vectors are controlled through the mitigations= command line option. The
+value provided begins with a global option and then may optionally include one
+or more options to disable various attack vectors.
+
+Format:
+ | ``mitigations=[global]``
+ | ``mitigations=[global],[attack vectors]``
+
+Global options:
+
+============ =============================================================
+Option Description
+============ =============================================================
+'off' All attack vectors disabled.
+'auto' All attack vectors enabled, partial cross-thread mitigations.
+'auto,nosmt' All attack vectors enabled, full cross-thread mitigations.
+============ =============================================================
+
+Attack vector options:
+
+================= =======================================
+Option Description
+================= =======================================
+'no_user_kernel' Disables user-to-kernel mitigations.
+'no_user_user' Disables user-to-user mitigations.
+'no_guest_host' Disables guest-to-host mitigations.
+'no_guest_guest' Disables guest-to-guest mitigations
+'no_cross_thread' Disables all cross-thread mitigations.
+================= =======================================
+
+Multiple attack vector options may be specified in a comma-separated list. If
+the global option is not specified, it defaults to 'auto'. The global option
+'off' is equivalent to disabling all attack vectors.
+
+Examples:
+ | ``mitigations=auto,no_user_kernel``
+
+ Enable all attack vectors except user-to-kernel. Partial cross-thread
+ mitigations.
+
+ | ``mitigations=auto,nosmt,no_guest_host,no_guest_guest``
+
+ Enable all attack vectors and cross-thread mitigations except for
+ guest-to-host and guest-to-guest mitigations.
+
+ | ``mitigations=,no_cross_thread``
+
+ Enable all attack vectors but not cross-thread mitigations.
+
+Interactions with command-line options
+--------------------------------------
+
+Vulnerability-specific controls (e.g. "retbleed=off") take precedence over all
+attack vector controls. Mitigations for individual vulnerabilities may be
+turned on or off via their command-line options regardless of the attack vector
+controls.
+
+Summary of attack-vector mitigations
+------------------------------------
+
+When a vulnerability is mitigated due to an attack-vector control, the default
+mitigation option for that particular vulnerability is used. To use a different
+mitigation, please use the vulnerability-specific command line option.
+
+The table below summarizes which vulnerabilities are mitigated when different
+attack vectors are enabled and assuming the CPU is vulnerable.
+
+=============== ============== ============ ============= ============== ============ ========
+Vulnerability User-to-Kernel User-to-User Guest-to-Host Guest-to-Guest Cross-Thread Notes
+=============== ============== ============ ============= ============== ============ ========
+BHI X X
+ITS X X
+GDS X X X X * (Note 1)
+L1TF X X * (Note 2)
+MDS X X X X * (Note 2)
+MMIO X X X X * (Note 2)
+Meltdown X
+Retbleed X X * (Note 3)
+RFDS X X X X
+Spectre_v1 X
+Spectre_v2 X X
+Spectre_v2_user X X * (Note 1)
+SRBDS X X X X
+SRSO X X
+SSB (Note 4)
+TAA X X X X * (Note 2)
+TSA X X X X
+=============== ============== ============ ============= ============== ============ ========
+
+Notes:
+ 1 -- Can be mitigated without disabling SMT.
+
+ 2 -- Disables SMT if cross-thread mitigations are fully enabled and the CPU
+ is vulnerable
+
+ 3 -- Disables SMT if cross-thread mitigations are fully enabled, the CPU is
+ vulnerable, and STIBP is not supported
+
+ 4 -- Speculative store bypass is always enabled by default (no kernel
+ mitigation applied) unless overridden with spec_store_bypass_disable option
+
+When an attack-vector is disabled, all mitigations for the vulnerabilities
+listed in the above table are disabled, unless mitigation is required for a
+different enabled attack-vector or a mitigation is explicitly selected via a
+vulnerability-specific command line option.
diff --git a/Documentation/admin-guide/hw-vuln/index.rst b/Documentation/admin-guide/hw-vuln/index.rst
index 09890a8..89ca636 100644
--- a/Documentation/admin-guide/hw-vuln/index.rst
+++ b/Documentation/admin-guide/hw-vuln/index.rst
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time.
.. toctree::
:maxdepth: 1
+ attack_vector_controls
spectre
l1tf
mds
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 07e22ba..baa1d6a 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3790,6 +3790,10 @@
mmio_stale_data=full,nosmt [X86]
retbleed=auto,nosmt [X86]
+ [X86] After one of the above options, additionally
+ supports attack-vector based controls as documented in
+ Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
+
mminit_loglevel=
[KNL,EARLY] When CONFIG_DEBUG_MEMORY_INIT is set, this
parameter allows control of the logging verbosity for
^ permalink raw reply related [flat|nested] 50+ messages in thread
end of thread, other threads:[~2025-07-11 16:09 UTC | newest]
Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 18:32 [PATCH v6 00/21] Attack vector controls (part 2) David Kaplan
2025-07-07 18:32 ` [PATCH v6 01/21] Documentation/x86: Document new attack vector controls David Kaplan
2025-07-09 15:57 ` [PATCH v7 01/22] " David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:32 ` [PATCH v6 02/21] cpu: Define attack vectors David Kaplan
2025-07-10 10:42 ` Borislav Petkov
2025-07-10 14:02 ` Kaplan, David
2025-07-10 15:17 ` Borislav Petkov
2025-07-10 15:22 ` Kaplan, David
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:32 ` [PATCH v6 03/21] x86/Kconfig: Add arch attack vector support David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:32 ` [PATCH v6 04/21] x86/bugs: Define attack vectors relevant for each bug David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 05/21] x86/bugs: Add attack vector controls for MDS David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 06/21] x86/bugs: Add attack vector controls for TAA David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 07/21] x86/bugs: Add attack vector controls for MMIO David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 08/21] x86/bugs: Add attack vector controls for RFDS David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 09/21] x86/bugs: Add attack vector controls for SRBDS David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 10/21] x86/bugs: Add attack vector controls for GDS David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 11/21] x86/bugs: Add attack vector controls for spectre_v1 David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 12/21] x86/bugs: Add attack vector controls for retbleed David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 13/21] x86/bugs: Add attack vector controls for spectre_v2_user David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 14/21] x86/bugs: Add attack vector controls for BHI David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 15/21] x86/bugs: Add attack vector controls for spectre_v2 David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 16/21] x86/bugs: Add attack vector controls for L1TF David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 17/21] x86/bugs: Add attack vector controls for SRSO David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 18/21] x86/bugs: Add attack vector controls for ITS David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 19/21] x86/pti: Add attack vector controls for PTI David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 20/21] x86/bugs: Print enabled attack vectors David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-07-07 18:33 ` [PATCH v6 21/21] cpu: Show attack vectors in sysfs David Kaplan
2025-07-09 18:47 ` Borislav Petkov
2025-07-09 15:58 ` [PATCH v7 19/22] x86/bugs: Add attack vector controls for TSA David Kaplan
2025-07-11 16:09 ` [tip: x86/bugs] " tip-bot2 for David Kaplan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).