File xsa435-0-40.patch of Package xen.32200
From 205a9f970378c31ae3e00b52d59103a2e881b9e0 Mon Sep 17 00:00:00 2001
From: Andrew Cooper <andrew.cooper3@citrix.com>
Date: Mon, 15 May 2023 19:05:01 +0100
Subject: x86/tsx: Remove opencoded MSR_ARCH_CAPS check
The current cpu_has_tsx_ctrl tristate is serving double pupose; to signal the
first pass through tsx_init(), and the availability of MSR_TSX_CTRL.
Drop the variable, replacing it with a once boolean, and altering
cpu_has_tsx_ctrl to come out of the feature information.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/tsx.c
+++ b/xen/arch/x86/tsx.c
@@ -13,7 +13,6 @@
* conditions.
*/
int8_t __read_mostly opt_tsx = -1;
-int8_t __read_mostly cpu_has_tsx_ctrl = -1;
static int __init parse_tsx(const char *s)
{
@@ -30,6 +29,8 @@ custom_param("tsx", parse_tsx);
void tsx_init(void)
{
+ static bool __read_mostly once;
+
/*
* This function is first called between microcode being loaded, and CPUID
* being scanned generally. Calculate from raw data whether MSR_TSX_CTRL
@@ -37,13 +38,13 @@ void tsx_init(void)
*/
if ( unlikely(cpu_has_tsx_ctrl < 0) )
{
- uint64_t caps = 0;
+ once = true;
if ( boot_cpu_data.cpuid_level >= 7 &&
(cpuid_count_edx(7, 0) & cpufeat_mask(X86_FEATURE_ARCH_CAPS)) )
- rdmsrl(MSR_ARCH_CAPABILITIES, caps);
-
- cpu_has_tsx_ctrl = !!(caps & ARCH_CAPS_TSX_CTRL);
+ rdmsr(MSR_ARCH_CAPABILITIES,
+ boot_cpu_data.x86_capability[FEATURESET_m10Al],
+ boot_cpu_data.x86_capability[FEATURESET_m10Ah]);
/*
* The TSX features (HLE/RTM) are handled specially. They both
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -124,6 +124,7 @@
/* MSR_ARCH_CAPS */
#define cpu_has_if_pschange_mc_no boot_cpu_has(X86_FEATURE_IF_PSCHANGE_MC_NO)
+#define cpu_has_tsx_ctrl boot_cpu_has(X86_FEATURE_TSX_CTRL)
/* Synthesized. */
#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -620,7 +620,7 @@ static inline uint8_t get_cpu_family(uin
return fam;
}
-extern int8_t opt_tsx, cpu_has_tsx_ctrl;
+extern int8_t opt_tsx;
void tsx_init(void);
void update_mcu_opt_ctrl(void);