]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
vvmx: Test whether MSR_IA32_VMX_BASIC is set correctly
authorHaozhong Zhang <haozhong.zhang@intel.com>
Fri, 16 Dec 2016 13:43:35 +0000 (21:43 +0800)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Jun 2017 09:21:42 +0000 (10:21 +0100)
It tests whether bit 31 and bit 48 are 0, and VMCS size is in the
range (0, 4096].

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/msr-index.h
tests/vvmx/msr.c

index 9ac797017b9c9617ed3dd87467e74a13bc61c964..d5cf57ffa8b97235e4aa29a70f3c44ca3f49d25b 100644 (file)
@@ -32,6 +32,9 @@
 #define MSR_PERF_GLOBAL_STATUS          0x0000038e
 #define MSR_PERF_GLOBAL_CTRL            0x0000038f
 #define MSR_PERF_GLOBAL_OVF_CTRL        0x00000390
+
+#define MSR_VMX_BASIC                   0x00000480
+
 #define MSR_A_PMC(n)                   (0x000004c1 + (n))
 
 #define MSR_X2APIC_REGS                 0x00000800
@@ -75,6 +78,21 @@ typedef union msr_feature_control {
     };
 } msr_feature_control_t;
 
+typedef union msr_vmx_basic {
+    uint64_t raw;
+    struct {
+        uint32_t      vmcs_rev_id:31;
+        bool                  mbz:1;
+        uint32_t        vmcs_size:13;
+        uint32_t                 :3;
+        bool          paddr_32bit:1;
+        bool             smm_dual:1;
+        uint32_t    vmcs_mem_type:4;
+        bool     inouts_exit_info:1;
+        bool            true_ctls:1;
+    };
+} msr_vmx_basic_t;
+
 #endif /* !__ASSEMBLY__ */
 #endif /* XFT_X86_MSR_INDEX_H */
 
index 231612f9fa5c7c8b9355b99151f912cbc6875ca4..0c821609ab124de466d365e0ad1af438c372abbc 100644 (file)
@@ -28,11 +28,35 @@ static void test_msr_feature_control(void)
         xtf_failure("Fail: Successfully wrote to MSR_FEATURE_CONTROL\n");
 }
 
+static void test_msr_vmx_basic(void)
+{
+    msr_vmx_basic_t basic;
+
+    if ( rdmsr_safe(MSR_VMX_BASIC, &basic.raw) )
+        return xtf_failure("Fail: Fault when reading MSR_VMX_BASIC\n");
+
+    if ( basic.mbz )
+        xtf_failure("Fail: MSR_VMX_BASIC[31] is not 0\n");
+
+    if ( basic.vmcs_size == 0 )
+        xtf_failure("Fail: VMCS size reported as 0\n");
+    else if ( basic.vmcs_size > 4096 )
+        xtf_failure("Fail: VMCS size (%u) exceeds 4096 limit\n",
+                    basic.vmcs_size);
+
+    if ( cpu_has_lm && basic.paddr_32bit )
+        xtf_failure("Fail: Physical address width limited to 32 bits\n");
+
+    if ( !wrmsr_safe(MSR_VMX_BASIC, basic.raw) )
+        xtf_failure("Fail: Successfully wrote to MSR_VMX_BASIC\n");
+}
+
 void test_msr_vmx(void)
 {
     printk("Test: MSRs\n");
 
     test_msr_feature_control();
+    test_msr_vmx_basic();
 }
 
 /*