Skip to contentSkip to conversation

TAA 0

PATCH New Borislav Petkov 8 participants 75 messages Oct 24, 2019 – Nov 1, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover TAA 0

From: Borislav Petkov <[email protected]>
Subject: [PATCH 0/9] TAA

Hi,

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.

Thx.

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   | 256 ++++++++++++++++++
 .../admin-guide/kernel-parameters.txt         |  52 ++++
 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                    | 133 +++++++++
 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                     | 134 +++++++++
 arch/x86/kvm/x86.c                            |  19 ++
 drivers/base/cpu.c                            |   9 +
 include/linux/cpu.h                           |   3 +
 20 files changed, 842 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
reviewer
#1 lore raw

PATCH 1/9 TAA 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.

[ 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 but still enumerated as present by CPUID(EAX=7).EBX{bit4}.

---
 arch/x86/include/asm/msr-index.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/include/asm/msr-index.h +5 -0
index 20ce682a2540..da4caf6da739 100644
@@ -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
#2 lore raw

[MODERATED] Re: [PATCH 1/9] TAA 1

Quoted 8 lines · speck for Pawan Gupta

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.

This should clarify that not *all* TAA-vulnerable CPUs will get IA32_TSX_CTRL, instead only the ones which aren't also vulnerable to MDS.

Quoted 21 lines

[ 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).

Quoted 6 lines

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 ...

Quoted 2 lines

but still enumerated as present by
CPUID(EAX=7).EBX{bit4}.

... unless disabled by bit 1 of IA32_TSX_CTRL_MSR.

Signature · 1 line
Josh
#3 lore raw

[MODERATED] Re: [PATCH 1/9] TAA 1

Quoted 3 lines · speck for Josh Poimboeuf

This should clarify that not *all* TAA-vulnerable CPUs will get IA32_TSX_CTRL, instead only the ones which aren't also vulnerable to MDS.

Added:

"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."

Hopefully that makes it more clear.

Quoted 9 lines
Quoted 2 lines

The other TSX sub-feature, Hardware Lock Elision (HLE), is unconditionally disabled

... by the new microcode ...

Quoted 2 lines

but still enumerated as present by
CPUID(EAX=7).EBX{bit4}.

... unless disabled by bit 1 of IA32_TSX_CTRL_MSR.

Changed it to:

"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."

Thx.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#4 lore raw

[MODERATED] Re: [PATCH 1/9] TAA 1

Quoted 22 lines · speck for Borislav Petkov
Quoted 3 lines · speck for Josh Poimboeuf

This should clarify that not *all* TAA-vulnerable CPUs will get IA32_TSX_CTRL, instead only the ones which aren't also vulnerable to MDS.

Added:

"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."

Hopefully that makes it more clear.

Quoted 8 lines
Quoted 2 lines

The other TSX sub-feature, Hardware Lock Elision (HLE), is unconditionally disabled

... by the new microcode ...

Quoted 2 lines

but still enumerated as present by
CPUID(EAX=7).EBX{bit4}.

Quoted 8 lines
Quoted 1 line

... unless disabled by bit 1 of IA32_TSX_CTRL_MSR.

Changed it to:

"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."

Sounds good.

Signature · 1 line
Josh
reviewer
#5 lore raw

PATCH 2/9 TAA 2

In reply to Borislav Petkov

From: 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
index 9ae7d1bcd4f4..897c8302d982 100644
@@ -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
reviewer
#6 lore raw

PATCH 3/9 TAA 3

In reply to Borislav Petkov

From: 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. ]

Cc Andrew Morton <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Babu Moger <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Kees Cook <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Rahul Tanwar <[email protected]>
Cc Ricardo Neri <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
Cc Zhao Yakui <[email protected]>
---
 .../admin-guide/kernel-parameters.txt         |  11 ++
 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                     | 119 ++++++++++++++++++
 6 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/kernel/cpu/tsx.c
Documentation/admin-guide/kernel-parameters.txt +11 -0
index a84a83f8881e..ad6b69057bb0 100644
@@ -4848,6 +4848,17 @@
 			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.
+			off	- Disable TSX on the system.
+
+			Not specifying this option is equivalent to tsx=off.
+
 	turbografx.map[2|3]=	[HW,JOY]
 			TurboGraFX parallel port interface
 			Format:
arch/x86/kernel/cpu/Makefile +1 -1
index d7a1e5a9331c..890f60083eca 100644
@@ -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
index 897c8302d982..885d4ac2111a 100644
@@ -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
index c0e2407abdd6..38ab6e115eac 100644
@@ -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
index c2fdc00df163..11d5c5950e2d 100644
@@ -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 +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.21.0
#7 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 6 lines · speck for Pawan Gupta
Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -4848,6 +4848,17 @@
 			interruptions from clocksource watchdog are not
 			acceptable).
 

Documentation/admin-guide/kernel-parameters.txt line 4860

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10 -0
+	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.
+			off	- Disable TSX on the system.
+
+			Not specifying this option is equivalent to tsx=off.

This still needs details about when 'tsx=off' does and doesn't work.

The above makes it sound like it's off for all CPUs, when in fact it's only off for newer MDS_NO CPUs.

It should also perhaps describe the risks associated with tsx=on. While there are mitigations for all known issues (i.e., the tsx_async_abort= option), 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.

Signature · 1 line
Josh
#8 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 4 lines · speck for Josh Poimboeuf

This still needs details about when 'tsx=off' does and doesn't work.

The above makes it sound like it's off for all CPUs, when in fact it's only off for newer MDS_NO CPUs.

How does that sound (and that is being mentioned somewhere in all the text but here it is important to have):

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.)

Quoted 5 lines

It should also perhaps describe the risks associated with tsx=on. While there are mitigations for all known issues (i.e., the tsx_async_abort= option), 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.

You've basically said it nicely already:

"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."

ACK?

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#9 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 23 lines · speck for Borislav Petkov
Quoted 4 lines · speck for Josh Poimboeuf

This still needs details about when 'tsx=off' does and doesn't work.

The above makes it sound like it's off for all CPUs, when in fact it's only off for newer MDS_NO CPUs.

How does that sound (and that is being mentioned somewhere in all the text but here it is important to have):

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.)

Quoted 5 lines

It should also perhaps describe the risks associated with tsx=on. While there are mitigations for all known issues (i.e., the tsx_async_abort= option), 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.

Quoted 8 lines

You've basically said it nicely already:

"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."

ACK?

ACK

Signature · 1 line
Josh
#10 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Pawan Gupta

arch/x86/kernel/cpu/tsx.c line 101

