[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] tests/tsx: Extend test-tsx to check MSR_MCU_OPT_CTRL



commit 4b45c4faa8c0637eb41cb4b143ccd4e9548c4908
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Jun 10 12:34:45 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Feb 8 18:00:08 2022 +0000

    tests/tsx: Extend test-tsx to check MSR_MCU_OPT_CTRL
    
    This MSR needs to be identical across the system for TSX to have identical
    behaviour everywhere.  Furthermore, its CPUID bit (SRBDS_CTRL) shouldn't be
    visible to guests.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 tools/tests/tsx/test-tsx.c        | 9 ++++++++-
 xen/arch/x86/platform_hypercall.c | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/tests/tsx/test-tsx.c b/tools/tests/tsx/test-tsx.c
index a3d987b6d2..f11e8c54e0 100644
--- a/tools/tests/tsx/test-tsx.c
+++ b/tools/tests/tsx/test-tsx.c
@@ -42,6 +42,7 @@ enum {
 #define  ARCH_CAPS_TSX_CTRL                 (1 <<  7)
 #define MSR_TSX_FORCE_ABORT                 0x0000010f
 #define MSR_TSX_CTRL                        0x00000122
+#define MSR_MCU_OPT_CTRL                    0x00000123
 
 static unsigned int nr_failures;
 #define fail(fmt, ...)                          \
@@ -155,6 +156,10 @@ static void test_tsx_msrs(void)
     printf("Testing MSR_TSX_CTRL consistency\n");
     test_tsx_msr_consistency(
         MSR_TSX_CTRL, host.msr.arch_caps.tsx_ctrl);
+
+    printf("Testing MSR_MCU_OPT_CTRL consistency\n");
+    test_tsx_msr_consistency(
+        MSR_MCU_OPT_CTRL, host.cpuid.feat.srbds_ctrl);
 }
 
 /*
@@ -313,7 +318,8 @@ static void test_guest_policies(const struct xc_cpu_policy 
*max,
 
     if ( ((cm->feat.raw[0].d | cd->feat.raw[0].d) &
           (bitmaskof(X86_FEATURE_TSX_FORCE_ABORT) |
-           bitmaskof(X86_FEATURE_RTM_ALWAYS_ABORT))) ||
+           bitmaskof(X86_FEATURE_RTM_ALWAYS_ABORT) |
+           bitmaskof(X86_FEATURE_SRBDS_CTRL))) ||
          ((mm->arch_caps.raw | md->arch_caps.raw) & ARCH_CAPS_TSX_CTRL) )
         fail("  Xen-only TSX controls offered to guest\n");
 
@@ -388,6 +394,7 @@ static void test_guest(struct xen_domctl_createdomain *c)
     if ( guest_policy.cpuid.feat.hle ||
          guest_policy.cpuid.feat.tsx_force_abort ||
          guest_policy.cpuid.feat.rtm_always_abort ||
+         guest_policy.cpuid.feat.srbds_ctrl ||
          guest_policy.msr.arch_caps.tsx_ctrl )
         fail("  Unexpected features advertised\n");
 
diff --git a/xen/arch/x86/platform_hypercall.c 
b/xen/arch/x86/platform_hypercall.c
index 284c2dfb9e..bf4090c942 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -80,6 +80,9 @@ static bool msr_read_allowed(unsigned int msr)
 
     case MSR_TSX_CTRL:
         return cpu_has_tsx_ctrl;
+
+    case MSR_MCU_OPT_CTRL:
+        return cpu_has_srbds_ctrl;
     }
 
     if ( ppin_msr && msr == ppin_msr )
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.