added more svm intercepts

This commit is contained in:
Stanislav Shwartsman 2011-12-26 20:51:57 +00:00
parent 0de2516d05
commit c32eaa5d05
5 changed files with 56 additions and 0 deletions

View File

@ -635,6 +635,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR2Rq(bxInstruction_c *i)
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_WRITE_INTERCEPTED(2)) Svm_Vmexit(SVM_VMEXIT_CR2_WRITE);
}
#endif
BX_CPU_THIS_PTR cr2 = BX_READ_64BIT_REG(i->rm());
BX_NEXT_INSTR(i);
@ -733,6 +739,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR2(bxInstruction_c *i)
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_READ_INTERCEPTED(2)) Svm_Vmexit(SVM_VMEXIT_CR2_READ);
}
#endif
BX_WRITE_64BIT_REG(i->rm(), BX_CPU_THIS_PTR cr2);
BX_NEXT_INSTR(i);
@ -750,6 +762,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR3(bxInstruction_c *i)
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_READ_INTERCEPTED(3)) Svm_Vmexit(SVM_VMEXIT_CR3_READ);
}
#endif
#if BX_SUPPORT_VMX
if (BX_CPU_THIS_PTR in_vmx_guest)
VMexit_CR3_Read(i);
@ -1180,6 +1198,12 @@ bx_bool BX_CPP_AttrRegparmN(1) BX_CPU_C::SetCR4(bx_address val)
{
if (! check_CR4(val)) return 0;
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_WRITE_INTERCEPTED(4)) Svm_Vmexit(SVM_VMEXIT_CR4_WRITE);
}
#endif
#if BX_CPU_LEVEL >= 6
// Modification of PGE,PAE,PSE,PCIDE,SMEP flushes TLB cache according to docs.
if ((val & BX_CR4_FLUSH_TLB_MASK) != (BX_CPU_THIS_PTR cr4.val32 & BX_CR4_FLUSH_TLB_MASK)) {
@ -1229,6 +1253,12 @@ bx_bool BX_CPP_AttrRegparmN(1) BX_CPU_C::SetCR3(bx_address val)
}
#endif
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_WRITE_INTERCEPTED(3)) Svm_Vmexit(SVM_VMEXIT_CR3_WRITE);
}
#endif
BX_CPU_THIS_PTR cr3 = val;
// flush TLB even if value does not change
@ -1344,6 +1374,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CLTS(bxInstruction_c *i)
}
#endif
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if(SVM_CR_WRITE_INTERCEPTED(0)) Svm_Vmexit(SVM_VMEXIT_CR0_WRITE);
}
#endif
BX_CPU_THIS_PTR cr0.set_TS(0);
#if BX_CPU_LEVEL >= 6

View File

@ -225,6 +225,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::WBINVD(bxInstruction_c *i)
VMexit_WBINVD(i);
#endif
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if (SVM_INTERCEPT(1, SVM_INTERCEPT1_WBINVD)) Svm_Vmexit(SVM_VMEXIT_WBINVD);
}
#endif
invalidate_prefetch_q();
BX_DEBUG(("WBINVD: Flush internal caches !"));

View File

@ -613,6 +613,9 @@ void BX_CPU_C::SvmInterceptException(unsigned type, unsigned vector, Bit16u errc
#define SVM_VMEXIT_IO_INSTR_LEN8 (1 << 4)
#define SVM_VMEXIT_IO_INSTR_LEN16 (1 << 5)
#define SVM_VMEXIT_IO_INSTR_LEN32 (1 << 6)
#define SVM_VMEXIT_IO_INSTR_ASIZE16 (1 << 7)
#define SVM_VMEXIT_IO_INSTR_ASIZE32 (1 << 8)
#define SVM_VMEXIT_IO_INSTR_ASIZE64 (1 << 9)
void BX_CPU_C::SvmInterceptIO(bxInstruction_c *i, unsigned port, unsigned len)
{

View File

@ -329,6 +329,11 @@ typedef struct bx_VMCB_CACHE
#define SVM_INTERCEPT1_SKINIT (1 << 6)
#define SVM_INTERCEPT1_RDTSCP (1 << 7)
#define SVM_INTERCEPT1_ICEBP (1 << 8)
#define SVM_INTERCEPT1_WBINVD (1 << 9)
#define SVM_INTERCEPT1_MONITOR (1 << 10)
#define SVM_INTERCEPT1_MWAIT (1 << 11)
#define SVM_INTERCEPT1_MWAIT_ARMED (1 << 12)
#define SVM_INTERCEPT1_XSETBV (1 << 13)
#define SVM_INTERCEPT(vector, intercept_bit) \
(BX_CPU_THIS_PTR vmcb.ctrls.intercept_vector[vector] & (intercept_bit))

View File

@ -407,6 +407,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::XSETBV(bxInstruction_c *i)
}
#endif
#if BX_SUPPORT_SVM
if (BX_CPU_THIS_PTR in_svm_guest) {
if (SVM_INTERCEPT(1, SVM_INTERCEPT1_XSETBV)) Svm_Vmexit(SVM_VMEXIT_XSETBV);
}
#endif
// CPL is always 3 in vm8086 mode
if (/* v8086_mode() || */ CPL != 0) {
BX_ERROR(("XSETBV: The current priveledge level is not 0"));