Quoted 9 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/tsx.c new file +9 -0
+	if (tsx_ctrl_state == TSX_CTRL_DISABLE) {
+		tsx_disable();
+
+		/*
+		 * tsx_disable() will change the state of the
+		 * RTM CPUID bit.  Clear it here since it is now
+		 * expected to be not set.
+		 */
+		setup_clear_cpu_cap(X86_FEATURE_RTM);

This same argument applies to HLE, and it would be weird for pre-TSX_CTRL CPUs with tsx=off to report HLE but not RTM in /proc/cpuid

Furthermore, while grepping through the tree, I found

events/intel/lbr.c-267-static inline bool lbr_from_signext_quirk_needed(void)
events/intel/lbr.c-268-{
events/intel/lbr.c-269- int lbr_format = x86_pmu.intel_cap.lbr_format; events/intel/lbr.c:270: bool tsx_support = boot_cpu_has(X86_FEATURE_HLE) || events/intel/lbr.c-271-                    boot_cpu_has(X86_FEATURE_RTM); events/intel/lbr.c-272-
events/intel/lbr.c-273- return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX);

which is going to need an adjustment to avoid applying the quirks on non-broken hardware.

~Andrew

#11 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 13 lines · speck for Andrew Cooper

arch/x86/kernel/cpu/tsx.c line 101

Quoted 9 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/tsx.c new file +9 -0
+	if (tsx_ctrl_state == TSX_CTRL_DISABLE) {
+		tsx_disable();
+
+		/*
+		 * tsx_disable() will change the state of the
+		 * RTM CPUID bit.  Clear it here since it is now
+		 * expected to be not set.
+		 */
+		setup_clear_cpu_cap(X86_FEATURE_RTM);

This same argument applies to HLE, and it would be weird for pre-TSX_CTRL CPUs with tsx=off to report HLE but not RTM in /proc/cpuid

Right, the correct fix for that would be to run tsx_init() before we read CPUID leafs in get_cpu_cap() because then it'll load the proper bits already and we won't have to clear anything - the MSR write would've cleared both CPUID bits already.

I just checked that it happens globally even:

$ ./cpuid -r | grep -E "^\s+0x00000007" | awk '{ print $6 }' | uniq
edx=0xbc000400

Bits 4 (HLE) and 11 (RTM) are cleared on all CPUs.

I'll try this tomorrow to check whether it would even work that early.

If there's issues with it, then we'll have to do the above thing and clear HLE too, by hand.

Quoted 12 lines

Furthermore, while grepping through the tree, I found

events/intel/lbr.c-267-static inline bool lbr_from_signext_quirk_needed(void)
events/intel/lbr.c-268-{
events/intel/lbr.c-269- int lbr_format = x86_pmu.intel_cap.lbr_format; events/intel/lbr.c:270: bool tsx_support = boot_cpu_has(X86_FEATURE_HLE) || events/intel/lbr.c-271-                    boot_cpu_has(X86_FEATURE_RTM); events/intel/lbr.c-272-
events/intel/lbr.c-273- return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX);

Quoted 2 lines

which is going to need an adjustment to avoid applying the quirks on non-broken hardware.

When both HLE and RTM bits are cleared, that should still be correct, no? Or am I missing something?

Signature · 4 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
#12 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 25 lines · speck for Borislav Petkov
Quoted 13 lines · speck for Andrew Cooper

arch/x86/kernel/cpu/tsx.c line 101

Quoted 9 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/tsx.c new file +9 -0
+	if (tsx_ctrl_state == TSX_CTRL_DISABLE) {
+		tsx_disable();
+
+		/*
+		 * tsx_disable() will change the state of the
+		 * RTM CPUID bit.  Clear it here since it is now
+		 * expected to be not set.
+		 */
+		setup_clear_cpu_cap(X86_FEATURE_RTM);

This same argument applies to HLE, and it would be weird for pre-TSX_CTRL CPUs with tsx=off to report HLE but not RTM in /proc/cpuid

Right, the correct fix for that would be to run tsx_init() before we read CPUID leafs in get_cpu_cap() because then it'll load the proper bits already and we won't have to clear anything - the MSR write would've cleared both CPUID bits already.

I just checked that it happens globally even:

$ ./cpuid -r | grep -E "^\s+0x00000007" | awk '{ print $6 }' | uniq
edx=0xbc000400
Quoted 6 lines

Bits 4 (HLE) and 11 (RTM) are cleared on all CPUs.

I'll try this tomorrow to check whether it would even work that early.

If there's issues with it, then we'll have to do the above thing and clear HLE too, by hand.

But pre-TSX_CTRL CPUs won't reach the above code, because of the tsx_ctrl_is_supported() check at the beginning of tsx_init().

And post-TSX_CTRL CPUs will have the HLE bit already cleared by microcode.

Signature · 1 line
Josh
#13 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 2 lines · speck for Josh Poimboeuf

But pre-TSX_CTRL CPUs won't reach the above code, because of the tsx_ctrl_is_supported() check at the beginning of tsx_init().

Yes, pre-TSX_CTRL won't have those CPUID bits cleared because they cannot anyway - MSR is not there.

And even if we clear the corresponding X86_FEATURE_ bits, nothing is stopping people from using TSX - they won't query /proc/cpuinfo but CPUID directly. Hell, they can even try the instructions and see if they fault or not, without querying any feature bits.

Quoted 2 lines

And post-TSX_CTRL CPUs will have the HLE bit already cleared by microcode.

Yes.

In both cases, the X86_FEATURE_* bits mirror what's in CPUID. At least for the two TSX bits: HLE and RTM.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#14 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 12 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

But pre-TSX_CTRL CPUs won't reach the above code, because of the tsx_ctrl_is_supported() check at the beginning of tsx_init().

Yes, pre-TSX_CTRL won't have those CPUID bits cleared because they cannot anyway - MSR is not there.

And even if we clear the corresponding X86_FEATURE_ bits, nothing is stopping people from using TSX - they won't query /proc/cpuinfo but CPUID directly. Hell, they can even try the instructions and see if they fault or not, without querying any feature bits.

Quoted 7 lines
Quoted 2 lines

And post-TSX_CTRL CPUs will have the HLE bit already cleared by microcode.

Yes.

In both cases, the X86_FEATURE_* bits mirror what's in CPUID. At least for the two TSX bits: HLE and RTM.

Actually, according to the patches, with TSX_CTRL CPUs, HLE is unconditionally disabled, but still enumerated as present in CPUID (why???)

If that's the case then it sounds like X86_FEATURE_HLE needs to be forced clear for TSX_CTRL CPUs?

Signature · 1 line
Josh
#15 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 3 lines · speck for Josh Poimboeuf

Actually, according to the patches, with TSX_CTRL CPUs, HLE is unconditionally disabled, but still enumerated as present in CPUID (why???)

I found it: in an older email thread Andrew talks about migration compatibility and HLE. Dunno if we care but maybe someone else has a better idea.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#16 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 7 lines · speck for Borislav Petkov
Quoted 3 lines · speck for Josh Poimboeuf

Actually, according to the patches, with TSX_CTRL CPUs, HLE is unconditionally disabled, but still enumerated as present in CPUID (why???)

I found it: in an older email thread Andrew talks about migration compatibility and HLE. Dunno if we care but maybe someone else has a better idea.

The first TSX problem in Haswell/Broadwell lead to chaos when a microcode update took feature bits out.

When the second problem came around, I understand from IRL conversations that several vendors firmly expressed their opinion about whether feature bits should disappear in microcode.

As HLE is a hint bit at best, it was left visible despite being disabled behind the scenes.

~Andrew

#17 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 2 lines · speck for Andrew Cooper

The first TSX problem in Haswell/Broadwell lead to chaos when a microcode update took feature bits out.

Yeap, not worky with our current non-reentrant feature detection OSes. :-P

Quoted 6 lines

When the second problem came around, I understand from IRL conversations that several vendors firmly expressed their opinion about whether feature bits should disappear in microcode.

As HLE is a hint bit at best, it was left visible despite being disabled behind the scenes.

Yeah, and it being a hint bit only, I don't know whether we should care about a box where RTM=0 but HLE=1.

I guess the relevant use case is big fat hypervisor. But perhaps the easiest thing would be if the migration code gets told to ignore HLE.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#18 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Borislav Petkov
Quoted 8 lines · speck for Borislav Petkov
Quoted 3 lines · speck for Josh Poimboeuf

Actually, according to the patches, with TSX_CTRL CPUs, HLE is unconditionally disabled, but still enumerated as present in CPUID (why???)

I found it: in an older email thread Andrew talks about migration compatibility and HLE. Dunno if we care but maybe someone else has a better idea.

Ok, so a question here is -- on top of all the other questions we seem to be generating -- should we be unconditionally clearing X86_FEATURE_HLE in the cases where HLE is disabled but not reported as such, or will that break virt somehow?

Signature · 1 line
Josh
#19 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Borislav Petkov
Quoted 23 lines · speck for Borislav Petkov
Quoted 12 lines · speck for Andrew Cooper

arch/x86/kernel/cpu/tsx.c line 101

Quoted 9 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/tsx.c new file +9 -0
+	if (tsx_ctrl_state == TSX_CTRL_DISABLE) {
+		tsx_disable();
+
+		/*
+		 * tsx_disable() will change the state of the
+		 * RTM CPUID bit.  Clear it here since it is now
+		 * expected to be not set.
+		 */
+		setup_clear_cpu_cap(X86_FEATURE_RTM);

This same argument applies to HLE, and it would be weird for pre-TSX_CTRL CPUs with tsx=off to report HLE but not RTM in /proc/cpuid

Right, the correct fix for that would be to run tsx_init() before we read CPUID leafs in get_cpu_cap() because then it'll load the proper bits already and we won't have to clear anything - the MSR write would've cleared both CPUID bits already.

I just checked that it happens globally even:

$ ./cpuid -r | grep -E "^\s+0x00000007" | awk '{ print $6 }' | uniq
edx=0xbc000400
Quoted 6 lines

Bits 4 (HLE) and 11 (RTM) are cleared on all CPUs.

I'll try this tomorrow to check whether it would even work that early.

If there's issues with it, then we'll have to do the above thing and clear HLE too, by hand.

On Xen, I've juggled things such that we load microcode, then interpret tsx= if the user has provided it (taking care to always write MSR_TSX_CTRL if it is available, to discard whatever settings firmware or kexec left), before querying CPUID.

Later, the spec-ctrl= interpretation happens, which might choose to turn off TSX due to TAA, which then has to modify MSR_TSX_CTRL and force clear the bits in the policy.

Given that speculative mitigations rely heavily on CPUID, I can't reason about a clean way to disentangle this, but the above seems to be the least complicated algorithm.

Quoted 12 lines
Quoted 12 lines

Furthermore, while grepping through the tree, I found

events/intel/lbr.c-267-static inline bool lbr_from_signext_quirk_needed(void)
events/intel/lbr.c-268-{
events/intel/lbr.c-269- int lbr_format = x86_pmu.intel_cap.lbr_format; events/intel/lbr.c:270: bool tsx_support = boot_cpu_has(X86_FEATURE_HLE) || events/intel/lbr.c-271-                    boot_cpu_has(X86_FEATURE_RTM); events/intel/lbr.c-272-
events/intel/lbr.c-273- return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX);

Quoted 4 lines
Quoted 2 lines

which is going to need an adjustment to avoid applying the quirks on non-broken hardware.

When both HLE and RTM bits are cleared, that should still be correct, no? Or am I missing something?

On Haswell and Broadwell, the microcode which turned HLE/RTM off in the pipeline left the LBR MSRs in a state where you can't context switch the value, because they would yield a value via RDMSR which WRMSR faulted on, because the two operations had an asymmetric view of how the top bits of metadata should be interpreted, given some TSX-related metadata and a sign extended linear address.

On Skylake where you can't actually turn RTM off, but we may hide FEATURE_RTM/HLE, the above quirk is probably not true.

On Cascadelake, who knows?  RTM is being turned off in the pipeline, but maybe the HSX/BWX bug has been fixed, or maybe it is being turned off in a different way, or ...

~Andrew

#20 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 4 lines · speck for Andrew Cooper

On Xen, I've juggled things such that we load microcode, then interpret tsx= if the user has provided it (taking care to always write MSR_TSX_CTRL if it is available, to discard whatever settings firmware or kexec left), before querying CPUID.

Yap, wanna try the same thing, in that exact order.

Quoted 3 lines

Later, the spec-ctrl= interpretation happens, which might choose to turn off TSX due to TAA, which then has to modify MSR_TSX_CTRL and force clear the bits in the policy.

Well, the kernel doesn't reeval CPUID feature bits in that case because it has gone on booting and enabled all kinds of feature supporting code. This is the reason why the whole late microcode loading is such a bad thing to do.

Quoted 3 lines

Given that speculative mitigations rely heavily on CPUID, I can't reason about a clean way to disentangle this, but the above seems to be the least complicated algorithm.

Right, considering our CPU feature supporting code doesn't do any reevaluation of features and it "reloads" support for newly appearing or disappearing features, the only ordering you can do is

1. load microcode and toggle MSRs or do whatever else, which modifies CPUID leafs.

2. Read and cache and act upon those feature leafs.

That's it, feature bits are cast in stone.

Quoted 9 lines

On Haswell and Broadwell, the microcode which turned HLE/RTM off in the pipeline left the LBR MSRs in a state where you can't context switch the value, because they would yield a value via RDMSR which WRMSR faulted on, because the two operations had an asymmetric view of how the top bits of metadata should be interpreted, given some TSX-related metadata and a sign extended linear address.

On Skylake where you can't actually turn RTM off, but we may hide FEATURE_RTM/HLE, the above quirk is probably not true.

Huh? How is that possible? TSX_CTRL has defined only bit 1 there, the CPUID enumeration bit, and bit 0 doesn't do any RTM disabling? Srsly?!

Quoted 3 lines

On Cascadelake, who knows?  RTM is being turned off in the pipeline, but maybe the HSX/BWX bug has been fixed, or maybe it is being turned off in a different way, or ...

Right, I guess we'll deal with any perfcounters fallout in public, when the stuff releases...

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#21 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 7 lines · speck for Borislav Petkov
Quoted 4 lines · speck for Andrew Cooper

On Xen, I've juggled things such that we load microcode, then interpret tsx= if the user has provided it (taking care to always write MSR_TSX_CTRL if it is available, to discard whatever settings firmware or kexec left), before querying CPUID.

Yap, wanna try the same thing, in that exact order.

Quoted 7 lines
Quoted 3 lines

Later, the spec-ctrl= interpretation happens, which might choose to turn off TSX due to TAA, which then has to modify MSR_TSX_CTRL and force clear the bits in the policy.

Well, the kernel doesn't reeval CPUID feature bits in that case because it has gone on booting and enabled all kinds of feature supporting code. This is the reason why the whole late microcode loading is such a bad thing to do.

:)

I don't necessarily disagree, but the customers (who ultimately pay my salary) want late microcode loading and livepatching, so we've delivered.

Quoted 8 lines
Quoted 8 lines

On Haswell and Broadwell, the microcode which turned HLE/RTM off in the pipeline left the LBR MSRs in a state where you can't context switch the value, because they would yield a value via RDMSR which WRMSR faulted on, because the two operations had an asymmetric view of how the top bits of metadata should be interpreted, given some TSX-related metadata and a sign extended linear address.

Quoted 4 lines
Quoted 2 lines

On Skylake where you can't actually turn RTM off, but we may hide FEATURE_RTM/HLE, the above quirk is probably not true.

Huh? How is that possible? TSX_CTRL has defined only bit 1 there, the CPUID enumeration bit, and bit 0 doesn't do any RTM disabling? Srsly?!

Skylake CPUs aren't getting TSX_CTRL, but force setting/clearing bits at boot will affect later logic.  (Unless I'm being blind while reading the patches, which is a distinct possibility).

Quoted 6 lines
Quoted 4 lines

On Cascadelake, who knows?  RTM is being turned off in the pipeline, but maybe the HSX/BWX bug has been fixed, or maybe it is being turned off in a different way, or ...

Right, I guess we'll deal with any perfcounters fallout in public, when the stuff releases...

So, I remembered that I had already written a test case for this bug.

Initial experimentation shows that using TSX_CTRL to secure Cascade Lake doesn't result in Haswell/Broadwell style GP faults, which is good news.  I will be adjusting Xen's logic not to invoke the quirk on more modern parts.

~Andrew

reviewer
#22 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

On Haswell and Broadwell, the microcode which turned HLE/RTM off in the pipeline left the LBR MSRs in a state where you can't context switch the value, because they would yield a value via RDMSR which WRMSR faulted on, because the two operations had an asymmetric view of how the top bits of metadata should be interpreted, given some TSX-related metadata and a sign extended linear address.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

On Skylake where you can't actually turn RTM off, but we may hide FEATURE_RTM/HLE, the above quirk is probably not true.

Huh? How is that possible? TSX_CTRL has defined only bit 1 there, the CPUID enumeration bit, and bit 0 doesn't do any RTM disabling? Srsly?!

Skylake CPUs aren't getting TSX_CTRL, but force setting/clearing bits at boot will affect later logic.  (Unless I'm being blind while reading the patches, which is a distinct possibility).

tsx_init() will not force bits at boot on Skylake because of tsx_ctrl_is_supported() check.

Would adding this comment help?

----

arch/x86/kernel/cpu/tsx.c +0 -0
index 0969e6e9dff3..416dad3b8590 100644
@@ -78,9 +78,19 @@ static enum tsx_ctrl_states x86_get_tsx_auto_mode(void)
 
 void __init tsx_init(void)
 {
	char arg[5] = {};

int ret;

+ /*
+ * On MDS_NO=0 CPUs tsx_init() would do nothing and simply return from
+ * here.
+ *
+ * TSX control(aka MSR_IA32_TSX_CTRL) is only available after a
+ * microcode update on CPUs that have their MSR_IA32_ARCH_CAPABILITIES
+ * bit MDS_NO=1. CPUs with MDS_NO=0 are not planned to get
+ * MSR_IA32_TSX_CTRL even after the microcode update. tsx= cmdline
+ * requests will do nothing on CPUs without MSR_IA32_TSX_CTRL support.
+ */
if (!tsx_ctrl_is_supported())
return;

#23 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 4 lines · speck for Pawan Gupta

tsx_init() will not force bits at boot on Skylake because of tsx_ctrl_is_supported() check.

Would adding this comment help?

Yes, I've added it to tsx_ctrl_is_supported(). Considering how confusing this whole TAA/TSX situation to people is, having more comments at the right spot explaining stuff is always prudent.

Thx.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#24 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Andrew Cooper
Quoted 2 lines · speck for Andrew Cooper

I don't necessarily disagree, but the customers (who ultimately pay my salary) want late microcode loading and livepatching, so we've delivered.

Yeah, you guys promised too much. How do you deal with userspace using a feature and you wanna upgrade microcode which disables it? TSX might not be a good example here because feature bits disappearing is still ok, it doesn't fault but it would simply start aborting transactions unconditionally but what if it is a CPU feature which userspace is actively using and it disappears underneath its feet all of a sudden?

Just upgrade the microcode and forget about it is not enough. I'm pretty sure you'll have to "dance". But hey, you can buy almost everything with money nowadays so... :-)

Quoted 3 lines

Skylake CPUs aren't getting TSX_CTRL, but force setting/clearing bits at boot will affect later logic.  (Unless I'm being blind while reading the patches, which is a distinct possibility).

