Attack vector controls (part 2)
Subsystems (6)
v6 cover Attack vector controls (part 2)
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/[email protected]/
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
Signature · 1 line
2.34.1
PATCH v6 1/21 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.
--- .../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
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst new file +237 -0
@@ -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.
Documentation/admin-guide/hw-vuln/index.rst +1 -0
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time. .. toctree:: :maxdepth: 1 + attack_vector_controls spectre l1tf mds
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -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
Signature · 1 line
2.34.1
PATCH v7 1/22 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.
--- .../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
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst new file +238 -0
@@ -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.
Documentation/admin-guide/hw-vuln/index.rst +1 -0
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time. .. toctree:: :maxdepth: 1 + attack_vector_controls spectre l1tf mds
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -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
Signature · 1 line
2.34.1
[tip: x86/bugs] Documentation/x86: Document new attack vector controls
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Wed, 09 Jul 2025 10:57:31 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- 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
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst new file +238 -0
@@ -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.
Documentation/admin-guide/hw-vuln/index.rst +1 -0
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time. .. toctree:: :maxdepth: 1 + attack_vector_controls spectre l1tf mds
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -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
PATCH v6 2/21 cpu: Define attack vectors
In reply to David KaplanDefine 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.
--- include/linux/cpu.h | 21 +++++++ kernel/cpu.c | 130 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 140 insertions(+), 11 deletions(-)
include/linux/cpu.h +21 -0
@@ -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_ */
kernel/cpu.c +119 -11
152 lines not on this page · raw message
Signature · 1 line
2.34.1
Borislav Petkov
maintainerRe: [PATCH v6 02/21] cpu: Define attack vectors
kernel/cpu.c enum cpu_mitigations { · line 3280
Quoted 2 lines · David Kaplan
kernel/cpu.c +2
-0+/* 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.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRE: [PATCH v6 02/21] cpu: Define attack vectors
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 31 lines
-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Thursday, July 10, 2025 5:43 AM
To: Kaplan, David <[email protected]>
Cc: Thomas Gleixner <[email protected]>; Peter Zijlstra <[email protected]>; Josh Poimboeuf <[email protected]>; Pawan Gupta <[email protected]>; Ingo Molnar <[email protected]>; Dave Hansen <[email protected]>; [email protected]; H . Peter Anvin <[email protected]>; [email protected]
Subject: Re: [PATCH v6 02/21] cpu: Define attack vectorsCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Review
Quoted 2 lines · David Kaplan
(quoted diff) +2
-0+ /* 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.
Quoted 9 lines
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
Borislav Petkov
maintainerRe: [PATCH v6 02/21] cpu: Define attack vectors
Quoted 3 lines · David
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.
Quoted 6 lines
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.
---
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst +4 -4
@@ -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.
kernel/cpu.c +2 -2
@@ -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 ; }
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRE: [PATCH v6 02/21] cpu: Define attack vectors
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 86 lines
-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Thursday, July 10, 2025 10:17 AM
To: Kaplan, David <[email protected]>
Cc: Thomas Gleixner <[email protected]>; Peter Zijlstra <[email protected]>; Josh Poimboeuf <[email protected]>; Pawan Gupta <[email protected]>; Ingo Molnar <[email protected]>; Dave Hansen <[email protected]>; [email protected]; H . Peter Anvin <[email protected]>; [email protected]
Subject: Re: [PATCH v6 02/21] cpu: Define attack vectorsCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 3 lines · David
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.
Quoted 6 lines
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.
---
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst +1
-1@@ -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:
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst +3
-3- | ``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.kernel/cpu.c +2
-2@@ -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",
Quoted 4 lines
arg);
return 0;
}Yeah that looks good to me. I did testing on this locally and it seemed to work fine.
Thanks
--David Kaplan
[tip: x86/bugs] cpu: Define attack vectors
In reply to David KaplanThe following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:32:57 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- include/linux/cpu.h | 21 +++++++- kernel/cpu.c | 130 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 140 insertions(+), 11 deletions(-)
include/linux/cpu.h +21 -0
@@ -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_ */
kernel/cpu.c +119 -11
152 lines not on this page · raw message
PATCH v6 3/21 x86/Kconfig: Add arch attack vector support
In reply to David KaplanARCH_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.
--- arch/Kconfig | 3 +++ arch/x86/Kconfig | 1 + 2 files changed, 4 insertions(+)
arch/Kconfig +3 -0
@@ -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
arch/x86/Kconfig +1 -0
@@ -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
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/Kconfig: Add arch attack vector support
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:32:58 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/Kconfig | 3 +++ arch/x86/Kconfig | 1 + 2 files changed, 4 insertions(+)
arch/Kconfig +3 -0
@@ -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
arch/x86/Kconfig +1 -0
@@ -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
PATCH v6 4/21 x86/bugs: Define attack vectors relevant for each bug
In reply to David KaplanAdd 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.
--- arch/x86/kernel/cpu/bugs.c | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/x86/kernel/cpu/bugs.c +56 -0
@@ -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 ;
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Define attack vectors relevant for each bug
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:32:59 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 56 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+)
arch/x86/kernel/cpu/bugs.c +56 -0
@@ -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 ;
PATCH v6 5/21 x86/bugs: Add attack vector controls for MDS
In reply to David KaplanUse 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.
--- arch/x86/kernel/cpu/bugs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +9 -5
@@ -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); } }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for MDS
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:00 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +9 -5
@@ -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); } }
PATCH v6 6/21 x86/bugs: Add attack vector controls for TAA
In reply to David KaplanUse attack vector controls to determine if TAA mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -7
@@ -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); } }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for TAA
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:01 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -7
@@ -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); } }
PATCH v6 7/21 x86/bugs: Add attack vector controls for MMIO
In reply to David KaplanUse attack vectors controls to determine if MMIO mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -4
@@ -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); }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for MMIO
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:02 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -4
@@ -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); }
PATCH v6 8/21 x86/bugs: Add attack vector controls for RFDS
In reply to David KaplanUse attack vector controls to determine if RFDS mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -4
@@ -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)
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for RFDS
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:03 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -4
@@ -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)
PATCH v6 9/21 x86/bugs: Add attack vector controls for SRBDS
In reply to David KaplanUse attack vector controls to determine if SRBDS mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +9 -3
@@ -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
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for SRBDS
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:04 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +9 -3
@@ -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
PATCH v6 10/21 x86/bugs: Add attack vector controls for GDS
In reply to David KaplanUse attack vector controls to determine if GDS mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -5
@@ -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 )) {
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for GDS
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:05 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -5
@@ -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 )) {
PATCH v6 11/21 x86/bugs: Add attack vector controls for spectre_v1
In reply to David KaplanUse attack vector controls to determine if spectre_v1 mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -2
@@ -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 ) {
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v1
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:06 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -2
@@ -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 ) {
PATCH v6 12/21 x86/bugs: Add attack vector controls for retbleed
In reply to David KaplanUse attack vector controls to determine if retbleed mitigation is required.
Disable SMT if cross-thread protection is desired and STIBP is not available.
--- arch/x86/kernel/cpu/bugs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -3
@@ -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); }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for retbleed
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:07 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +8 -3
@@ -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); }
PATCH v6 13/21 x86/bugs: Add attack vector controls for spectre_v2_user
In reply to David KaplanUse attack vector controls to determine if spectre_v2_user mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +8 -1
@@ -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 ;
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v2_user
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:08 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +8 -1
@@ -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 ;
PATCH v6 14/21 x86/bugs: Add attack vector controls for BHI
In reply to David KaplanUse attack vector controls to determine if BHI mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +12 -3
@@ -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 )
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for BHI
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:09 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +12 -3
@@ -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 )
PATCH v6 15/21 x86/bugs: Add attack vector controls for spectre_v2
In reply to David KaplanUse attack vector controls to determine if spectre_v2 mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +6 -4
@@ -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]); }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for spectre_v2
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:10 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +6 -4
@@ -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]); }
PATCH v6 16/21 x86/bugs: Add attack vector controls for L1TF
In reply to David KaplanUse attack vector controls to determine if L1TF mitigation is required.
Disable SMT if cross-thread protection is desired.
--- arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/bugs.c +12 -6
@@ -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 )
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for L1TF
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:11 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/bugs.c +12 -6
@@ -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 )
PATCH v6 17/21 x86/bugs: Add attack vector controls for SRSO
In reply to David KaplanUse attack vector controls to determine if SRSO mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +10 -5
@@ -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 ()) {
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for SRSO
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:12 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +10 -5
@@ -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 ()) {
PATCH v6 18/21 x86/bugs: Add attack vector controls for ITS
In reply to David KaplanUse attack vector controls to determine if ITS mitigation is required.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +10 -5
@@ -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 :
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for ITS
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:13 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/bugs.c +10 -5
@@ -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 :
PATCH v6 19/21 x86/pti: Add attack vector controls for PTI
In reply to David KaplanDisable PTI mitigation if user->kernel attack vector mitigations are disabled.
--- arch/x86/mm/pti.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/mm/pti.c +3 -1
@@ -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." );
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/pti: Add attack vector controls for PTI
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:14 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/mm/pti.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/mm/pti.c +3 -1
@@ -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." );
PATCH v6 20/21 x86/bugs: Print enabled attack vectors
In reply to David KaplanPrint 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.
--- arch/x86/kernel/cpu/bugs.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/x86/kernel/cpu/bugs.c +35 -0
@@ -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 ();
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Print enabled attack vectors
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Mon, 07 Jul 2025 13:33:15 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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.
--- arch/x86/kernel/cpu/bugs.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/x86/kernel/cpu/bugs.c +35 -0
@@ -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 ();
PATCH v6 21/21 cpu: Show attack vectors in sysfs
In reply to David KaplanShow the status of currently mitigated attack vectors in /sys/devices/system/cpu/vector_mitigations/.
--- drivers/base/cpu.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/base/cpu.c +67 -0
@@ -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); } }
Signature · 1 line
2.34.1
Borislav Petkov
maintainerRe: [PATCH v6 21/21] cpu: Show attack vectors in sysfs
Quoted 2 lines · David Kaplan
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.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquettePATCH v7 19/22 x86/bugs: Add attack vector controls for TSA
In reply to David KaplanUse attack vector controls to determine which TSA mitigation to use.
--- arch/x86/kernel/cpu/bugs.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +18 -8
@@ -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]); }
Signature · 1 line
2.34.1
[tip: x86/bugs] x86/bugs: Add attack vector controls for TSA
The following commit has been merged into the x86/bugs branch of tip:
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 <[email protected]> AuthorDate: Wed, 09 Jul 2025 10:58:44 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> 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. ]
--- arch/x86/kernel/cpu/bugs.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +23 -8
@@ -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]); }