Skip to content

Commit 2d8eade

Browse files
committed
x86/spec-ctrl: Support Intel PSFD for guests
The Feb 2022 microcode from Intel retrofits AMD's MSR_SPEC_CTRL.PSFD interface to Sunny Cove (IceLake) and later cores. Update the MSR_SPEC_CTRL emulation, and expose it to guests. Signed-off-by: Andrew Cooper <[email protected]> Reviewed-by: Jan Beulich <[email protected]> (cherry picked from commit 52ce1c9)
1 parent b8fec3e commit 2d8eade

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

tools/libs/light/libxl_cpuid.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
234234
{"fsrs", 0x00000007, 1, CPUID_REG_EAX, 11, 1},
235235
{"fsrcs", 0x00000007, 1, CPUID_REG_EAX, 12, 1},
236236

237+
{"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1},
238+
237239
{"lahfsahf", 0x80000001, NA, CPUID_REG_ECX, 0, 1},
238240
{"cmplegacy", 0x80000001, NA, CPUID_REG_ECX, 1, 1},
239241
{"svm", 0x80000001, NA, CPUID_REG_ECX, 2, 1},

tools/misc/xen-cpuid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ static const char *const str_7b1[32] =
199199

200200
static const char *const str_7d2[32] =
201201
{
202+
[ 0] = "intel-psfd",
202203
};
203204

204205
static const struct {

xen/arch/x86/msr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
443443
uint64_t msr_spec_ctrl_valid_bits(const struct cpuid_policy *cp)
444444
{
445445
bool ssbd = cp->feat.ssbd || cp->extd.amd_ssbd;
446-
bool psfd = cp->extd.psfd;
446+
bool psfd = cp->feat.intel_psfd || cp->extd.psfd;
447447

448448
/*
449449
* Note: SPEC_CTRL_STIBP is specified as safe to use (i.e. ignored)

xen/arch/x86/spec_ctrl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,13 @@ custom_param("pv-l1tf", parse_pv_l1tf);
307307

308308
static void __init print_details(enum ind_thunk thunk, uint64_t caps)
309309
{
310-
unsigned int _7d0 = 0, e8b = 0, tmp;
310+
unsigned int _7d0 = 0, _7d2 = 0, e8b = 0, max = 0, tmp;
311311

312312
/* Collect diagnostics about available mitigations. */
313313
if ( boot_cpu_data.cpuid_level >= 7 )
314-
cpuid_count(7, 0, &tmp, &tmp, &tmp, &_7d0);
314+
cpuid_count(7, 0, &max, &tmp, &tmp, &_7d0);
315+
if ( max >= 2 )
316+
cpuid_count(7, 2, &tmp, &tmp, &tmp, &_7d2);
315317
if ( boot_cpu_data.extended_cpuid_level >= 0x80000008 )
316318
cpuid(0x80000008, &tmp, &e8b, &tmp, &tmp);
317319

@@ -345,6 +347,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
345347
(_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "",
346348
(e8b & cpufeat_mask(X86_FEATURE_AMD_SSBD)) ||
347349
(_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "",
350+
(_7d2 & cpufeat_mask(X86_FEATURE_INTEL_PSFD)) ||
348351
(e8b & cpufeat_mask(X86_FEATURE_PSFD)) ? " PSFD" : "",
349352
(_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "",
350353
(_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "",

xen/include/public/arch-x86/cpufeatureset.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ XEN_CPUFEATURE(NSCB, 11*32+ 6) /*A Null Selector Clears Base (and
300300
/* Intel-defined CPU features, CPUID level 0x00000007:1.ebx, word 12 */
301301

302302
/* Intel-defined CPU features, CPUID level 0x00000007:2.edx, word 13 */
303+
XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */
303304

304305
#endif /* XEN_CPUFEATURE */
305306

xen/tools/gen-cpuid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def crunch_numbers(state):
287287
# IBRSB/IBRS, and we pass this MSR directly to guests. Treating them
288288
# as dependent features simplifies Xen's logic, and prevents the guest
289289
# from seeing implausible configurations.
290-
IBRSB: [STIBP, SSBD],
290+
IBRSB: [STIBP, SSBD, INTEL_PSFD],
291291
IBRS: [AMD_STIBP, AMD_SSBD, PSFD,
292292
IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
293293
AMD_STIBP: [STIBP_ALWAYS],

0 commit comments

Comments
 (0)