Yes, that's why I'm saying we should not blindly force set and clear bits but mirror what CPUID is telling us. At least wrt TSX.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#25 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 6 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Andrew Cooper

I don't necessarily disagree, but the customers (who ultimately pay my salary) want late microcode loading and livepatching, so we've delivered.

Yeah, you guys promised too much. How do you deal with userspace using a feature and you wanna upgrade microcode which disables it? TSX might not be a good example here

Its the perfect example here.  The answer is by requesting that Intel change bit 0's behaviour from causing #UD's to causing aborts.

The first version of this microcode was definitely not safe to late load.

Quoted 1 line

because feature bits disappearing is still ok,

Some userspace apparently gets confused when CPUID changes behind its back, which is why the CPUID control in bit 1 was split out from an otherwise monolithic bit 0.

At late load, choose (or not) to use bit 0 only. At boot, choose (or not) both bits 0 and 1 in unison.

Quoted 3 lines

it doesn't fault but it would simply start aborting transactions unconditionally but what if it is a CPU feature which userspace is actively using and it disappears underneath its feet all of a sudden?

Noone has guaranteed that all microcode ever in the future is going to be safe to use on a running system.  If it really can't be made to be safe, then customers are really going to have to reboot.

However, there is a lot of effort going into trying to make sure that fixes such as this one are made safe for late loading.

To give a concrete example, we have customers who's elapsed time for a reboot, conforming to SLAs, is in excess of 9 months, and new microcode with critical fixes is coming out faster than that.  I bet that I'm not the only person on this list with this type of customer.

Quoted 3 lines

Just upgrade the microcode and forget about it is not enough. I'm pretty sure you'll have to "dance". But hey, you can buy almost everything with money nowadays so... :-)

Yeah, you have to dance, but the constituent pieces are already around, so its not too bad.

Quoted 7 lines
Quoted 4 lines

Skylake CPUs aren't getting TSX_CTRL, but force setting/clearing bits at boot will affect later logic.  (Unless I'm being blind while reading the patches, which is a distinct possibility).

Yes, that's why I'm saying we should not blindly force set and clear bits but mirror what CPUID is telling us. At least wrt TSX.

Ah - in which case I agree.  Sorry for the noise.

~Andrew

#26 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 4 lines · speck for Andrew Cooper

Its the perfect example here.  The answer is by requesting that Intel change bit 0's behaviour from causing #UD's to causing aborts.

The first version of this microcode was definitely not safe to late load.

Yap, exactly, and that is a problem: you can't always get the microcode update to do what you want. IOW, we need some sort of communication protocl between CPU vendors and OS which tells the OS what the microcode provides and the OS can determine whether late loading would succeed.

tglx proposed a table of CPUID feature bits changing, for example, and that is a first step in the right direction.

Changing the kernel to "reload" features is not trivial.

Quoted 6 lines

Some userspace apparently gets confused when CPUID changes behind its back, which is why the CPUID control in bit 1 was split out from an otherwise monolithic bit 0.

At late load, choose (or not) to use bit 0 only. At boot, choose (or not) both bits 0 and 1 in unison.

Yes, and the fact that there are two bits is practically dictated by the inability of the OS to handle late loading optimally. Otherwise, you would've had only one bit.

All I'm saying is, late loading is such a problem that it even dictates how microcode should look like.

Quoted 11 lines

Noone has guaranteed that all microcode ever in the future is going to be safe to use on a running system.  If it really can't be made to be safe, then customers are really going to have to reboot.

However, there is a lot of effort going into trying to make sure that fixes such as this one are made safe for late loading.

To give a concrete example, we have customers who's elapsed time for a reboot, conforming to SLAs, is in excess of 9 months, and new microcode with critical fixes is coming out faster than that.  I bet that I'm not the only person on this list with this type of customer.

Oh I bet.

And I really think in the age of containers and live migration and all that crap, what we should push for is freeing the host for proper kernel and microcode update and then rebooting it. While the guests are moved to another instance which has been rebooted already. I know, that is hard and it has its warts too but the late loading is a PITA already. And rebooting the host as part of maint downtime would give you a lot more advantages.

But that's a whole another topic for another time and place.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#27 lore raw

[MODERATED] [AUTOREPLY] [MODERATED] [AUTOREPLY] Automatic reply: [PATCH 3/9] TAA 3

reviewer
#28 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Andrew Cooper
Quoted 13 lines · speck for Andrew Cooper

arch/x86/kernel/cpu/tsx.c line 101

Quoted 9 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/tsx.c new file +9 -0
+	if (tsx_ctrl_state == TSX_CTRL_DISABLE) {
+		tsx_disable();
+
+		/*
+		 * tsx_disable() will change the state of the
+		 * RTM CPUID bit.  Clear it here since it is now
+		 * expected to be not set.
+		 */
+		setup_clear_cpu_cap(X86_FEATURE_RTM);

This same argument applies to HLE, and it would be weird for pre-TSX_CTRL CPUs with tsx=off to report HLE but not RTM in /proc/cpuid

I guess you mean post-TSX_CTRL CPUs. I think this was done intentionally to reduce an extra cloud pool scenario. I will confirm if this is the case.

Quoted 12 lines

Furthermore, while grepping through the tree, I found

events/intel/lbr.c-267-static inline bool lbr_from_signext_quirk_needed(void)
events/intel/lbr.c-268-{
events/intel/lbr.c-269- int lbr_format = x86_pmu.intel_cap.lbr_format; events/intel/lbr.c:270: bool tsx_support = boot_cpu_has(X86_FEATURE_HLE) || events/intel/lbr.c-271-                    boot_cpu_has(X86_FEATURE_RTM); events/intel/lbr.c-272-
events/intel/lbr.c-273- return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX);

Quoted 2 lines

which is going to need an adjustment to avoid applying the quirks on non-broken hardware.

This may need an adjustment. I will get back on this one too.

Thanks,
Pawan

maintainer
#29 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Pawan Gupta
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well. I talked a bit about this with some powerpc people and they really want to disable this option as well, much like is being done here, for lots of other, non-security reasons.

So can we please go back to the generic name so that we have some unification, making userspace stuff more uniform?

thanks,

greg k-h

#30 lore raw

[MODERATED] Re: ***UNCHECKED*** Re: [PATCH 3/9] TAA 3

Quoted 7 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is,

indeed

Quoted 3 lines

I really would like to change the name here. We
already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

Which option are we talking about?

Quoted 7 lines

I talked a bit
about this with some powerpc people and they really want to disable this option as well, much like is being done here, for lots of other, non-security reasons.

So can we please go back to the generic name so that we have some unification, making userspace stuff more uniform?

What do you propose?

Signature · 2 lines
Michal Hocko
SUSE Labs
reviewer
#31 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

In reply to Greg KH
Quoted 9 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

I think powerpc calls it "ppc_tm=". We can't obviously change to this.

	ppc_tm=		[PPC]
			Format: {"off"}
			Disable Hardware Transactional Memory
Quoted 7 lines

I talked a bit
about this with some powerpc people and they really want to disable this option as well, much like is being done here, for lots of other, non-security reasons.

So can we please go back to the generic name so that we have some unification, making userspace stuff more uniform?

I couldn't find an existing generic name for this.

Thanks,
Pawan

maintainer
#32 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 11 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

Quoted 5 lines

I think powerpc calls it "ppc_tm=". We can't obviously change to this.

	ppc_tm=		[PPC]
			Format: {"off"}
			Disable Hardware Transactional Memory

No, but we can use "tm", and PPC said they would drop the "ppc_" prefix and use the generic flag as well. "Transactional Memory" is the generic term for this from what I can tell.

thanks,

greg k-h

#33 lore raw

[MODERATED] Re: ***UNCHECKED*** Re: [PATCH 3/9] TAA 3

Quoted 14 lines · speck for Greg KH
Quoted 13 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

I think powerpc calls it "ppc_tm=". We can't obviously change to this.

Quoted 7 lines
Quoted 3 lines
	ppc_tm=		[PPC]
			Format: {"off"}
			Disable Hardware Transactional Memory

No, but we can use "tm", and PPC said they would drop the "ppc_" prefix and use the generic flag as well. "Transactional Memory" is the generic term for this from what I can tell.

Are those two (tsx and tm) going to have the same semantic? I have little doubts TBH considering how tsx itself is tricky.

Signature · 2 lines
Michal Hocko
SUSE Labs
maintainer
#34 lore raw

[MODERATED] Re: ***UNCHECKED*** Re: [PATCH 3/9] TAA 3

Quoted 19 lines · speck for Michal Hocko
Quoted 18 lines · speck for Greg KH
Quoted 16 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

I think powerpc calls it "ppc_tm=". We can't obviously change to this.

	ppc_tm=		[PPC]
			Format: {"off"}
			Disable Hardware Transactional Memory
Quoted 6 lines
Quoted 3 lines

No, but we can use "tm", and PPC said they would drop the "ppc_" prefix and use the generic flag as well. "Transactional Memory" is the generic term for this from what I can tell.

Are those two (tsx and tm) going to have the same semantic? I have little doubts TBH considering how tsx itself is tricky.

Ugh, turns out gmail was marking all of these threads as spam, that answers my "why is this list so quiet?" question :(

Anyway, yes, TM shoudl have the same semantic. But, if it's too late at the moment, we can always unify this later on if PPC really wants it. I was just passing on what those developers told me. As the bundles are all set to go now, I'm not going to press the issue.

thanks,

greg k-h

#35 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 2 lines · speck for Greg KH

Anyway, yes, TM shoudl have the same semantic. But, if it's too late at the moment, we can always unify this later on if PPC really wants it.

We can s/unify/add additional/ to minimize confusion. What I mean is, we can add "tm=" as an additional option which coexists with the "tsx=" option on x86 because the patches would have released already and we would have communicated "tsx=" to people by then. So "tsx=" and "tm=" would do the same thing on x86.

Methinks.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Mary Higgins, Sri Rasiah, HRB 21284 (AG Nürnberg)
-- 
maintainer
#36 lore raw

[MODERATED] Re: [PATCH 3/9] TAA 3

Quoted 9 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Greg KH

Anyway, yes, TM shoudl have the same semantic. But, if it's too late at the moment, we can always unify this later on if PPC really wants it.

We can s/unify/add additional/ to minimize confusion. What I mean is, we can add "tm=" as an additional option which coexists with the "tsx=" option on x86 because the patches would have released already and we would have communicated "tsx=" to people by then. So "tsx=" and "tm=" would do the same thing on x86.

Ah, yes, that sounds like a sane plan.

thanks,

greg k-h

#37 lore raw

[MODERATED] Re: ***UNCHECKED*** Re: Re: [PATCH 3/9] TAA 3

In reply to Greg KH
Quoted 24 lines · speck for Greg KH
Quoted 23 lines · speck for Michal Hocko
Quoted 21 lines · speck for Greg KH
Quoted 11 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Greg KH
Quoted 4 lines · speck for Pawan Gupta

From: Pawan Gupta <[email protected]>
Subject: [PATCH 3/9] x86/cpu: Add a "tsx=" cmdline option with TSX disabled by
default

As late at this is, I really would like to change the name here. We already have a powerpc command line option to disable this for those chips, and we should use the same name here as well.

Quoted 5 lines

I think powerpc calls it "ppc_tm=". We can't obviously change to this.

	ppc_tm=		[PPC]
			Format: {"off"}
			Disable Hardware Transactional Memory

No, but we can use "tm", and PPC said they would drop the "ppc_" prefix and use the generic flag as well. "Transactional Memory" is the generic term for this from what I can tell.

Quoted 7 lines
Quoted 2 lines

Are those two (tsx and tm) going to have the same semantic? I have little doubts TBH considering how tsx itself is tricky.

Ugh, turns out gmail was marking all of these threads as spam, that answers my "why is this list so quiet?" question :(

Anyway, yes, TM shoudl have the same semantic.

My current understanding is that there is no way to simply disable tsx by the tsx parameter in general. I have no idea whether the same is the case for the ppc side of matters but I would be really surprised if the story was consistent with x86.

Anway if there is a way to make this more consistent then I have no objections but please keep in mind that last minute changes this late are not really healthy tend to cause more harm then good. This is an architecture specific problem and attaching it as such first makes a lot of sense to me.

Thanks!

Signature · 2 lines
Michal Hocko
SUSE Labs
reviewer
#38 lore raw

PATCH 4/9 TAA 4

In reply to Borislav Petkov

From: 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
]

Cc Andrew Morton <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Kees Cook <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Thomas Lendacky <[email protected]>
Cc x86-ml <[email protected]>
---
 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           | 110 +++++++++++++++++++++++++++
 arch/x86/kernel/cpu/common.c         |  15 ++++
 6 files changed, 139 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -0
index 0652d3eed9bd..989e03544f18 100644
@@ -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
index da4caf6da739..b3a8bb2af0b6 100644
@@ -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
index 80bc209c0708..5c24a7b35166 100644
@@ -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
index 6e0a3b43d027..54f5d54280f6 100644
@@ -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 +110 -0

140 lines not on this page · raw message

arch/x86/kernel/cpu/common.c +15 -0
index 885d4ac2111a..f8b8afc8f5b5 100644
@@ -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
#39 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 13 lines · speck for Pawan Gupta
arch/x86/kernel/cpu/common.c +5 -0
index 885d4ac2111a..f8b8afc8f5b5 100644
@@ -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
+	 *

arch/x86/kernel/cpu/common.c static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) · line 1145

Quoted 10 lines
arch/x86/kernel/cpu/common.c +10 -0
+	 * 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);
+

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

