summaryrefslogtreecommitdiff
path: root/xen
diff options
context:
space:
mode:
authorAndrew Cooper <andrew.cooper3@citrix.com>2021-05-20 19:16:11 +0100
committerAndrew Cooper <andrew.cooper3@citrix.com>2021-05-27 19:34:00 +0100
commit9fdcf851689cb2a9501d3947cb5d767d9c7797e8 (patch)
tree87c4c9e52ace3a26a42bb6ad19cb7a5000851b3b /xen
parent3670abcaf0324f2aedba0c4dc7939072b27efa1d (diff)
x86/tsx: Deprecate vpmu=rtm-abort and use tsx=<bool> instead
This reuses the rtm_disable infrastructure, so CPUID derivation works properly when TSX is disabled in favour of working PCR3. vpmu= is not a supported feature, and having this functionality under tsx= centralises all TSX handling. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/x86/cpu/intel.c3
-rw-r--r--xen/arch/x86/cpu/vpmu.c4
-rw-r--r--xen/arch/x86/tsx.c51
-rw-r--r--xen/include/asm-x86/vpmu.h1
4 files changed, 51 insertions, 8 deletions
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index 37439071d9..abf8e206d7 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -356,9 +356,6 @@ static void Intel_errata_workarounds(struct cpuinfo_x86 *c)
(c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47))
__set_bit(X86_FEATURE_CLFLUSH_MONITOR, c->x86_capability);
- if (cpu_has_tsx_force_abort && opt_rtm_abort)
- wrmsrl(MSR_TSX_FORCE_ABORT, TSX_FORCE_ABORT_RTM);
-
probe_c3_errata(c);
}
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index d8659c63f8..16e91a3694 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -49,7 +49,6 @@ CHECK_pmu_params;
static unsigned int __read_mostly opt_vpmu_enabled;
unsigned int __read_mostly vpmu_mode = XENPMU_MODE_OFF;
unsigned int __read_mostly vpmu_features = 0;
-bool __read_mostly opt_rtm_abort;
static DEFINE_SPINLOCK(vpmu_lock);
static unsigned vpmu_count;
@@ -79,7 +78,8 @@ static int __init parse_vpmu_params(const char *s)
else if ( !cmdline_strcmp(s, "arch") )
vpmu_features |= XENPMU_FEATURE_ARCH_ONLY;
else if ( (val = parse_boolean("rtm-abort", s, ss)) >= 0 )
- opt_rtm_abort = val;
+ printk(XENLOG_WARNING
+ "'rtm-abort=<bool>' superseded. Use 'tsx=<bool>' instead\n");
else
rc = -EINVAL;
diff --git a/xen/arch/x86/tsx.c b/xen/arch/x86/tsx.c
index 98ecb71a4a..338191df7f 100644
--- a/xen/arch/x86/tsx.c
+++ b/xen/arch/x86/tsx.c
@@ -6,7 +6,9 @@
* Valid values:
* 1 => Explicit tsx=1
* 0 => Explicit tsx=0
- * -1 => Default, implicit tsx=1, may change to 0 to mitigate TAA
+ * -1 => Default, altered to 0/1 (if unspecified) by:
+ * - TAA heuristics/settings for speculative safety
+ * - "TSX vs PCR3" select for TSX memory ordering safety
* -3 => Implicit tsx=1 (feed-through from spec-ctrl=0)
*
* This is arranged such that the bottom bit encodes whether TSX is actually
@@ -50,6 +52,26 @@ void tsx_init(void)
cpu_has_tsx_ctrl = !!(caps & ARCH_CAPS_TSX_CTRL);
+ if ( cpu_has_tsx_force_abort )
+ {
+ /*
+ * On an early TSX-enable Skylake part subject to the memory
+ * ordering erratum, with at least the March 2019 microcode.
+ */
+
+ /*
+ * If no explicit tsx= option is provided, pick a default.
+ *
+ * This deliberately overrides the implicit opt_tsx=-3 from
+ * `spec-ctrl=0` because:
+ * - parse_spec_ctrl() ran before any CPU details where know.
+ * - We now know we're running on a CPU not affected by TAA (as
+ * TSX_FORCE_ABORT is enumerated).
+ */
+ if ( opt_tsx < 0 )
+ opt_tsx = 1;
+ }
+
/*
* The TSX features (HLE/RTM) are handled specially. They both
* enumerate features but, on certain parts, have mechanisms to be
@@ -75,6 +97,12 @@ void tsx_init(void)
}
}
+ /*
+ * Note: MSR_TSX_CTRL is enumerated on TSX-enabled MDS_NO and later parts.
+ * MSR_TSX_FORCE_ABORT is enumerated on TSX-enabled pre-MDS_NO Skylake
+ * parts only. The two features are on a disjoint set of CPUs, and not
+ * offered to guests by hypervisors.
+ */
if ( cpu_has_tsx_ctrl )
{
uint32_t hi, lo;
@@ -90,9 +118,28 @@ void tsx_init(void)
wrmsr(MSR_TSX_CTRL, lo, hi);
}
+ else if ( cpu_has_tsx_force_abort )
+ {
+ /*
+ * On an early TSX-enable Skylake part subject to the memory ordering
+ * erratum, with at least the March 2019 microcode.
+ */
+ uint32_t hi, lo;
+
+ rdmsr(MSR_TSX_FORCE_ABORT, lo, hi);
+
+ /* Check bottom bit only. Higher bits are various sentinels. */
+ rtm_disabled = !(opt_tsx & 1);
+
+ lo &= ~TSX_FORCE_ABORT_RTM;
+ if ( rtm_disabled )
+ lo |= TSX_FORCE_ABORT_RTM;
+
+ wrmsr(MSR_TSX_FORCE_ABORT, lo, hi);
+ }
else if ( opt_tsx >= 0 )
printk_once(XENLOG_WARNING
- "MSR_TSX_CTRL not available - Ignoring tsx= setting\n");
+ "TSX controls not available - Ignoring tsx= setting\n");
}
/*
diff --git a/xen/include/asm-x86/vpmu.h b/xen/include/asm-x86/vpmu.h
index 55f85ba00f..4b0a6ba3da 100644
--- a/xen/include/asm-x86/vpmu.h
+++ b/xen/include/asm-x86/vpmu.h
@@ -126,7 +126,6 @@ static inline int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
extern unsigned int vpmu_mode;
extern unsigned int vpmu_features;
-extern bool opt_rtm_abort;
/* Context switch */
static inline void vpmu_switch_from(struct vcpu *prev)