From: Andrew Cooper Date: Sat, 6 Apr 2024 19:25:43 +0000 (+0100) Subject: Extend rtm-check to report the RTM_ALWAYS_ABORT flag X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=HEAD;p=xtf.git Extend rtm-check to report the RTM_ALWAYS_ABORT flag Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/include/arch/cpuid.h b/arch/x86/include/arch/cpuid.h index e6d6a8c..364b0b4 100644 --- a/arch/x86/include/arch/cpuid.h +++ b/arch/x86/include/arch/cpuid.h @@ -47,8 +47,9 @@ static inline bool vendor_is(enum x86_vendor v) #define FEATURESET_7c0 cpufeat_word(X86_FEATURE_PREFETCHWT1) #define FEATURESET_e7d cpufeat_word(X86_FEATURE_ITSC) #define FEATURESET_e8b cpufeat_word(X86_FEATURE_CLZERO) +#define FEATURESET_7d0 cpufeat_word(X86_FEATURE_RTM_ALWAYS_ABORT) -#define FSCAPINTS (FEATURESET_e8b + 1) +#define FSCAPINTS (FEATURESET_7d0 + 1) extern uint32_t x86_features[FSCAPINTS]; @@ -98,6 +99,8 @@ static inline bool cpu_has(unsigned int feature) #define cpu_has_umip cpu_has(X86_FEATURE_UMIP) #define cpu_has_pku cpu_has(X86_FEATURE_PKU) +#define cpu_has_rtm_always_abort cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT) + #endif /* XTF_X86_CPUID_H */ /* diff --git a/arch/x86/setup.c b/arch/x86/setup.c index d47fb62..c797e57 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -71,7 +71,7 @@ static void collect_cpuid(cpuid_count_fn_t cpuid_fn) cpuid_fn(7, 0, &tmp, &x86_features[FEATURESET_7b0], &x86_features[FEATURESET_7c0], - &tmp); + &x86_features[FEATURESET_7d0]); if ( max_leaf >= 0xd ) cpuid_fn(0xd, 0, &x86_features[FEATURESET_Da1], diff --git a/include/xen/arch-x86/cpufeatureset.h b/include/xen/arch-x86/cpufeatureset.h index f66a4ab..0604780 100644 --- a/include/xen/arch-x86/cpufeatureset.h +++ b/include/xen/arch-x86/cpufeatureset.h @@ -155,6 +155,9 @@ /* AMD-defined CPU features, CPUID level 0x80000008.ebx, word 8 */ #define X86_FEATURE_CLZERO (8*32+ 0) /* CLZERO instruction */ +/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ +#define X86_FEATURE_RTM_ALWAYS_ABORT (9*32+11) /* RTM disabled (XBEGIN aborts) */ + #endif /* XEN_PUBLIC_ARCH_X86_CPUFEATURESET_H */ /* diff --git a/tests/rtm-check/main.c b/tests/rtm-check/main.c index eadee26..fafb10e 100644 --- a/tests/rtm-check/main.c +++ b/tests/rtm-check/main.c @@ -15,8 +15,8 @@ const char test_title[] = "Test RTM behaviour"; void test_main(void) { - printk("CPUID: HLE %u, RTM %u\n", - cpu_has_hle, cpu_has_rtm); + printk("CPUID: HLE %u, RTM %u, RTM_ALWAYS_ABORT %u\n", + cpu_has_hle, cpu_has_rtm, cpu_has_rtm_always_abort); for ( int i = 0; i < 1000; ++i ) {