Signature · 1 line
Josh
#40 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#41 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

I guess so, unless somebody else can deduce that from existing information...

Signature · 1 line
Josh
reviewer
#42 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 9 lines · speck for Josh Poimboeuf
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

I guess so, unless somebody else can deduce that from existing information...

This is the list to the best of my knowledge.

+----------------------------+------------------+------------+
|            Name            |  Family / model  |  Stepping  |
+============================+==================+============+
| Whiskey Lake (ULT refresh) |      06_8E       |    0xC     |
+----------------------------+------------------+------------+
|    2nd gen Cascade Lake    |      06_55       |    6, 7    |
+----------------------------+------------------+------------+
|       Coffee Lake R        |      06_9E       |    0xD     |
+----------------------------+------------------+------------+

Thanks,
Pawan

reviewer
#43 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 13 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Josh Poimboeuf
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

I guess so, unless somebody else can deduce that from existing information...

This is the list to the best of my knowledge.

Quoted 9 lines
+----------------------------+------------------+------------+
|            Name            |  Family / model  |  Stepping  |
+============================+==================+============+
| Whiskey Lake (ULT refresh) |      06_8E       |    0xC     |
+----------------------------+------------------+------------+
|    2nd gen Cascade Lake    |      06_55       |    6, 7    |
+----------------------------+------------------+------------+
|       Coffee Lake R        |      06_9E       |    0xD     |
+----------------------------+------------------+------------+

Please discard this list, this is opposite of what we are looking for here.

Thanks,
Pawan

#44 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

In reply to Pawan Gupta
Quoted 13 lines · speck for Pawan Gupta
Quoted 9 lines · speck for Josh Poimboeuf
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

I guess so, unless somebody else can deduce that from existing information...

This is the list to the best of my knowledge.

Quoted 9 lines
+----------------------------+------------------+------------+
|            Name            |  Family / model  |  Stepping  |
+============================+==================+============+
| Whiskey Lake (ULT refresh) |      06_8E       |    0xC     |
+----------------------------+------------------+------------+
|    2nd gen Cascade Lake    |      06_55       |    6, 7    |
+----------------------------+------------------+------------+
|       Coffee Lake R        |      06_9E       |    0xD     |
+----------------------------+------------------+------------+

That may be helpful, but I think the question is how does that information translate to the cpu_vuln_whitelist table.

Signature · 1 line
Josh
#45 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

In reply to Borislav Petkov
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

While the original expression might be ugly, and could probably be explained more clearly, it is correct AFAICT.  I certainly have a very similar one in Xen.

~Andrew

#46 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 9 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we shouldn't set TAA_BUG.

Which models are those?

Here's the current struct:

