[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 4/8] x86: Initial support for WRMSRNS
WRMSR Non-Serialising is an optimisation intended for cases where an MSR needs updating, but architectural serialising properties are not needed. In is anticipated that this will apply to most if not all MSRs modified on context switch paths. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Wei Liu <wl@xxxxxxx> v2: * New --- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 1 + xen/arch/x86/include/asm/msr.h | 12 ++++++++++++ xen/include/public/arch-x86/cpufeatureset.h | 1 + 4 files changed, 15 insertions(+) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index cbd4e511e8ab..8da78773a886 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -235,6 +235,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"fzrm", 0x00000007, 1, CPUID_REG_EAX, 10, 1}, {"fsrs", 0x00000007, 1, CPUID_REG_EAX, 11, 1}, {"fsrcs", 0x00000007, 1, CPUID_REG_EAX, 12, 1}, + {"wrmsrns", 0x00000007, 1, CPUID_REG_EAX, 19, 1}, {"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1}, {"mcdt-no", 0x00000007, 2, CPUID_REG_EDX, 5, 1}, diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index ea7ff320e0e4..f482c4e28f30 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -189,6 +189,7 @@ static const char *const str_7a1[32] = [10] = "fzrm", [11] = "fsrs", [12] = "fsrcs", + /* 18 */ [19] = "wrmsrns", }; static const char *const str_e21a[32] = diff --git a/xen/arch/x86/include/asm/msr.h b/xen/arch/x86/include/asm/msr.h index dd1eee04a637..191e54068856 100644 --- a/xen/arch/x86/include/asm/msr.h +++ b/xen/arch/x86/include/asm/msr.h @@ -38,6 +38,18 @@ static inline void wrmsrl(unsigned int msr, __u64 val) wrmsr(msr, lo, hi); } +/* Non-serialising WRMSR, when available. Falls back to a serialising WRMSR. */ +static inline void wrmsr_ns(uint32_t msr, uint32_t lo, uint32_t hi) +{ + /* + * WRMSR is 2 bytes. WRMSRNS is 3 bytes. Pad WRMSR with a redundant CS + * prefix to avoid a trailing NOP. + */ + alternative_input(".byte 0x2e; wrmsr", + ".byte 0x0f,0x01,0xc6", X86_FEATURE_WRMSRNS, + "c" (msr), "a" (lo), "d" (hi)); +} + /* rdmsr with exception handling */ #define rdmsr_safe(msr,val) ({\ int rc_; \ diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h index ad7e89dd4c40..5444bc5d8374 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -281,6 +281,7 @@ XEN_CPUFEATURE(AVX512_BF16, 10*32+ 5) /*A AVX512 BFloat16 Instructions */ XEN_CPUFEATURE(FZRM, 10*32+10) /*A Fast Zero-length REP MOVSB */ XEN_CPUFEATURE(FSRS, 10*32+11) /*A Fast Short REP STOSB */ XEN_CPUFEATURE(FSRCS, 10*32+12) /*A Fast Short REP CMPSB/SCASB */ +XEN_CPUFEATURE(WRMSRNS, 10*32+19) /* WRMSR Non-Serialising */ /* AMD-defined CPU features, CPUID level 0x80000021.eax, word 11 */ XEN_CPUFEATURE(LFENCE_DISPATCH, 11*32+ 2) /*A LFENCE always serializing */ -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |