VMfailInvalid is expected in this test.
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xtf_warning("Warning: VT-x found on non-Intel processor\n");
test_msr_vmx();
+
+ if ( xtf_status_reported() )
+ return; /* No point continuing if the basic MSRs aren't working. */
+
+ vmx_collect_data();
+
test_vmxon();
xtf_success(NULL);
*/
void check(const char *func, exinfo_t got, exinfo_t exp);
+extern uint32_t vmcs_revid; /**< Hardware VMCS Revision ID. */
+
+/**
+ * Collect real information about the VT-x environment, for use by test.
+ */
+void vmx_collect_data(void);
+
+/* Clear a VMCS, and set a specific revision id. */
+static inline void clear_vmcs(void *_vmcs, uint32_t rev)
+{
+ uint32_t *vmcs = _vmcs;
+
+ memset(vmcs, 0, PAGE_SIZE);
+ vmcs[0] = rev;
+}
+
/* VMX instruction stubs, wrapped to return exinfo_t information. */
exinfo_t stub_vmxon(uint64_t paddr);
exinfo_t stub_vmxon_user(uint64_t paddr);
func, exp, expstr, got, gotstr);
}
+uint32_t vmcs_revid;
+
+void vmx_collect_data(void)
+{
+ msr_vmx_basic_t basic = { rdmsr(MSR_VMX_BASIC) };
+
+ vmcs_revid = basic.vmcs_rev_id;
+}
+
/*
* Read the VM Instruction Error code from the VMCS. It is the callers
* responsibility to ensure that the VMCS is valid in context.
check(__func__, ex, VMERR_INVALID);
}
+/**
+ * vmxon with VMCS revision ID mismatched with MSR_IA32_VMX_BASIC
+ *
+ * Expect: VMfailInvalid
+ */
+static void test_vmxon_mismatched_revid(void)
+{
+ clear_vmcs(vmxon_region_unused, vmcs_revid ^ 2);
+ exinfo_t ex = stub_vmxon(_u(vmxon_region_unused));
+
+ check(__func__, ex, VMERR_INVALID);
+}
+
void test_vmxon(void)
{
unsigned long cr4 = read_cr4();
test_vmxon_in_user();
test_vmxon_overly_wide_paddr();
test_vmxon_unaligned_paddr();
+ test_vmxon_mismatched_revid();
}
/*