static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
VULNWL(ANY, 4, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(CENTAUR, 5, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(INTEL, 5, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(NSC, 5, X86_MODEL_ANY, NO_SPECULATION),

/* Intel Family 6 */
VULNWL_INTEL(ATOM_SALTWELL, NO_SPECULATION),
VULNWL_INTEL(ATOM_SALTWELL_TABLET, NO_SPECULATION),
VULNWL_INTEL(ATOM_SALTWELL_MID, NO_SPECULATION),
VULNWL_INTEL(ATOM_BONNELL, NO_SPECULATION),
VULNWL_INTEL(ATOM_BONNELL_MID, NO_SPECULATION),

VULNWL_INTEL(ATOM_SILVERMONT, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_SILVERMONT_D, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_SILVERMONT_MID, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_AIRMONT, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(XEON_PHI_KNL, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(XEON_PHI_KNM, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),

VULNWL_INTEL(CORE_YONAH, NO_SSB),

VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_AIRMONT_NP, NO_L1TF | NO_SWAPGS),

VULNWL_INTEL(ATOM_GOLDMONT, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),
VULNWL_INTEL(ATOM_GOLDMONT_D, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),
VULNWL_INTEL(ATOM_GOLDMONT_PLUS, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),

/*
* Technically, swapgs isn't serializing on AMD (despite it previously
* being documented as such in the APM). But according to AMD, %gs is
* updated non-speculatively, and the issuing of %gs-relative memory
* operands will be blocked until the %gs update completes, which is
* good enough for our purposes.
*/

/* AMD Family 0xf - 0x12 */
VULNWL_AMD(0x0f, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x10, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x11, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),

/* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_HYGON(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS),
{}
};

Signature · 1 line
Josh
#47 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 8 lines · Josh Poimboeuf
Quoted 7 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Quoted 6 lines
Quoted 2 lines

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we

meant to say: "some of the *MDS* models don't have TSX".

Quoted 57 lines

shouldn't set TAA_BUG.

Which models are those?

Here's the current struct:

static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
VULNWL(ANY, 4, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(CENTAUR, 5, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(INTEL, 5, X86_MODEL_ANY, NO_SPECULATION),
VULNWL(NSC, 5, X86_MODEL_ANY, NO_SPECULATION),

/* Intel Family 6 */
VULNWL_INTEL(ATOM_SALTWELL, NO_SPECULATION),
VULNWL_INTEL(ATOM_SALTWELL_TABLET, NO_SPECULATION),
VULNWL_INTEL(ATOM_SALTWELL_MID, NO_SPECULATION),
VULNWL_INTEL(ATOM_BONNELL, NO_SPECULATION),
VULNWL_INTEL(ATOM_BONNELL_MID, NO_SPECULATION),

VULNWL_INTEL(ATOM_SILVERMONT, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_SILVERMONT_D, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_SILVERMONT_MID, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_AIRMONT, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(XEON_PHI_KNL, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(XEON_PHI_KNM, NO_SSB | NO_L1TF | MSBDS_ONLY | NO_SWAPGS),

VULNWL_INTEL(CORE_YONAH, NO_SSB),

VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF | MSBDS_ONLY | NO_SWAPGS),
VULNWL_INTEL(ATOM_AIRMONT_NP, NO_L1TF | NO_SWAPGS),

VULNWL_INTEL(ATOM_GOLDMONT, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),
VULNWL_INTEL(ATOM_GOLDMONT_D, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),
VULNWL_INTEL(ATOM_GOLDMONT_PLUS, NO_TAA | NO_MDS | NO_L1TF | NO_SWAPGS),

/*
* Technically, swapgs isn't serializing on AMD (despite it previously
* being documented as such in the APM). But according to AMD, %gs is
* updated non-speculatively, and the issuing of %gs-relative memory
* operands will be blocked until the %gs update completes, which is
* good enough for our purposes.
*/

/* AMD Family 0xf - 0x12 */
VULNWL_AMD(0x0f, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x10, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x11, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS),

/* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS),
VULNWL_HYGON(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS),
{}
};

Signature · 1 line
Josh
Signature · 1 line
Josh
#48 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

In reply to Josh Poimboeuf
Quoted 7 lines · speck for Josh Poimboeuf
Quoted 6 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Quoted 8 lines
Quoted 2 lines

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we shouldn't set TAA_BUG.

Which models are those?

Ok.  First things first.  Do you (and by this, I really mean Linux) want to consider TAA an overlapping set with MDS, or a disjoint set?

After considering this for ages, and particularly, how to explain it clearly to non-experts in Xen's security advisory, I chose to go with this:

---8<---
Vulnerability to TAA is a little complicated to quantify.

In the pipeline, it is just another way to get speculative access to stale load port, store buffer or fill buffer data, and therefore can be considered a superset of MDS.  On parts which predate MDS_NO, the existing VERW flushing will mitigate this sidechannel as well.

On parts which contain MDS_NO, the lack of VERW flushing means that an attacker can still target microarchitectural buffers to leak secrets. Therefore, we consider TAA to be the set of parts which have MDS_NO but lack TAA_NO.
---8<---

The simplifying fact is that vulnerability to TAA doesn't matter on CPUs which don't advertise MDS_NO, because you're already doing VERW and disabling hyperthreading, *and* can't turn TSX off if it actually available.

People who were not taking MDS mitigations in the first place won't change their minds because of TAA, either.

~Andrew

#49 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 37 lines · speck for Andrew Cooper
Quoted 7 lines · speck for Josh Poimboeuf
Quoted 6 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Quoted 8 lines
Quoted 2 lines

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we shouldn't set TAA_BUG.

Which models are those?

Ok.  First things first.  Do you (and by this, I really mean Linux) want to consider TAA an overlapping set with MDS, or a disjoint set?

After considering this for ages, and particularly, how to explain it clearly to non-experts in Xen's security advisory, I chose to go with this:

---8<---
Vulnerability to TAA is a little complicated to quantify.

In the pipeline, it is just another way to get speculative access to stale load port, store buffer or fill buffer data, and therefore can be considered a superset of MDS.  On parts which predate MDS_NO, the existing VERW flushing will mitigate this sidechannel as well.

On parts which contain MDS_NO, the lack of VERW flushing means that an attacker can still target microarchitectural buffers to leak secrets. Therefore, we consider TAA to be the set of parts which have MDS_NO but lack TAA_NO.
---8<---

Quoted 6 lines

The simplifying fact is that vulnerability to TAA doesn't matter on CPUs which don't advertise MDS_NO, because you're already doing VERW and disabling hyperthreading, *and* can't turn TSX off if it actually available.

People who were not taking MDS mitigations in the first place won't change their minds because of TAA, either.

Good question.

The current Linux patches consider them overlapping. But it _might_ possibly be easier to communicate if we considered them disjoint. I don't know if there's a good answer, but at this point it might be easiest to stick with our current overlapping approach.

Signature · 1 line
Josh
#50 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 41 lines · speck for Josh Poimboeuf
Quoted 40 lines · speck for Andrew Cooper
Quoted 7 lines · speck for Josh Poimboeuf
Quoted 6 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Quoted 8 lines
Quoted 2 lines

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we shouldn't set TAA_BUG.

Which models are those?

Ok.  First things first.  Do you (and by this, I really mean Linux) want to consider TAA an overlapping set with MDS, or a disjoint set?

After considering this for ages, and particularly, how to explain it clearly to non-experts in Xen's security advisory, I chose to go with this:

---8<---
Vulnerability to TAA is a little complicated to quantify.

In the pipeline, it is just another way to get speculative access to stale load port, store buffer or fill buffer data, and therefore can be considered a superset of MDS.  On parts which predate MDS_NO, the existing VERW flushing will mitigate this sidechannel as well.

On parts which contain MDS_NO, the lack of VERW flushing means that an attacker can still target microarchitectural buffers to leak secrets. Therefore, we consider TAA to be the set of parts which have MDS_NO but lack TAA_NO.
---8<---

The simplifying fact is that vulnerability to TAA doesn't matter on CPUs which don't advertise MDS_NO, because you're already doing VERW and disabling hyperthreading, *and* can't turn TSX off if it actually available.

Quoted 9 lines
Quoted 2 lines

People who were not taking MDS mitigations in the first place won't change their minds because of TAA, either.

Good question.

The current Linux patches consider them overlapping. But it _might_ possibly be easier to communicate if we considered them disjoint. I don't know if there's a good answer, but at this point it might be easiest to stick with our current overlapping approach.

I'll bring this up with the group.  I bet we are not the only people wondering the same, and it won't do any downstream users any good if they see conflicting descriptions from software vendors.

~Andrew

#51 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 46 lines · speck for Andrew Cooper
Quoted 45 lines · speck for Josh Poimboeuf
Quoted 36 lines · speck for Andrew Cooper
Quoted 7 lines · speck for Josh Poimboeuf
Quoted 6 lines · speck for Andrew Cooper
Quoted 5 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

As I said before this would be a lot nicer if we could just add NO_TAA to the cpu_vuln_whitelist.

We're waiting for a list of CPUs from Intel here, right?

Quoted 8 lines
Quoted 2 lines

There is no model list required.  Vulnerability to TAA is calculable directly from existing architectural sources.

Can you elaborate? Earlier I suggested relying on NO_MDS in cpu_vuln_whitelist, but I believe you said that's not sufficient, because some of the non-MDS models don't have TSX, in which case we shouldn't set TAA_BUG.

Which models are those?

Ok.  First things first.  Do you (and by this, I really mean Linux) want to consider TAA an overlapping set with MDS, or a disjoint set?

After considering this for ages, and particularly, how to explain it clearly to non-experts in Xen's security advisory, I chose to go with this:

---8<---
Vulnerability to TAA is a little complicated to quantify.

In the pipeline, it is just another way to get speculative access to stale load port, store buffer or fill buffer data, and therefore can be considered a superset of MDS.  On parts which predate MDS_NO, the existing VERW flushing will mitigate this sidechannel as well.

On parts which contain MDS_NO, the lack of VERW flushing means that an attacker can still target microarchitectural buffers to leak secrets. Therefore, we consider TAA to be the set of parts which have MDS_NO but lack TAA_NO.
---8<---

Quoted 6 lines

The simplifying fact is that vulnerability to TAA doesn't matter on CPUs which don't advertise MDS_NO, because you're already doing VERW and disabling hyperthreading, *and* can't turn TSX off if it actually available.

People who were not taking MDS mitigations in the first place won't change their minds because of TAA, either.

Good question.

Quoted 8 lines
Quoted 5 lines

The current Linux patches consider them overlapping. But it _might_ possibly be easier to communicate if we considered them disjoint. I don't know if there's a good answer, but at this point it might be easiest to stick with our current overlapping approach.

I'll bring this up with the group.  I bet we are not the only people wondering the same, and it won't do any downstream users any good if they see conflicting descriptions from software vendors.

Preliminary feedback suggests that some vendors are definitely going with TAA being a disjoint set to MDS, and other vendors are leaning in that direction.

We should wait a bit longer for more views and opinions, as I think my question was fairly late US time anyway yesterday.

~Andrew

reviewer
#52 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

In reply to Pawan Gupta

arch/x86/kernel/cpu/bugs.c void cpu_bugs_smt_update(void) · line 925

Quoted 13 lines · speck for Pawan Gupta

void cpu_bugs_smt_update(void)
{

arch/x86/kernel/cpu/bugs.c +7 -0
@@ -819,6 +916,19 @@ void cpu_bugs_smt_update(void)
 		break;
 	}
 
+	switch (taa_mitigation) {
+	case TAA_MITIGATION_VERW:
+	case TAA_MITIGATION_UCODE_NEEDED:
+		if (sched_smt_active())
+			pr_warn_once(TAA_MSG_SMT);
+		/* TSX is enabled, apply MDS idle buffer clearing. */
+		update_mds_branch_idle();

With partial clearing removed, this call can go away.

Thanks,
Pawan

#53 lore raw

[MODERATED] Re: [PATCH 4/9] TAA 4

Quoted 7 lines · speck for Pawan Gupta
Quoted 6 lines · speck for Pawan Gupta

void cpu_bugs_smt_update(void)
{

(quoted diff) +0 -0
@@ -819,6 +916,19 @@ void cpu_bugs_smt_update(void)
 		break;
 	}
 
Quoted 9 lines

arch/x86/kernel/cpu/bugs.c void cpu_bugs_smt_update(void) · line 925

Quoted 7 lines
arch/x86/kernel/cpu/bugs.c +7 -0
+	switch (taa_mitigation) {
+	case TAA_MITIGATION_VERW:
+	case TAA_MITIGATION_UCODE_NEEDED:
+		if (sched_smt_active())
+			pr_warn_once(TAA_MSG_SMT);
+		/* TSX is enabled, apply MDS idle buffer clearing. */
+		update_mds_branch_idle();

With partial clearing removed, this call can go away.

It is gone now, thx.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
reviewer
#54 lore raw

PATCH 5/9 TAA 5

In reply to Borislav Petkov

From: 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

Cc Greg Kroah-Hartman <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
---
 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
index 6648e0fbed96..07a8f812cf66 100644
@@ -1438,6 +1438,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)
@@ -1508,6 +1523,9 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
 	case X86_BUG_MDS:
 		return mds_show_state(buf);
 
+	case X86_BUG_TAA:
+		return tsx_async_abort_show_state(buf);
+
 	default:
 		break;
 	}
@@ -1544,4 +1562,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
index cc37511de866..0fccd8c0312e 100644
@@ -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
index d0633ebdaa9c..f35369f79771 100644
@@ -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
maintainer Reviewed-by on v1 5/9
#55 lore raw

[MODERATED] Re: [PATCH 5/9] TAA 5

Quoted 24 lines · speck for Pawan Gupta

From: 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

Cc Greg Kroah-Hartman <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
Quoted 5 lines
---
 arch/x86/kernel/cpu/bugs.c | 23 +++++++++++++++++++++++
 drivers/base/cpu.c         |  9 +++++++++
 include/linux/cpu.h        |  3 +++
 3 files changed, 35 insertions(+)
reviewer
#56 lore raw

PATCH 6/9 TAA 6

In reply to Borislav Petkov

From: 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.

Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc kvm ML <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc "Radim Krcmar" <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
---
 arch/x86/kvm/x86.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/x86/kvm/x86.c +19 -0
index 661e2bf38526..fb8d80caf642 100644
@@ -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
#57 lore raw

PATCH 9/9 TAA 9

In reply to Borislav Petkov

From: 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.

---
 arch/x86/Kconfig          | 45 +++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/cpu/tsx.c | 22 +++++++++++++------
 2 files changed, 61 insertions(+), 6 deletions(-)
arch/x86/Kconfig +45 -0
index d6e1faa28c58..eebae89726c4 100644
@@ -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 command line parameter. This
+	  has a risk that TSX will get enabled also on platforms which are
+	  known to be vulnerable to attacks like TAA and a safer option is to
+	  use tsx=auto command line parameter.
+
+	  This options 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 always disabled - equals tsx=off command line parameter.
+
+config X86_INTEL_TSX_MODE_ON
+	bool "on"
+	help
+	  TSX is always enabled on TSX capable HW - equals 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 tsx=auto command line parameter.
+endchoice
+
 config EFI
 	bool "EFI runtime service support"
 	depends on ACPI
arch/x86/kernel/cpu/tsx.c +16 -6
index 89ab91eacd4f..ab400f8bbfe1 100644
@@ -67,6 +67,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] = {};
@@ -82,17 +90,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
#58 lore raw

[MODERATED] Re: [PATCH 9/9] TAA 9

Quoted 48 lines · speck for Michal Hocko

From: 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.

---
 arch/x86/Kconfig          | 45 +++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/cpu/tsx.c | 22 +++++++++++++------
 2 files changed, 61 insertions(+), 6 deletions(-)
arch/x86/Kconfig +8 -0
index d6e1faa28c58..eebae89726c4 100644
@@ -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.

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1960

Quoted 10 lines
arch/x86/Kconfig +10 -0
+
+	  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 command line parameter. This
+	  has a risk that TSX will get enabled also on platforms which are
+	  known to be vulnerable to attacks like TAA and a safer option is to
+	  use tsx=auto command line parameter.

I think this is misleading. tsx=on doesn't make you vulnerable to TAA, because we still the TAA mitigation.

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1968

Quoted 8 lines
arch/x86/Kconfig +8 -0
+
+	  This options 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.

tsx=on vs tsx=auto is not a security consideration, but rather a performance one. With tsx=auto you disable TSX on some TAA-affected CPUs so you don't have to pay the performance penalty of the MDS mitigations.

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1973

Quoted 5 lines
arch/x86/Kconfig +5 -0
+
+config X86_INTEL_TSX_MODE_OFF
+	bool "off"
+	help
+	  TSX is always disabled - equals tsx=off command line parameter.

Define "always" :-)

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1985

Quoted 12 lines
arch/x86/Kconfig +12 -0
+
+config X86_INTEL_TSX_MODE_ON
+	bool "on"
+	help
+	  TSX is always enabled on TSX capable HW - equals 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 tsx=auto command line parameter.

Not exactly :-) This also leaves TSX enabled on MDS vulnerable parts.

Signature · 1 line
Josh
#59 lore raw

[MODERATED] Re: [PATCH 9/9] TAA 9

Quoted 2 lines · speck for Josh Poimboeuf

I think this is misleading. tsx=on doesn't make you vulnerable to TAA, because we still the TAA mitigation.

Changed to:

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.

Quoted 4 lines

tsx=on vs tsx=auto is not a security consideration, but rather a performance one. With tsx=auto you disable TSX on some TAA-affected CPUs so you don't have to pay the performance penalty of the MDS mitigations.

By performance penalty you mean, when you have TSX disabled on those parts, you'll save yourself the VERW which should be taking care of TAA too?

Quoted 8 lines

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1973

Quoted 6 lines
arch/x86/Kconfig +5 -0
+
+config X86_INTEL_TSX_MODE_OFF
+	bool "off"
+	help
+	  TSX is always disabled - equals tsx=off command line parameter.

Define "always" :-)

Changed to:

"TSX is disabled if possible - equals to tsx=off command line parameter."

Quoted 1 line

Not exactly :-) This also leaves TSX enabled on MDS vulnerable parts.

Your point being, the MD_CLEAR which takes care of TAA too?

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#60 lore raw

[MODERATED] Re: ***UNCHECKED*** Re: [PATCH 9/9] TAA 9

Quoted 30 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

I think this is misleading. tsx=on doesn't make you vulnerable to TAA, because we still the TAA mitigation.

Changed to:

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.

Quoted 4 lines

tsx=on vs tsx=auto is not a security consideration, but rather a performance one. With tsx=auto you disable TSX on some TAA-affected CPUs so you don't have to pay the performance penalty of the MDS mitigations.

By performance penalty you mean, when you have TSX disabled on those parts, you'll save yourself the VERW which should be taking care of TAA too?

Quoted 8 lines

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1973

Quoted 6 lines
arch/x86/Kconfig +5 -0
+
+config X86_INTEL_TSX_MODE_OFF
+	bool "off"
+	help
+	  TSX is always disabled - equals tsx=off command line parameter.

Define "always" :-)

Quoted 3 lines

Changed to:

"TSX is disabled if possible - equals to tsx=off command line parameter."

