add vmcs revision id interface to CPUID class

This commit is contained in:
Stanislav Shwartsman 2013-10-14 18:35:56 +00:00
parent f3e10ea276
commit e1012f1165
3 changed files with 13 additions and 8 deletions

View File

@ -57,6 +57,12 @@ public:
virtual int wrmsr(Bit32u index, Bit64u msr) { return -1; }
#endif
#define BX_VMX_VMCS_REVISION_ID 0x2B /* better to be unique bochs VMCS revision id */
#if BX_SUPPORT_VMX
virtual Bit32u get_vmcs_revision_id(void) const { return BX_VMX_VMCS_REVISION_ID; }
#endif
protected:
BX_CPU_C *cpu;

View File

@ -1649,9 +1649,9 @@ Bit32u BX_CPU_C::VMenterLoadCheckGuestState(Bit64u *qualification)
}
revision &= ~BX_VMCS_SHADOW_BIT_MASK;
}
if (revision != VMX_VMCS_REVISION_ID) {
if (revision != BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()) {
*qualification = (Bit64u) VMENTER_ERR_GUEST_STATE_LINK_POINTER;
BX_ERROR(("VMFAIL: VMCS link pointer incorrect revision ID %d != %d", revision, VMX_VMCS_REVISION_ID));
BX_ERROR(("VMFAIL: VMCS link pointer incorrect revision ID %d != %d", revision, BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()));
return VMX_VMEXIT_VMENTRY_FAILURE_GUEST_STATE;
}
@ -2543,8 +2543,8 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMXON(bxInstruction_c *i)
// not allowed to be shadow VMCS
Bit32u revision = VMXReadRevisionID((bx_phy_address) pAddr);
if (revision != VMX_VMCS_REVISION_ID) {
BX_ERROR(("VMXON: not expected (%d != %d) VMCS revision id !", revision, VMX_VMCS_REVISION_ID));
if (revision != BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()) {
BX_ERROR(("VMXON: not expected (%d != %d) VMCS revision id !", revision, BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()));
VMfailInvalid();
BX_NEXT_INSTR(i);
}
@ -2915,8 +2915,8 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMPTRLD(bxInstruction_c *i)
if (BX_SUPPORT_VMX_EXTENSION(BX_VMX_VMCS_SHADOWING))
revision &= ~BX_VMCS_SHADOW_BIT_MASK; // allowed to be shadow VMCS
if (revision != VMX_VMCS_REVISION_ID) {
BX_ERROR(("VMPTRLD: not expected (%d != %d) VMCS revision id !", revision, VMX_VMCS_REVISION_ID));
if (revision != BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()) {
BX_ERROR(("VMPTRLD: not expected (%d != %d) VMCS revision id !", revision, BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id()));
VMfail(VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
}
else {

View File

@ -25,7 +25,6 @@
#define _BX_VMX_INTEL_H_
#define VMX_VMCS_AREA_SIZE 4096
#define VMX_VMCS_REVISION_ID 0x10 /* better to be uniq bochs VMCS revision id */
// VMCS pointer is always 64-bit variable
#define BX_INVALID_VMCSPTR BX_CONST64(0xFFFFFFFFFFFFFFFF)
@ -803,7 +802,7 @@ typedef struct bx_VMCS
// 56:63 reserved, must be zero
//
#define VMX_MSR_VMX_BASIC_LO (VMX_VMCS_REVISION_ID)
#define VMX_MSR_VMX_BASIC_LO (BX_CPU_THIS_PTR cpuid->get_vmcs_revision_id())
#define VMX_MSR_VMX_BASIC_HI \
(VMX_VMCS_AREA_SIZE | ((!bx_cpuid_support_x86_64()) << 16) | \
(BX_MEMTYPE_WB << 18) | (1<<22)) | ((BX_SUPPORT_VMX >= 2) ? (1<<23) : 0)