TAA v2 0
Subsystems (6)
cover TAA v2 0
From: Borislav Petkov <[email protected]>
Subject: [PATCH 0/9] TAA v2
Hi,
lemme send the pile out one more time before I leave for OSS EU in Lyon. Patch 6 is still there until Paolo and Tony have figured out what should happen with guests.
changelog:
==========
v1:
here's the pile I've picked up. I've incorporated as much of the feedback as possible, scream loudly if something's missing. First testing looks good.
We'll cast them in stone in the coming days because distros and stable have to start backporting soon. All fixes will go ontop, as in previous occasions.
Michal Hocko (1):
x86/tsx: Add config options to set tsx=on|off|auto
Pawan Gupta (8):
x86/msr: Add the IA32_TSX_CTRL MSR
x86/cpu: Add a helper function x86_read_arch_cap_msr() x86/cpu: Add a "tsx=" cmdline option with TSX disabled by default x86/speculation/taa: Add mitigation for TSX Async Abort x86/speculation/taa: Add sysfs reporting for TSX Async Abort kvm/x86: Export MDS_NO=0 to guests when TSX is enabled x86/tsx: Add "auto" option to the tsx= cmdline parameter x86/speculation/taa: Add documentation for TSX Async Abort
.../ABI/testing/sysfs-devices-system-cpu | 1 + Documentation/admin-guide/hw-vuln/index.rst | 1 + .../admin-guide/hw-vuln/tsx_async_abort.rst | 276 ++++++++++++++++++ .../admin-guide/kernel-parameters.txt | 67 +++++ Documentation/x86/index.rst | 1 + Documentation/x86/tsx_async_abort.rst | 117 ++++++++ arch/x86/Kconfig | 45 +++ arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 9 + arch/x86/include/asm/nospec-branch.h | 4 +- arch/x86/include/asm/processor.h | 7 + arch/x86/kernel/cpu/Makefile | 2 +- arch/x86/kernel/cpu/bugs.c | 131 +++++++++ arch/x86/kernel/cpu/common.c | 32 +- arch/x86/kernel/cpu/cpu.h | 18 ++ arch/x86/kernel/cpu/intel.c | 5 + arch/x86/kernel/cpu/tsx.c | 140 +++++++++ arch/x86/kvm/x86.c | 19 ++ drivers/base/cpu.c | 9 + include/linux/cpu.h | 3 + 20 files changed, 881 insertions(+), 7 deletions(-) create mode 100644 Documentation/admin-guide/hw-vuln/tsx_async_abort.rst create mode 100644 Documentation/x86/tsx_async_abort.rst create mode 100644 arch/x86/kernel/cpu/tsx.c
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 1/9 TAA v2 1
From: Pawan Gupta <[email protected]>
Subject: [PATCH 1/9] x86/msr: Add the IA32_TSX_CTRL MSR
Transactional Synchronization Extensions (TSX) may be used on certain processors as part of a speculative side channel attack. A microcode update for existing processors that are vulnerable to this attack will add a new MSR - IA32_TSX_CTRL to allow the system administrator the option to disable TSX as one of the possible mitigations.
The CPUs which get this new MSR after a microcode upgrade are the ones which do not set MSR_IA32_ARCH_CAPABILITIES.MDS_NO (bit 5) because those CPUs have CPUID.MD_CLEAR, i.e., the VERW implementation which clears all CPU buffers takes care of the TAA case as well.
[ Note that future processors that are not vulnerable will also
support the IA32_TSX_CTRL MSR. ]
Add defines for the new IA32_TSX_CTRL MSR and its bits.
TSX has two sub-features:
1. Restricted Transactional Memory (RTM) is an explicitly-used feature where new instructions begin and end TSX transactions.
2. Hardware Lock Elision (HLE) is implicitly used when certain kinds of "old" style locks are used by software.
Bit 7 of the IA32_ARCH_CAPABILITIES indicates the presence of the IA32_TSX_CTRL MSR.
There are two control bits in IA32_TSX_CTRL MSR:
Bit 0: When set, it disables the Restricted Transactional Memory (RTM)
sub-feature of TSX (will force all transactions to abort on the XBEGIN instruction).
Bit 1: When set, it disables the enumeration of the RTM and HLE feature
(i.e. it will make CPUID(EAX=7).EBX{bit4} and
CPUID(EAX=7).EBX{bit11} read as 0).
The other TSX sub-feature, Hardware Lock Elision (HLE), is unconditionally disabled by the new microcode but still enumerated as present by CPUID(EAX=7).EBX{bit4}, unless disabled by IA32_TSX_CTRL_MSR[1] - TSX_CTRL_CPUID_CLEAR.
--- arch/x86/include/asm/msr-index.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/include/asm/msr-index.h +5 -0
@@ -93,6 +93,7 @@* Microarchitectural Data * Sampling (MDS) vulnerabilities. */ +#define ARCH_CAP_TSX_CTRL_MSR BIT(7)/* MSR for TSX control is available. */ #define MSR_IA32_FLUSH_CMD 0x0000010b#define L1D_FLUSH BIT(0)/*
@@ -103,6 +104,10 @@#define MSR_IA32_BBL_CR_CTL 0x00000119#define MSR_IA32_BBL_CR_CTL3 0x0000011e +#define MSR_IA32_TSX_CTRL 0x00000122 +#define TSX_CTRL_RTM_DISABLE BIT(0)/* Disable RTM feature */ +#define TSX_CTRL_CPUID_CLEAR BIT(1)/* Disable TSX enumeration */ +#define MSR_IA32_SYSENTER_CS 0x00000174#define MSR_IA32_SYSENTER_ESP 0x00000175#define MSR_IA32_SYSENTER_EIP 0x00000176
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 2/9 TAA v2 2
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 2/9] x86/cpu: Add a helper function x86_read_arch_cap_msr()
Add a helper function to read the IA32_ARCH_CAPABILITIES MSR.
--- arch/x86/kernel/cpu/common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/common.c +11 -4
@@ -1092,19 +1092,26 @@ static bool __init cpu_matches(unsigned long which)return m && !!(m->driver_data & which); } -static void __init cpu_set_bug_bits (struct cpuinfo_x86 *c) +u64 x86_read_arch_cap_msr (void ) {u64 ia32_cap =0 ; +if (boot_cpu_has (X86_FEATURE_ARCH_CAPABILITIES )) +rdmsrl (MSR_IA32_ARCH_CAPABILITIES , ia32_cap); + +return ia32_cap; +} + +static void __init cpu_set_bug_bits (struct cpuinfo_x86 *c) +{ +u64 ia32_cap =x86_read_arch_cap_msr (); +if (cpu_matches (NO_SPECULATION ))return ;setup_force_cpu_bug (X86_BUG_SPECTRE_V1 );setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); -if (cpu_has (c,X86_FEATURE_ARCH_CAPABILITIES )) -rdmsrl (MSR_IA32_ARCH_CAPABILITIES , ia32_cap); -if (!cpu_matches (NO_SSB ) && !(ia32_cap &ARCH_CAP_SSB_NO ) && !cpu_has (c,X86_FEATURE_AMD_SSB_NO ))setup_force_cpu_bug (X86_BUG_SPEC_STORE_BYPASS );
Signature · 1 line
2.21.0
Re: [PATCH 2/9] TAA v2 2
arch/x86/kernel/cpu/common.c static bool __init cpu_matches(unsigned long which) · line 1095
Quoted 6 lines · speck for Pawan Gupta
--- arch/x86/kernel/cpu/common.c | 15 +++++++++++----arch/x86/kernel/cpu/common.c +1
-1-static void __init cpu_set_bug_bits (struct cpuinfo_x86 *c) +u64 x86_read_arch_cap_msr (void )
Where is the declaration of this? In the next patch ....
Oh well.
Pawan Gupta
reviewerPATCH 3/9 TAA v2 3
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default
Add a kernel cmdline parameter "tsx" to control the Transactional Synchronization Extensions (TSX) feature. On CPUs that support TSX control, use "tsx=on|off" to enable or disable TSX. Not specifying this option is equivalent to "tsx=off". This is because on certain processors TSX may be used as a part of a speculative side channel attack.
Carve out the TSX controlling functionality into a separate compilation unit because TSX is a CPU feature while the TSX async abort control machinery will go to cpu/bugs.c.
[ bp: - Massage, shorten and clear the arg buffer.
- Clarifications of the tsx= possible options - Josh.
- Expand on TSX_CTRL availability - Pawan. ]
--- .../admin-guide/kernel-parameters.txt | 26 ++++ arch/x86/kernel/cpu/Makefile | 2 +- arch/x86/kernel/cpu/common.c | 2 + arch/x86/kernel/cpu/cpu.h | 18 +++ arch/x86/kernel/cpu/intel.c | 5 + arch/x86/kernel/cpu/tsx.c | 125 ++++++++++++++++++ 6 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 arch/x86/kernel/cpu/tsx.c
Documentation/admin-guide/kernel-parameters.txt +26 -0
@@ -4848,6 +4848,32 @@ interruptions from clocksource watchdog are not acceptable). + tsx= [X86] Control Transactional Synchronization + Extensions (TSX) feature in Intel processors that + support TSX control. + + This parameter controls the TSX feature. The options are: + + on - Enable TSX on the system. Although there are + mitigations for all known security vulnerabilities, + TSX has been known to be an accelerator for + several previous speculation-related CVEs, and + so there may be unknown security risks associated + with leaving it enabled. + + off - Disable TSX on the system. (Note that this + option takes effect only on newer CPUs which are + not vulnerable to MDS, i.e., have + MSR_IA32_ARCH_CAPABILITIES.MDS_NO=1 and which get + the new IA32_TSX_CTRL MSR through a microcode + update. This new MSR allows for the reliable + deactivation of the TSX functionality.) + + Not specifying this option is equivalent to tsx=off. + + See Documentation/admin-guide/hw-vuln/tsx_async_abort.rst + for more details. + turbografx.map[2|3]= [HW,JOY] TurboGraFX parallel port interface Format:
arch/x86/kernel/cpu/Makefile +1 -1
@@ -30,7 +30,7 @@ obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o ifdef CONFIG_CPU_SUP_INTEL -obj-y += intel.o intel_pconfig.o +obj-y += intel.o intel_pconfig.o tsx.o obj-$(CONFIG_PM) += intel_epb.o endif obj-$(CONFIG_CPU_SUP_AMD) += amd.o
arch/x86/kernel/cpu/common.c +2 -0
@@ -1561,6 +1561,8 @@ void __init identify_boot_cpu(void)#endif cpu_detect_tlb (&boot_cpu_data);setup_cr_pinning (); + +tsx_init (); }void identify_secondary_cpu (struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/cpu.h +18 -0
@@ -44,6 +44,22 @@ struct _tlb_table {extern const struct cpu_dev *const __x86_cpu_dev_start[], *const __x86_cpu_dev_end[]; +#ifdef CONFIG_CPU_SUP_INTEL +enum tsx_ctrl_states { +TSX_CTRL_ENABLE , +TSX_CTRL_DISABLE , +TSX_CTRL_NOT_SUPPORTED , +}; + +extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state; + +extern void __init tsx_init (void ); +extern void tsx_enable (void ); +extern void tsx_disable (void ); +#else +static inline void tsx_init (void ) { } +#endif /* CONFIG_CPU_SUP_INTEL */ +extern void get_cpu_cap (struct cpuinfo_x86 *c);extern void get_cpu_address_sizes (struct cpuinfo_x86 *c);extern void cpu_detect_cache_sizes (struct cpuinfo_x86 *c);
@@ -62,4 +78,6 @@ unsigned int aperfmperf_get_khz(int cpu);extern void x86_spec_ctrl_setup_ap (void ); +extern u64 x86_read_arch_cap_msr (void ); +#endif /* ARCH_X86_CPU_H */
arch/x86/kernel/cpu/intel.c +5 -0
@@ -762,6 +762,11 @@ static void init_intel(struct cpuinfo_x86 *c)detect_tme (c);init_intel_misc_features (c); + +if (tsx_ctrl_state ==TSX_CTRL_ENABLE ) +tsx_enable (); +if (tsx_ctrl_state ==TSX_CTRL_DISABLE ) +tsx_disable (); }#ifdef CONFIG_X86_32
arch/x86/kernel/cpu/tsx.c new file +125 -0
125 lines not on this page · raw message
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 4/9 TAA v2 4
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 4/9] x86/speculation/taa: Add mitigation for TSX Async Abort
TSX Async Abort (TAA) is a side channel vulnerability to the internal buffers in some Intel processors similar to Microachitectural Data Sampling (MDS). In this case, certain loads may speculatively pass invalid data to dependent operations when an asynchronous abort condition is pending in a TSX transaction.
This includes loads with no fault or assist condition. Such loads may speculatively expose stale data from the uarch data structures as in MDS. Scope of exposure is within the same-thread and cross-thread. This issue affects all current processors that support TSX, but do not have ARCH_CAP_TAA_NO (bit 8) set in MSR_IA32_ARCH_CAPABILITIES.
On CPUs which have their IA32_ARCH_CAPABILITIES MSR bit MDS_NO=0, CPUID.MD_CLEAR=1 and the MDS mitigation is clearing the CPU buffers using VERW or L1D_FLUSH, there is no additional mitigation needed for TAA. On affected CPUs with MDS_NO=1 this issue can be mitigated by disabling the Transactional Synchronization Extensions (TSX) feature.
A new MSR IA32_TSX_CTRL in future and current processors after a microcode update can be used to control the TSX feature. There are two bits in that MSR:
* TSX_CTRL_RTM_DISABLE disables the TSX sub-feature Restricted Transactional Memory (RTM).
* TSX_CTRL_CPUID_CLEAR clears the RTM enumeration in CPUID. The other TSX sub-feature, Hardware Lock Elision (HLE), is unconditionally disabled with updated microcode but still enumerated as present by CPUID(EAX=7).EBX{bit4}.
The second mitigation approach is similar to MDS which is clearing the affected CPU buffers on return to user space and when entering a guest. Relevant microcode update is required for the mitigation to work. More details on this approach can be found here:
https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html
The TSX feature can be controlled by the "tsx" command line parameter. If it is force-enabled then "Clear CPU buffers" (MDS mitigation) is deployed. The effective mitigation state can be read from sysfs.
[ bp:
- massage + comments cleanup
- s/TAA_MITIGATION_TSX_DISABLE/TAA_MITIGATION_TSX_DISABLED/g - Josh.
- remove partial TAA mitigation in update_mds_branch_idle() - Josh.
- s/tsx_async_abort_cmdline/tsx_async_abort_parse_cmdline/g
]
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 4 + arch/x86/include/asm/nospec-branch.h | 4 +- arch/x86/include/asm/processor.h | 7 ++ arch/x86/kernel/cpu/bugs.c | 108 +++++++++++++++++++++++++++ arch/x86/kernel/cpu/common.c | 15 ++++ 6 files changed, 137 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -399,5 +399,6 @@#define X86_BUG_MDS X86_BUG(19)/* CPU is affected by Microarchitectural data sampling */ #define X86_BUG_MSBDS_ONLY X86_BUG(20)/* CPU is only affected by the MSDBS variant of BUG_MDS */ #define X86_BUG_SWAPGS X86_BUG(21)/* CPU is affected by speculation through SWAPGS */ +#define X86_BUG_TAA X86_BUG(22)/* CPU is affected by TSX Async Abort(TAA) */ #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/include/asm/msr-index.h +4 -0
@@ -94,6 +94,10 @@* Sampling (MDS) vulnerabilities. */ #define ARCH_CAP_TSX_CTRL_MSR BIT(7)/* MSR for TSX control is available. */ +#define ARCH_CAP_TAA_NO BIT(8)/* +* Not susceptible to +* TSX Async Abort (TAA) vulnerabilities. +*/ #define MSR_IA32_FLUSH_CMD 0x0000010b#define L1D_FLUSH BIT(0)/*
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -314,7 +314,7 @@ DECLARE_STATIC_KEY_FALSE(mds_idle_clear);#include <asm/segment.h> /** -* mds_clear_cpu_buffers - Mitigation for MDS vulnerability +* mds_clear_cpu_buffers - Mitigation for MDS and TAA vulnerability * * This uses the otherwise unused and obsolete VERW instruction in * combination with microcode which triggers a CPU buffer flush when the
@@ -337,7 +337,7 @@ static inline void mds_clear_cpu_buffers(void) }/** -* mds_user_clear_cpu_buffers - Mitigation for MDS vulnerability +* mds_user_clear_cpu_buffers - Mitigation for MDS and TAA vulnerability * * Clear CPU buffers if the corresponding static key is enabled */
arch/x86/include/asm/processor.h +7 -0
@@ -988,4 +988,11 @@ enum mds_mitigations { MDS_MITIGATION_VMWERV, }; +enum taa_mitigations { +TAA_MITIGATION_OFF , +TAA_MITIGATION_UCODE_NEEDED , +TAA_MITIGATION_VERW , +TAA_MITIGATION_TSX_DISABLED , +}; +#endif /* _ASM_X86_PROCESSOR_H */
arch/x86/kernel/cpu/bugs.c +108 -0
138 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +15 -0
@@ -1128,6 +1128,21 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)if (!cpu_matches (NO_SWAPGS ))setup_force_cpu_bug (X86_BUG_SWAPGS ); +/* +* When the CPU is not mitigated for TAA (TAA_NO=0) set TAA bug when: +* - TSX is supported or +* - TSX_CTRL is present +* +* TSX_CTRL check is needed for cases when TSX could be disabled before +* the kernel boot e.g. kexec. +* TSX_CTRL check alone is not sufficient for cases when the microcode +* update is not present or running as guest that don't get TSX_CTRL. +*/ +if (!(ia32_cap &ARCH_CAP_TAA_NO ) && + (cpu_has (c,X86_FEATURE_RTM ) || + (ia32_cap &ARCH_CAP_TSX_CTRL_MSR ))) +setup_force_cpu_bug (X86_BUG_TAA ); +if (cpu_matches (NO_MELTDOWN ))return ;
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 5/9 TAA v2 5
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 5/9] x86/speculation/taa: Add sysfs reporting for TSX Async
Abort
Add the sysfs reporting file for TSX Async Abort. It exposes the vulnerability and the mitigation state similar to the existing files for the other hardware vulnerabilities.
Sysfs file path is:/sys/devices/system/cpu/vulnerabilities/tsx_async_abort
--- arch/x86/kernel/cpu/bugs.c | 23 +++++++++++++++++++++++ drivers/base/cpu.c | 9 +++++++++ include/linux/cpu.h | 3 +++ 3 files changed, 35 insertions(+)
arch/x86/kernel/cpu/bugs.c +23 -0
@@ -1436,6 +1436,21 @@ static ssize_t mds_show_state(char *buf) sched_smt_active() ? "vulnerable" : "disabled"); } +static ssize_t tsx_async_abort_show_state (char *buf) +{ +if ((taa_mitigation ==TAA_MITIGATION_TSX_DISABLED ) || + (taa_mitigation ==TAA_MITIGATION_OFF )) +return sprintf (buf,"%s\n" , taa_strings[taa_mitigation]); + +if (boot_cpu_has (X86_FEATURE_HYPERVISOR )) { +return sprintf (buf,"%s; SMT Host state unknown\n" , + taa_strings[taa_mitigation]); + } + +return sprintf (buf,"%s; SMT %s\n" , taa_strings[taa_mitigation], +sched_smt_active () ?"vulnerable" :"disabled" ); +} +static char *stibp_state (void ) {if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )
@@ -1506,6 +1521,9 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attrcase X86_BUG_MDS :return mds_show_state (buf); +case X86_BUG_TAA : +return tsx_async_abort_show_state (buf); +default :break ; }
@@ -1542,4 +1560,9 @@ ssize_t cpu_show_mds(struct device *dev, struct device_attribute *attr, char *bu {return cpu_show_common (dev, attr, buf,X86_BUG_MDS ); } + +ssize_t cpu_show_tsx_async_abort (struct device *dev,struct device_attribute *attr,char *buf) +{ +return cpu_show_common (dev, attr, buf,X86_BUG_TAA ); +}#endif
drivers/base/cpu.c +9 -0
@@ -554,12 +554,20 @@ ssize_t __weak cpu_show_mds(struct device *dev,return sprintf (buf,"Not affected\n" ); } +ssize_t __weak cpu_show_tsx_async_abort (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +return sprintf (buf,"Not affected\n" ); +} + static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL); static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL); static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL); static DEVICE_ATTR(spec_store_bypass, 0444, cpu_show_spec_store_bypass, NULL); static DEVICE_ATTR(l1tf, 0444, cpu_show_l1tf, NULL); static DEVICE_ATTR(mds, 0444, cpu_show_mds, NULL); +static DEVICE_ATTR(tsx_async_abort, 0444, cpu_show_tsx_async_abort, NULL);static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_meltdown.attr,
@@ -568,6 +576,7 @@ static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_spec_store_bypass.attr, &dev_attr_l1tf.attr, &dev_attr_mds.attr, + &dev_attr_tsx_async_abort.attr, NULL };
include/linux/cpu.h +3 -0
@@ -59,6 +59,9 @@ extern ssize_t cpu_show_l1tf(struct device *dev, struct device_attribute *attr, char *buf);extern ssize_t cpu_show_mds (struct device *dev,struct device_attribute *attr,char *buf); +extern ssize_t cpu_show_tsx_async_abort (struct device *dev, +struct device_attribute *attr, +char *buf); extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata,
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 6/9 TAA v2 6
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 6/9] kvm/x86: Export MDS_NO=0 to guests when TSX is enabled
Export the IA32_ARCH_CAPABILITIES MSR bit MDS_NO=0 to guests on TSX Async Abort(TAA) affected hosts that have TSX enabled and updated microcode. This is required so that the guests don't complain,
"Vulnerable: Clear CPU buffers attempted, no microcode"
when the host has the updated microcode to clear CPU buffers.
Microcode update also adds support for MSR_IA32_TSX_CTRL which is enumerated by the ARCH_CAP_TSX_CTRL bit in IA32_ARCH_CAPABILITIES MSR. Guests can't do this check themselves when the ARCH_CAP_TSX_CTRL bit is not exported to the guests.
In this case export MDS_NO=0 to the guests. When guests have CPUID.MD_CLEAR=1, they deploy MDS mitigation which also mitigates TAA.
--- arch/x86/kvm/x86.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/x86/kvm/x86.c +19 -0
@@ -1299,6 +1299,25 @@ static u64 kvm_get_arch_capabilities(void)if (!boot_cpu_has_bug (X86_BUG_MDS )) data |=ARCH_CAP_MDS_NO ; +/* +* On TAA affected systems, export MDS_NO=0 when: +* - TSX is enabled on the host, i.e. X86_FEATURE_RTM=1. +* - Updated microcode is present. This is detected by +* the presence of ARCH_CAP_TSX_CTRL_MSR and ensures +* that VERW clears CPU buffers. +* +* When MDS_NO=0 is exported, guests deploy clear CPU buffer +* mitigation and don't complain: +* +* "Vulnerable: Clear CPU buffers attempted, no microcode" +* +* If TSX is disabled on the system, guests are also mitigated against +* TAA and clear CPU buffer mitigation is not required for guests. +*/ +if (boot_cpu_has_bug (X86_BUG_TAA ) &&boot_cpu_has (X86_FEATURE_RTM ) && + (data &ARCH_CAP_TSX_CTRL_MSR )) + data &= ~ARCH_CAP_MDS_NO ; +return data; }
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 7/9 TAA v2 7
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 7/9] x86/tsx: Add "auto" option to the tsx= cmdline parameter
Platforms which are not affected by X86_BUG_TAA may want the TSX feature enabled. Add "auto" option to the TSX cmdline parameter. When tsx=auto disable TSX when X86_BUG_TAA is present, otherwise enable TSX.
More details on X86_BUG_TAA can be found here:
https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html
[ bp: Extend the arg buffer to accommodate "auto\0". ]
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/kernel/cpu/tsx.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -4869,6 +4869,9 @@ update. This new MSR allows for the reliable deactivation of the TSX functionality.) + auto - Disable TSX if X86_BUG_TAA is present, + otherwise enable TSX on the system. + Not specifying this option is equivalent to tsx=off. See Documentation/admin-guide/hw-vuln/tsx_async_abort.rst
arch/x86/kernel/cpu/tsx.c +6 -1
@@ -75,7 +75,7 @@ static bool __init tsx_ctrl_is_supported(void)void __init tsx_init (void ) { -char arg[4 ] = {}; +char arg[5 ] = {};int ret;if (!tsx_ctrl_is_supported ())
@@ -87,6 +87,11 @@ void __init tsx_init(void) tsx_ctrl_state =TSX_CTRL_ENABLE ; }else if (!strcmp (arg,"off" )) { tsx_ctrl_state =TSX_CTRL_DISABLE ; + }else if (!strcmp (arg,"auto" )) { +if (boot_cpu_has_bug (X86_BUG_TAA )) + tsx_ctrl_state =TSX_CTRL_DISABLE ; +else + tsx_ctrl_state =TSX_CTRL_ENABLE ; }else { tsx_ctrl_state =TSX_CTRL_DISABLE ;pr_err ("tsx: invalid option, defaulting to off\n" );
Signature · 1 line
2.21.0
Pawan Gupta
reviewerPATCH 8/9 TAA v2 8
In reply to Borislav PetkovFrom: Pawan Gupta <[email protected]>
Subject: [PATCH 8/9] x86/speculation/taa: Add documentation for TSX Async
Abort
Add the documenation for TSX Async Abort. Include the description of the issue, how to check the mitigation state, control the mitigation, guidance for system administrators.
[ bp: Add proper SPDX tags, touch ups by Josh and me. ]
--- .../ABI/testing/sysfs-devices-system-cpu | 1 + Documentation/admin-guide/hw-vuln/index.rst | 1 + .../admin-guide/hw-vuln/tsx_async_abort.rst | 276 ++++++++++++++++++ .../admin-guide/kernel-parameters.txt | 38 +++ Documentation/x86/index.rst | 1 + Documentation/x86/tsx_async_abort.rst | 117 ++++++++ 6 files changed, 434 insertions(+) create mode 100644 Documentation/admin-guide/hw-vuln/tsx_async_abort.rst create mode 100644 Documentation/x86/tsx_async_abort.rst
Documentation/ABI/testing/sysfs-devices-system-cpu +1 -0
@@ -486,6 +486,7 @@ What: /sys/devices/system/cpu/vulnerabilities /sys/devices/system/cpu/vulnerabilities/spec_store_bypass /sys/devices/system/cpu/vulnerabilities/l1tf /sys/devices/system/cpu/vulnerabilities/mds + /sys/devices/system/cpu/vulnerabilities/tsx_async_abort Date: January 2018 Contact: Linux kernel mailing list <[email protected]> Description: Information about CPU vulnerabilities
Documentation/admin-guide/hw-vuln/index.rst +1 -0
@@ -12,3 +12,4 @@ are configurable at compile, boot or run time. spectre l1tf mds + tsx_async_abort
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +276 -0
276 lines not on this page · raw message
Documentation/admin-guide/kernel-parameters.txt +38 -0
@@ -2636,6 +2636,7 @@ ssbd=force-off [ARM64] l1tf=off [X86] mds=off [X86] + tsx_async_abort=off [X86] auto (default) Mitigate all CPU vulnerabilities, but leave SMT
@@ -2651,6 +2652,7 @@ be fully mitigated, even if it means losing SMT. Equivalent to: l1tf=flush,nosmt [X86] mds=full,nosmt [X86] + tsx_async_abort=full,nosmt [X86] mminit_loglevel= [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
@@ -4877,6 +4879,42 @@ See Documentation/admin-guide/hw-vuln/tsx_async_abort.rst for more details. + tsx_async_abort= [X86,INTEL] Control mitigation for the TSX Async + Abort (TAA) vulnerability. + + Similar to Micro-architectural Data Sampling (MDS) + certain CPUs that support Transactional + Synchronization Extensions (TSX) are vulnerable to an + exploit against CPU internal buffers which can forward + information to a disclosure gadget under certain + conditions. + + In vulnerable processors, the speculatively forwarded + data can be used in a cache side channel attack, to + access data to which the attacker does not have direct + access. + + This parameter controls the TAA mitigation. The + options are: + + full - Enable TAA mitigation on vulnerable CPUs + if TSX is enabled. + + full,nosmt - Enable TAA mitigation and disable SMT on + vulnerable CPUs. If TSX is disabled, SMT + is not disabled because CPU is not + vulnerable to cross-thread TAA attacks. + off - Unconditionally disable TAA mitigation + + Not specifying this option is equivalent to + tsx_async_abort=full. On CPUs which are MDS affected + and deploy MDS mitigation, TAA mitigation is not + required and doesn't provide any additional + mitigation. + + For details see: + Documentation/admin-guide/hw-vuln/tsx_async_abort.rst + turbografx.map[2|3]= [HW,JOY] TurboGraFX parallel port interface Format:
Documentation/x86/index.rst +1 -0
@@ -27,6 +27,7 @@ x86-specific Documentation mds microcode resctrl_ui + tsx_async_abort usb-legacy-support i386/index x86_64/index
Documentation/x86/tsx_async_abort.rst new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 9/9 TAA v2 9
In reply to Borislav PetkovFrom: Michal Hocko <[email protected]>
Subject: [PATCH 9/9] x86/tsx: Add config options to set tsx=on|off|auto
There is a general consensus that TSX usage is not largely spread while the history shows there is a non trivial space for side channel attacks possible. Therefore the tsx is disabled by default even on platforms that might have a safe implementation of TSX according to the current knowledge. This is a fair trade off to make.
There are, however, workloads that really do benefit from using TSX and updating to a newer kernel with TSX disabled might introduce a noticeable regressions. This would be especially a problem for Linux distributions which will provide TAA mitigations.
Introduce config options X86_INTEL_TSX_MODE_OFF, X86_INTEL_TSX_MODE_ON and X86_INTEL_TSX_MODE_AUTO to control the TSX feature. The config setting can be overridden by the tsx cmdline options.
[ bp: Text cleanups from Josh. ]
--- arch/x86/Kconfig | 45 +++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/tsx.c | 22 +++++++++++++------ 2 files changed, 61 insertions(+), 6 deletions(-)
arch/x86/Kconfig +45 -0
@@ -1940,6 +1940,51 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS If unsure, say y. +choice + prompt "TSX enable mode" + depends on CPU_SUP_INTEL + default X86_INTEL_TSX_MODE_OFF + help + Intel's TSX (Transactional Synchronization Extensions) feature + allows to optimize locking protocols through lock elision which + can lead to a noticeable performance boost. + + On the other hand it has been shown that TSX can be exploited + to form side channel attacks (e.g. TAA) and chances are there + will be more of those attacks discovered in the future. + + Therefore TSX is not enabled by default (aka tsx=off). An admin + might override this decision by tsx=on the command line parameter. + Even with TSX enabled, the kernel will attempt to enable the best + possible TAA mitigation setting depending on the microcode available + for the particular machine. + + This option allows to set the default tsx mode between tsx=on, =off + and =auto. See Documentation/admin-guide/kernel-parameters.txt for more + details. + + Say off if not sure, auto if TSX is in use but it should be used on safe + platforms or on if TSX is in use and the security aspect of tsx is not + relevant. + +config X86_INTEL_TSX_MODE_OFF + bool "off" + help + TSX is disabled if possible - equals to tsx=off command line parameter. + +config X86_INTEL_TSX_MODE_ON + bool "on" + help + TSX is always enabled on TSX capable HW - equals the tsx=on command + line parameter. + +config X86_INTEL_TSX_MODE_AUTO + bool "auto" + help + TSX is enabled on TSX capable HW that is believed to be safe against + side channel attacks- equals the tsx=auto command line parameter. +endchoice + config EFI bool "EFI runtime service support" depends on ACPI
arch/x86/kernel/cpu/tsx.c +16 -6
@@ -73,6 +73,14 @@ static bool __init tsx_ctrl_is_supported(void)return !!(ia32_cap &ARCH_CAP_TSX_CTRL_MSR ); } +static enum tsx_ctrl_states x86_get_tsx_auto_mode (void ) +{ +if (boot_cpu_has_bug (X86_BUG_TAA )) +return TSX_CTRL_DISABLE ; + +return TSX_CTRL_ENABLE ; +} +void __init tsx_init (void ) {char arg[5 ] = {};
@@ -88,17 +96,19 @@ void __init tsx_init(void) }else if (!strcmp (arg,"off" )) { tsx_ctrl_state =TSX_CTRL_DISABLE ; }else if (!strcmp (arg,"auto" )) { -if (boot_cpu_has_bug (X86_BUG_TAA )) - tsx_ctrl_state =TSX_CTRL_DISABLE ; -else - tsx_ctrl_state =TSX_CTRL_ENABLE ; + tsx_ctrl_state =x86_get_tsx_auto_mode (); }else { tsx_ctrl_state =TSX_CTRL_DISABLE ;pr_err ("tsx: invalid option, defaulting to off\n" ); } }else { -/* tsx= not provided, defaulting to off */ - tsx_ctrl_state =TSX_CTRL_DISABLE ; +/* tsx= not provided */ +if (IS_ENABLED (CONFIG_X86_INTEL_TSX_MODE_AUTO )) + tsx_ctrl_state =x86_get_tsx_auto_mode (); +else if (IS_ENABLED (CONFIG_X86_INTEL_TSX_MODE_OFF )) + tsx_ctrl_state =TSX_CTRL_DISABLE ; +else + tsx_ctrl_state =TSX_CTRL_ENABLE ; }if (tsx_ctrl_state ==TSX_CTRL_DISABLE ) {
Signature · 1 line
2.21.0