Thanks for refinements. The changelog and the help text was written at the time when all this was still clear as mud.

Signature · 2 lines
Michal Hocko
SUSE Labs
#61 lore raw

[MODERATED] Re: [PATCH 9/9] TAA 9

In reply to Borislav Petkov

Missed these questions the first time around...

Quoted 12 lines · speck for Borislav Petkov
Quoted 2 lines · speck for Josh Poimboeuf

I think this is misleading. tsx=on doesn't make you vulnerable to TAA, because we still the TAA mitigation.

Changed to:

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.

Quoted 8 lines
Quoted 4 lines

tsx=on vs tsx=auto is not a security consideration, but rather a performance one. With tsx=auto you disable TSX on some TAA-affected CPUs so you don't have to pay the performance penalty of the MDS mitigations.

By performance penalty you mean, when you have TSX disabled on those parts, you'll save yourself the VERW which should be taking care of TAA too?

Right.

Quoted 7 lines
Quoted 6 lines

arch/x86/Kconfig config X86_INTEL_MEMORY_PROTECTION_KEYS · line 1973

Quoted 4 lines
arch/x86/Kconfig +4 -0
+config X86_INTEL_TSX_MODE_OFF
+	bool "off"
+	help
+	  TSX is always disabled - equals tsx=off command line parameter.

Define "always" :-)

Quoted 7 lines

Changed to:

"TSX is disabled if possible - equals to tsx=off command line parameter."

Quoted 1 line

Not exactly :-) This also leaves TSX enabled on MDS vulnerable parts.

Your point being, the MD_CLEAR which takes care of TAA too?

You overtrimmed :-) Going back, I believe this comment was about

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 tsx=auto command line parameter.

My point is that this option makes it sounds like TSX is *only* enabled on non-TAA parts, when in fact it's also enabled on those TAA parts which are also vulnerable to MDS (this of course assumes the "overlapping" model described by Andrew).

Signature · 1 line
Josh
reviewer
#62 lore raw

PATCH 7/9 TAA 7

In reply to Borislav Petkov

From: 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". ]

Cc "H. Peter Anvin" <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Mark Gross <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt | 5 +++++
 arch/x86/kernel/cpu/tsx.c                       | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index ad6b69057bb0..e1aca10f2a7f 100644
@@ -4856,6 +4856,11 @@
 
 			on	- Enable TSX on the system.
 			off	- Disable TSX on the system.
+			auto	- Disable TSX if X86_BUG_TAA is present,
+				  otherwise enable TSX on the system.
+
+			More details on X86_BUG_TAA here:
+			Documentation/admin-guide/hw-vuln/tsx_async_abort.rst
 
 			Not specifying this option is equivalent to tsx=off.
 
arch/x86/kernel/cpu/tsx.c +6 -1
index e5933ef50add..89ab91eacd4f 100644
@@ -69,7 +69,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())
@@ -81,6 +81,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
#63 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Documentation/admin-guide/kernel-parameters.txt line 4859

Quoted 9 lines · speck for Pawan Gupta
Documentation/admin-guide/kernel-parameters.txt +1 -0
index ad6b69057bb0..e1aca10f2a7f 100644
@@ -4856,6 +4856,11 @@
 
 			on	- Enable TSX on the system.
 			off	- Disable TSX on the system.
+			auto	- Disable TSX if X86_BUG_TAA is present,

Not quite true, since MDS-affected parts don't have the new microcode bits to disable TSX.

Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+				  otherwise enable TSX on the system.
+
+			More details on X86_BUG_TAA here:
+			Documentation/admin-guide/hw-vuln/tsx_async_abort.rst
 
 			Not specifying this option is equivalent to tsx=off.
Signature · 1 line
Josh
#64 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Quoted 7 lines · speck for Josh Poimboeuf
Quoted 6 lines · speck for Pawan Gupta
Documentation/admin-guide/kernel-parameters.txt +0 -0
index ad6b69057bb0..e1aca10f2a7f 100644
@@ -4856,6 +4856,11 @@
 
Quoted 6 lines

Documentation/admin-guide/kernel-parameters.txt line 4859

Quoted 3 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
 			on	- Enable TSX on the system.
 			off	- Disable TSX on the system.
+			auto	- Disable TSX if X86_BUG_TAA is present,

Not quite true, since MDS-affected parts don't have the new microcode bits to disable TSX.

How's this:

"Disable TSX if the CPU is affected by the TSX Async Abort (TAA) vulnerability and microcode provides a special MSR - TSX_CTRL_MSR - which provides the required TSX control knobs. On MDS-affected parts where VERW takes care of the TAA vulnerability, that controlling MSR is not present and thus TSX cannot be disabled there."

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#65 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Quoted 5 lines · speck for Borislav Petkov

"Disable TSX if the CPU is affected by the TSX Async Abort (TAA) vulnerability and microcode provides a special MSR - TSX_CTRL_MSR - which provides the required TSX control knobs. On MDS-affected parts where VERW takes care of the TAA vulnerability, that controlling MSR is not present and thus TSX cannot be disabled there."

This is true if you ignore hyperthreading.

On SMT systems, TSX disable is 100% complete mitigation, while VERW clearing is not.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#66 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Quoted 8 lines · speck for Jiri Kosina
Quoted 5 lines · speck for Borislav Petkov

"Disable TSX if the CPU is affected by the TSX Async Abort (TAA) vulnerability and microcode provides a special MSR - TSX_CTRL_MSR - which provides the required TSX control knobs. On MDS-affected parts where VERW takes care of the TAA vulnerability, that controlling MSR is not present and thus TSX cannot be disabled there."

Quoted 4 lines

This is true if you ignore hyperthreading.

On SMT systems, TSX disable is 100% complete mitigation, while VERW clearing is not.

So why is our default this then?

static enum taa_mitigations taa_mitigation __ro_after_init = TAA_MITIGATION_VERW;

and we only do the TAA_MITIGATION_TSX_DISABLED thing only if TSX has been disabled earlier?

Because of those MDS_NO=0 machines which don't get the TSX_CTRL MSR so that TSX cannot be disabled there?

Are some of those machines SMT?

Because if so, we *must* disable SMT unconditionally to mitigate TAA completely there... methinks.

Signature · 4 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
#67 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Quoted 21 lines · speck for Borislav Petkov
Quoted 8 lines · speck for Jiri Kosina
Quoted 5 lines · speck for Borislav Petkov

"Disable TSX if the CPU is affected by the TSX Async Abort (TAA) vulnerability and microcode provides a special MSR - TSX_CTRL_MSR - which provides the required TSX control knobs. On MDS-affected parts where VERW takes care of the TAA vulnerability, that controlling MSR is not present and thus TSX cannot be disabled there."

Quoted 4 lines

This is true if you ignore hyperthreading.

On SMT systems, TSX disable is 100% complete mitigation, while VERW clearing is not.

So why is our default this then?

static enum taa_mitigations taa_mitigation __ro_after_init = TAA_MITIGATION_VERW;

and we only do the TAA_MITIGATION_TSX_DISABLED thing only if TSX has been disabled earlier?

Quoted 7 lines

Because of those MDS_NO=0 machines which don't get the TSX_CTRL MSR so that TSX cannot be disabled there?

Are some of those machines SMT?

Because if so, we *must* disable SMT unconditionally to mitigate TAA completely there... methinks.

For the same reasons we kept SMT enabled for L1TF and MDS... We don't want to break existing SMT workloads.

Signature · 1 line
Josh
#68 lore raw

[MODERATED] Re: [PATCH 7/9] TAA 7

Quoted 2 lines · speck for Josh Poimboeuf

For the same reasons we kept SMT enabled for L1TF and MDS... We don't want to break existing SMT workloads.

Should we add that to the above "auto" option text?

I mean, it's not like it is a new decision to keep SMT enabled in the face of a not fully mitigated vuln...

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
reviewer
#69 lore raw

PATCH 8/9 TAA 8

In reply to Borislav Petkov

From: 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. ]

---
 .../ABI/testing/sysfs-devices-system-cpu      |   1 +
 Documentation/admin-guide/hw-vuln/index.rst   |   1 +
 .../admin-guide/hw-vuln/tsx_async_abort.rst   | 256 ++++++++++++++++++
 .../admin-guide/kernel-parameters.txt         |  36 +++
 Documentation/x86/index.rst                   |   1 +
 Documentation/x86/tsx_async_abort.rst         | 117 ++++++++
 6 files changed, 412 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
index 06d0931119cc..0e77569bd5e0 100644
@@ -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
index 49311f3da6f2..0802b1c67452 100644
@@ -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 +256 -0

256 lines not on this page · raw message

Documentation/admin-guide/kernel-parameters.txt +36 -0
index e1aca10f2a7f..6eb1c0c8018c 100644
@@ -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
@@ -4864,6 +4866,40 @@
 
 			Not specifying this option is equivalent to tsx=off.
 
+	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
+			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
index af64c4bb4447..a8de2fbc1caa 100644
@@ -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
#70 lore raw

[MODERATED] Re: [PATCH 8/9] TAA 8

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 145

Quoted 5 lines · speck for Pawan Gupta
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +5 -0
+Virtualization mitigation
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Affected systems where the host has the TAA microcode and the TAA mitigation is
+ON (with TSX disabled) are not vulnerable regardless of the status of the VMs.

This is is confusing: "the TAA mitigation is ON (with TSX disabled)".

Which is it? Is the TAA mitigation on, or is TSX disabled?

Quoted 32 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +32 -0
+
+In all other cases, if the host either does not have the TAA microcode or the
+kernel is not mitigated, the system might be vulnerable.
+
+
+.. _taa_mitigation_control_command_line:
+
+Mitigation control on the kernel command line
+---------------------------------------------
+
+The kernel command line allows to control the TAA mitigations at boot time with
+the option "tsx_async_abort=". The valid arguments for this option are:
+
+  ============  =============================================================
+  off		This option disables the TAA mitigation on affected platforms.
+                If the system has TSX enabled (see next parameter) and the CPU
+                is affected, the system is vulnerable.
+
+  full	        TAA mitigation is enabled. If TSX is enabled, on an affected
+                system it will clear CPU buffers on ring transitions. On
+                systems which are MDS-affected and deploy MDS mitigation,
+                TAA is also mitigated. Specifying this option on those
+                systems will have no effect.
+
+  full,nosmt    The same as tsx_async_abort=full, with SMT disabled on
+                vulnerable CPUs that have TSX enabled. This is the complete
+                mitigation. When TSX is disabled, SMT is not disabled because
+                CPU is not vulnerable to cross-thread TAA attacks.
+  ============  =============================================================
+
+Not specifying this option is equivalent to "tsx_async_abort=full".
+

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 187

Quoted 10 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+The kernel command line also allows to control the TSX feature using the
+parameter "tsx=" on CPUs which support TSX control. MSR_IA32_TSX_CTRL is used
+to control the TSX feature and the enumeration of the TSX feature bits (RTM
+and HLE) in CPUID.
+
+The valid options are:
+
+  ============  =============================================================
+  off		Disables TSX.
+

This is not universally true.

Quoted 1 line

+ on Enables TSX.

This probably needs the same "TSX is fundamentally insecure" caveat I proposed for kernel-parameters.txt.

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 190

Quoted 2 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +2 -0
+
+  auto		Disables TSX on affected platform, otherwise enables TSX.

This is not universally true.

Also, it would be relevant to refer to that table Pawan posted which shows exactly which CPUs are vulnerable to TAA but not MDS.

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 200

Quoted 10 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+  ============  =============================================================
+
+Not specifying this option is equivalent to "tsx=off".
+
+The following combinations of the "tsx_async_abort" and "tsx" are possible. For
+affected platforms tsx=auto is equivalent to tsx=off and the result will be:
+
+  =========  ====================   =========================================
+  tsx=on     tsx_async_abort=full   The system will use VERW to clear CPU
+                                    buffers.

The system may still be vulnerable to SMT-based attacks.

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 204

Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+  tsx=on     tsx_async_abort=off    The system is vulnerable.
+  tsx=off    tsx_async_abort=full   TSX is disabled. System is not vulnerable.
+  tsx=off    tsx_async_abort=off    TSX is disabled. System is not vulnerable.
+  =========  ====================   =========================================

Combinations with tsx_async_abort=full,nosmt should also be described.

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 208

Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+
+For unaffected platforms "tsx=on" and "tsx_async_abort=full" does not clear CPU
+buffers.  For platforms without TSX control "tsx" command line argument has no
+effect.

Which platforms are those?

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 221

Quoted 12 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +12 -0
+For the affected platforms below table indicates the mitigation status for the
+combinations of CPUID bit MD_CLEAR and IA32_ARCH_CAPABILITIES MSR bits MDS_NO
+and TSX_CTRL_MSR.
+
+  =======  =========  =============  ========================================
+  MDS_NO   MD_CLEAR   TSX_CTRL_MSR   Status
+  =======  =========  =============  ========================================
+    0          0            0        Vulnerable (needs ucode)
+    0          1            0        MDS and TAA mitigated via VERW
+    1          1            0        MDS fixed, TAA vulnerable if TSX enabled
+                                     because MD_CLEAR has no meaning and
+                                     VERW is not guaranteed to clear buffers

(needs ucode) ?

Quoted 11 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +11 -0
+    1          X            1        MDS fixed, TAA can be mitigated by
+                                     VERW or TSX_CTRL_MSR
+  =======  =========  =============  ========================================
+
+Mitigation selection guide
+--------------------------
+
+1. Trusted userspace and guests
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If all user space applications are from a trusted source and do not execute

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 242

Quoted 10 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+untrusted code which is supplied externally, then the mitigation can be
+disabled. The same applies to virtualized environments with trusted guests.
+
+
+2. Untrusted userspace and guests
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If there are untrusted applications or guests on the system, enabling TSX
+might allow a malicious actor to leak data from the host or from other
+processes running on the same physical core.

Unless the mitigation is enabled (which is on by default, BTW...)

This makes it sounds like the only mitigation is to disable TSX.

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 246

Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+
+If the microcode is available and the TSX is disabled on the host, attacks
+are prevented in a virtualized environment as well, even if the VMs do not
+explicitly enable the mitigation.

What's the effect on VM security if TSX is enabled and the host TAA mitigation is also enabled?

Quoted 43 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+
+
+.. _taa_default_mitigations:
+
+Default mitigations
+-------------------
+
+The kernel's default action for vulnerable processors is:
+
+  - Deploy TSX disable mitigation (tsx_async_abort=full tsx=off).
Documentation/admin-guide/kernel-parameters.txt +11 -0
index e1aca10f2a7f..6eb1c0c8018c 100644
@@ -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
@@ -4864,6 +4866,40 @@
 
 			Not specifying this option is equivalent to tsx=off.
 
+	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.

Documentation/admin-guide/kernel-parameters.txt line 4887

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10 -0
+
+			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 disabled

Quoted 51 lines
Documentation/admin-guide/kernel-parameters.txt +15 -0
+			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
index af64c4bb4447..a8de2fbc1caa 100644
@@ -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 +15 -0
new file mode 100644
index 000000000000..583ddc185ba2
@@ -0,0 +1,117 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+TSX Async Abort (TAA) mitigation
+================================
+
+.. _tsx_async_abort:
+
+Overview
+--------
+
+TSX Async Abort (TAA) is a side channel attack on 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 Transactional
+Synchronization Extensions (TSX) transaction.  This includes loads with no

Documentation/x86/tsx_async_abort.rst line 25

Quoted 10 lines
Documentation/x86/tsx_async_abort.rst new file +10 -0
+fault or assist condition. Such loads may speculatively expose stale data from
+the same uarch data structures as in MDS, with same scope of exposure i.e.
+same-thread and cross-thread. This issue affects all current processors that
+support TSX.
+
+Mitigation strategy
+-------------------
+
+a) TSX disable - one of the mitigations is to disable TSX. A new MSR
+IA32_TSX_CTRL will be available in future and current processors after

which processors?

Documentation/x86/tsx_async_abort.rst line 31

Quoted 6 lines
Documentation/x86/tsx_async_abort.rst new file +6 -0
+microcode update which can be used to disable TSX. In addition, it
+controls the enumeration of the TSX feature bits (RTM and HLE) in CPUID.
+
+b) Clear CPU buffers - similar to MDS, clearing the CPU buffers mitigates this
+vulnerability. More details on this approach can be found in
+:ref:`Documentation/admin-guide/hw-vuln/mds.rst <mds>`.

It should be clarified the mitigation is a) OR b), not both.

Quoted 28 lines
Documentation/x86/tsx_async_abort.rst new file +28 -0
+
+Kernel internal mitigation modes
+--------------------------------
+
+ =============    ============================================================
+ off              Mitigation is disabled. Either the CPU is not affected or
+                  tsx_async_abort=off is supplied on the kernel command line.
+
+ tsx disabled     Mitigation is enabled. TSX feature is disabled by default at
+                  bootup on processors that support TSX control.
+
+ verw             Mitigation is enabled. CPU is affected and MD_CLEAR is
+                  advertised in CPUID.
+
+ ucode needed     Mitigation is enabled. CPU is affected and MD_CLEAR is not
+                  advertised in CPUID. That is mainly for virtualization
+                  scenarios where the host has the updated microcode but the
+                  hypervisor does not expose MD_CLEAR in CPUID. It's a best
+                  effort approach without guarantee.
+ =============    ============================================================
+
+If the CPU is affected and the "tsx_async_abort" kernel command line parameter is
+not provided then the kernel selects an appropriate mitigation depending on the
+status of RTM and MD_CLEAR CPUID bits.
+
+Below tables indicate the impact of tsx=on|off|auto cmdline options on state of
+TAA mitigation, VERW behavior and TSX feature for various combinations of
+MSR_IA32_ARCH_CAPABILITIES bits.

Documentation/x86/tsx_async_abort.rst line 69

Quoted 10 lines
Documentation/x86/tsx_async_abort.rst new file +10 -0
+
+1. "tsx=off"
+
+=========  =========  ============  ============  ==============  ===================  ======================
+MSR_IA32_ARCH_CAPABILITIES bits     Result with cmdline tsx=off
+----------------------------------  -------------------------------------------------------------------------
+TAA_NO     MDS_NO     TSX_CTRL_MSR  TSX state     VERW can clear  TAA mitigation       TAA mitigation
+                                    after bootup  CPU buffers     tsx_async_abort=off  tsx_async_abort=full
+=========  =========  ============  ============  ==============  ===================  ======================
+    0          0           0         HW default         Yes           Same as MDS           Same as MDS

Does "HW default" mean "Enabled"?

Signature · 1 line
Josh
#71 lore raw

[MODERATED] Re: [PATCH 8/9] TAA 8

Quoted 10 lines · speck for Josh Poimboeuf

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 145

Quoted 5 lines · speck for Pawan Gupta
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +5 -0
+Virtualization mitigation
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Affected systems where the host has the TAA microcode and the TAA mitigation is
+ON (with TSX disabled) are not vulnerable regardless of the status of the VMs.

This is is confusing: "the TAA mitigation is ON (with TSX disabled)".

Which is it? Is the TAA mitigation on, or is TSX disabled?

I think it wants to say:

"Affected systems where the host has TAA microcode and TAA is mitigated by having disabled TSX, are not vulnerable..."

Quoted 1 line

This is not universally true.

"Disables TSX on systems which have the TSX-disable MSR."

Quoted 5 lines
Quoted 2 lines

+ on Enables TSX.

This probably needs the same "TSX is fundamentally insecure" caveat I proposed for kernel-parameters.txt.

I'm great at copy'n'paste:

"Enables TSX.

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."

Quoted 8 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 190

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +2 -0
+
+  auto		Disables TSX on affected platform, otherwise enables TSX.

This is not universally true.

Also, it would be relevant to refer to that table Pawan posted which shows exactly which CPUs are vulnerable to TAA but not MDS.

This one?

I don't know whether this one will get more models later or what the TAA_NO plan is...

+----------------------------+------------------+------------+
|            Name            |  Family / model  |  Stepping  |
+============================+==================+============+
| Whiskey Lake (ULT refresh) |      06_8E       |    0xC     |
+----------------------------+------------------+------------+
|    2nd gen Cascade Lake    |      06_55       |    6, 7    |
+----------------------------+------------------+------------+
|       Coffee Lake R        |      06_9E       |    0xD     |
+----------------------------+------------------+------------+
Quoted 14 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 200

Quoted 11 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+  ============  =============================================================
+
+Not specifying this option is equivalent to "tsx=off".
+
+The following combinations of the "tsx_async_abort" and "tsx" are possible. For
+affected platforms tsx=auto is equivalent to tsx=off and the result will be:
+
+  =========  ====================   =========================================
+  tsx=on     tsx_async_abort=full   The system will use VERW to clear CPU
+                                    buffers.

The system may still be vulnerable to SMT-based attacks.

Quoted 6 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 204

Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+  tsx=on     tsx_async_abort=off    The system is vulnerable.
+  tsx=off    tsx_async_abort=full   TSX is disabled. System is not vulnerable.
+  tsx=off    tsx_async_abort=off    TSX is disabled. System is not vulnerable.
+  =========  ====================   =========================================

Combinations with tsx_async_abort=full,nosmt should also be described.

  =========  ====================   =========================================
  tsx=on     tsx_async_abort=full   The system will use VERW to clear CPU
                                    buffers. Cross-thread attacks still possible
                                    on SMT machines.
  tsx=on     tsx_async_abort=full,nosmt As above, cross-thread attacks on SMT
                                    mitigated.
  tsx=on     tsx_async_abort=off    The system is vulnerable.
  tsx=off    tsx_async_abort=full   TSX is disabled. System is not vulnerable.
  tsx=off    tsx_async_abort=full,nosmt ditto
  tsx=off    tsx_async_abort=off    ditto
  =========  ====================   =========================================
Quoted 5 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 208

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +3 -0
+For unaffected platforms "tsx=on" and "tsx_async_abort=full" does not clear CPU
+buffers.  For platforms without TSX control "tsx" command line argument has no
+effect.

Which platforms are those?

The MDS_NO=0 ones.

Quoted 15 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 221

Quoted 13 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +12 -0
+For the affected platforms below table indicates the mitigation status for the
+combinations of CPUID bit MD_CLEAR and IA32_ARCH_CAPABILITIES MSR bits MDS_NO
+and TSX_CTRL_MSR.
+
+  =======  =========  =============  ========================================
+  MDS_NO   MD_CLEAR   TSX_CTRL_MSR   Status
+  =======  =========  =============  ========================================
+    0          0            0        Vulnerable (needs ucode)
+    0          1            0        MDS and TAA mitigated via VERW
+    1          1            0        MDS fixed, TAA vulnerable if TSX enabled
+                                     because MD_CLEAR has no meaning and
+                                     VERW is not guaranteed to clear buffers

(needs ucode) ?

Will there even be microcode for those to beef up VERW?

Quoted 10 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 242

Quoted 6 lines

+2. Untrusted userspace and guests
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+
+If there are untrusted applications or guests on the system, enabling TSX
+might allow a malicious actor to leak data from the host or from other
+processes running on the same physical core.

Unless the mitigation is enabled (which is on by default, BTW...)

This makes it sounds like the only mitigation is to disable TSX.

"If there are untrusted applications or guests on the system, enabling TSX and the inability to enable the TAA mitigation (missing microcode for a particular model, etc.) might allow a malicious actor to leak data from the host or from other processes running on the same physical core."

Quoted 6 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 246

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +3 -0
+If the microcode is available and the TSX is disabled on the host, attacks
+are prevented in a virtualized environment as well, even if the VMs do not
+explicitly enable the mitigation.

What's the effect on VM security if TSX is enabled and the host TAA mitigation is also enabled?

Same as in the !VM case, I'd assume. tsx_async_abort=full,nosmt should give you full mitigation.

Quoted 6 lines

Documentation/admin-guide/kernel-parameters.txt line 4887

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+			This parameter controls the TAA mitigation.  The
+			options are:
+
+			full       - Enable TAA mitigation on vulnerable CPUs

if TSX is disabled

No, that's TAA_MITIGATION_VERW which does the buffer clearing.

Quoted 7 lines

Documentation/x86/tsx_async_abort.rst line 25

Quoted 5 lines
Documentation/x86/tsx_async_abort.rst new file +5 -0
+Mitigation strategy
+-------------------
+
+a) TSX disable - one of the mitigations is to disable TSX. A new MSR
+IA32_TSX_CTRL will be available in future and current processors after

which processors?

The MDS_NO=1 and future parts, I guess.

Quoted 9 lines

Documentation/x86/tsx_async_abort.rst line 31

Quoted 7 lines
Documentation/x86/tsx_async_abort.rst new file +6 -0
+microcode update which can be used to disable TSX. In addition, it
+controls the enumeration of the TSX feature bits (RTM and HLE) in CPUID.
+
+b) Clear CPU buffers - similar to MDS, clearing the CPU buffers mitigates this
+vulnerability. More details on this approach can be found in
+:ref:`Documentation/admin-guide/hw-vuln/mds.rst <mds>`.

It should be clarified the mitigation is a) OR b), not both.

Yah, the default one is b).

        if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
                taa_mitigation = TAA_MITIGATION_VERW;
        else
                taa_mitigation = TAA_MITIGATION_UCODE_NEEDED;

unless nothing has been specified on the cmdline and it depends on what CONFIG_X86_INTEL_TSX_MODE* has been enabled in .config. I know, it is a mouthful.

Quoted 11 lines

Documentation/x86/tsx_async_abort.rst line 69

Quoted 9 lines

+1. "tsx=off"

Documentation/x86/tsx_async_abort.rst new file +8 -0
+
+=========  =========  ============  ============  ==============  ===================  ======================
+MSR_IA32_ARCH_CAPABILITIES bits     Result with cmdline tsx=off
+----------------------------------  -------------------------------------------------------------------------
+TAA_NO     MDS_NO     TSX_CTRL_MSR  TSX state     VERW can clear  TAA mitigation       TAA mitigation
+                                    after bootup  CPU buffers     tsx_async_abort=off  tsx_async_abort=full
+=========  =========  ============  ============  ==============  ===================  ======================
+    0          0           0         HW default         Yes           Same as MDS           Same as MDS

Does "HW default" mean "Enabled"?

I'd assume coming out of reset, TSX is enabled. Question for Intel folks.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
-- 
#72 lore raw

[MODERATED] Re: [PATCH 8/9] TAA 8

Quoted 12 lines · speck for Borislav Petkov
Quoted 10 lines · speck for Josh Poimboeuf

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 145

Quoted 5 lines · speck for Pawan Gupta
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +5 -0
+Virtualization mitigation
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Affected systems where the host has the TAA microcode and the TAA mitigation is
+ON (with TSX disabled) are not vulnerable regardless of the status of the VMs.

This is is confusing: "the TAA mitigation is ON (with TSX disabled)".

Which is it? Is the TAA mitigation on, or is TSX disabled?

Quoted 8 lines

I think it wants to say:

"Affected systems where the host has TAA microcode and TAA is mitigated by having disabled TSX, are not vulnerable..."

Quoted 1 line

This is not universally true.

"Disables TSX on systems which have the TSX-disable MSR."

Maybe use the same wording from kernel-parameters.txt?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ on Enables TSX.

This probably needs the same "TSX is fundamentally insecure" caveat I proposed for kernel-parameters.txt.

I'm great at copy'n'paste:

Quoted 13 lines

"Enables TSX.

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."

Quoted 5 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 190

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +2 -0
+
+  auto		Disables TSX on affected platform, otherwise enables TSX.

This is not universally true.

Ditto, I guess whatever wording is used in kernel-parameters.txt can be cribbed for here.

Quoted 8 lines
Quoted 2 lines

Also, it would be relevant to refer to that table Pawan posted which shows exactly which CPUs are vulnerable to TAA but not MDS.

This one?

I don't know whether this one will get more models later or what the TAA_NO plan is...

Quoted 9 lines
+----------------------------+------------------+------------+
|            Name            |  Family / model  |  Stepping  |
+============================+==================+============+
| Whiskey Lake (ULT refresh) |      06_8E       |    0xC     |
+----------------------------+------------------+------------+
|    2nd gen Cascade Lake    |      06_55       |    6, 7    |
+----------------------------+------------------+------------+
|       Coffee Lake R        |      06_9E       |    0xD     |
+----------------------------+------------------+------------+

That's the one, but yeah... it might not be future-complete, and even if it is, Intel probably doesn't want to disclose that anyway.

Quoted 20 lines
Quoted 13 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 200

Quoted 10 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+  ============  =============================================================
+
+Not specifying this option is equivalent to "tsx=off".
+
+The following combinations of the "tsx_async_abort" and "tsx" are possible. For
+affected platforms tsx=auto is equivalent to tsx=off and the result will be:
+
+  =========  ====================   =========================================
+  tsx=on     tsx_async_abort=full   The system will use VERW to clear CPU
+                                    buffers.

The system may still be vulnerable to SMT-based attacks.

Quoted 6 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 204

Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+  tsx=on     tsx_async_abort=off    The system is vulnerable.
+  tsx=off    tsx_async_abort=full   TSX is disabled. System is not vulnerable.
+  tsx=off    tsx_async_abort=off    TSX is disabled. System is not vulnerable.
+  =========  ====================   =========================================

Combinations with tsx_async_abort=full,nosmt should also be described.

Quoted 8 lines
  =========  ====================   =========================================
  tsx=on     tsx_async_abort=full   The system will use VERW to clear CPU
                                    buffers. Cross-thread attacks still possible
                                    on SMT machines.
  tsx=on     tsx_async_abort=full,nosmt As above, cross-thread attacks on SMT
                                    mitigated.
  tsx=on     tsx_async_abort=off    The system is vulnerable.
  tsx=off    tsx_async_abort=full   TSX is disabled. System is not vulnerable.

TSX _might_ be disabled, depending...

Quoted 5 lines
  tsx=off    tsx_async_abort=full,nosmt ditto
  tsx=off    tsx_async_abort=off    ditto
  =========  ====================   =========================================
Quoted 7 lines
Quoted 5 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 208

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +3 -0
+For unaffected platforms "tsx=on" and "tsx_async_abort=full" does not clear CPU
+buffers.  For platforms without TSX control "tsx" command line argument has no
+effect.

Which platforms are those?

The MDS_NO=0 ones.

Right, update the wording?

Quoted 17 lines
Quoted 16 lines
Quoted 4 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +2 -0
+For the affected platforms below table indicates the mitigation status for the
+combinations of CPUID bit MD_CLEAR and IA32_ARCH_CAPABILITIES MSR bits MDS_NO

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 221

Quoted 10 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +10 -0
+and TSX_CTRL_MSR.
+
+  =======  =========  =============  ========================================
+  MDS_NO   MD_CLEAR   TSX_CTRL_MSR   Status
+  =======  =========  =============  ========================================
+    0          0            0        Vulnerable (needs ucode)
+    0          1            0        MDS and TAA mitigated via VERW
+    1          1            0        MDS fixed, TAA vulnerable if TSX enabled
+                                     because MD_CLEAR has no meaning and
+                                     VERW is not guaranteed to clear buffers

(needs ucode) ?

Quoted 1 line

Will there even be microcode for those to beef up VERW?

This might be a question for Intel, but I assumed this is the case where the new microcode on the MDS_NO parts would enable the VERW buffer clearing.

Quoted 25 lines
Quoted 11 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 242

Quoted 7 lines

+2. Untrusted userspace and guests
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +4 -0
+
+If there are untrusted applications or guests on the system, enabling TSX
+might allow a malicious actor to leak data from the host or from other
+processes running on the same physical core.

Unless the mitigation is enabled (which is on by default, BTW...)

This makes it sounds like the only mitigation is to disable TSX.

"If there are untrusted applications or guests on the system, enabling TSX and the inability to enable the TAA mitigation (missing microcode for a particular model, etc.) might allow a malicious actor to leak data from the host or from other processes running on the same physical core."

Quoted 6 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 246

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +3 -0
+If the microcode is available and the TSX is disabled on the host, attacks
+are prevented in a virtualized environment as well, even if the VMs do not
+explicitly enable the mitigation.

What's the effect on VM security if TSX is enabled and the host TAA mitigation is also enabled?

Quoted 2 lines

Same as in the !VM case, I'd assume. tsx_async_abort=full,nosmt should give you full mitigation.

Right, the effects of the host mitigation options on the guest would be useful here.

Quoted 8 lines
Quoted 6 lines

Documentation/admin-guide/kernel-parameters.txt line 4887

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+			This parameter controls the TAA mitigation.  The
+			options are:
+
+			full       - Enable TAA mitigation on vulnerable CPUs

if TSX is disabled

No, that's TAA_MITIGATION_VERW which does the buffer clearing.

I meant to say "if TSX is enabled". Otherwise if TSX is disabled this option doesn't do anything

Quoted 9 lines
Quoted 7 lines

Documentation/x86/tsx_async_abort.rst line 25

Quoted 5 lines
Documentation/x86/tsx_async_abort.rst new file +5 -0
+Mitigation strategy
+-------------------
+
+a) TSX disable - one of the mitigations is to disable TSX. A new MSR
+IA32_TSX_CTRL will be available in future and current processors after

which processors?

The MDS_NO=1 and future parts, I guess.

Right, that should be clarified.

Signature · 1 line
Josh
reviewer
#73 lore raw

[MODERATED] Re: [PATCH 8/9] TAA 8

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 221

Quoted 12 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +12 -0
+For the affected platforms below table indicates the mitigation status for the
+combinations of CPUID bit MD_CLEAR and IA32_ARCH_CAPABILITIES MSR bits MDS_NO
+and TSX_CTRL_MSR.
+
+  =======  =========  =============  ========================================
+  MDS_NO   MD_CLEAR   TSX_CTRL_MSR   Status
+  =======  =========  =============  ========================================
+    0          0            0        Vulnerable (needs ucode)
+    0          1            0        MDS and TAA mitigated via VERW
+    1          1            0        MDS fixed, TAA vulnerable if TSX enabled
+                                     because MD_CLEAR has no meaning and
+                                     VERW is not guaranteed to clear buffers

(needs ucode) ?

Quoted 5 lines
Quoted 1 line

Will there even be microcode for those to beef up VERW?

This might be a question for Intel, but I assumed this is the case where the new microcode on the MDS_NO parts would enable the VERW buffer clearing.

That is correct.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst line 246

Quoted 3 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst new file +3 -0
+If the microcode is available and the TSX is disabled on the host, attacks
+are prevented in a virtualized environment as well, even if the VMs do not
+explicitly enable the mitigation.

What's the effect on VM security if TSX is enabled and the host TAA mitigation is also enabled?

Quoted 5 lines
Quoted 2 lines

Same as in the !VM case, I'd assume. tsx_async_abort=full,nosmt should give you full mitigation.

Right, the effects of the host mitigation options on the guest would be useful here.

When TSX is enabled on host part 6/9 exports MDS_NO=0 to VMs, so that VMs deploy MDS mitigation which also mitigates TAA.

Quoted 11 lines
Quoted 9 lines
Quoted 7 lines

Documentation/x86/tsx_async_abort.rst line 25

Quoted 5 lines
Documentation/x86/tsx_async_abort.rst new file +5 -0
+Mitigation strategy
+-------------------
+
+a) TSX disable - one of the mitigations is to disable TSX. A new MSR
+IA32_TSX_CTRL will be available in future and current processors after

which processors?

The MDS_NO=1 and future parts, I guess.

Right, that should be clarified.

This is correct, list of MDS_NO=1 parts shared earlier, and the future parts.

Thanks,
Pawan

#74 lore raw

[MODERATED] Re: [PATCH 8/9] TAA 8

In reply to Josh Poimboeuf
Quoted 2 lines · speck for Josh Poimboeuf

Ditto, I guess whatever wording is used in kernel-parameters.txt can be cribbed for here.

All changed.

Quoted 2 lines

That's the one, but yeah... it might not be future-complete, and even if it is, Intel probably doesn't want to disclose that anyway.

Right, let's shelve adding that table for later.

Quoted 1 line

TSX _might_ be disabled, depending...

Done.

Quoted 1 line

Right, update the wording?

Done.

Quoted 2 lines

Right, the effects of the host mitigation options on the guest would be useful here.

Leaving that as is until the virt patch has been clarified with Paolo.

Quoted 2 lines

I meant to say "if TSX is enabled". Otherwise if TSX is disabled this option doesn't do anything

Done.

Quoted 3 lines
Quoted 1 line

The MDS_NO=1 and future parts, I guess.

Right, that should be clarified.

Leaving that out for now until we agree on publishing such a table.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
--