Changeset 72849 in vbox
- Timestamp:
- Jul 4, 2018 5:27:56 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r72848 r72849 153 153 154 154 /** Assert that preemption is disabled or covered by thread-context hooks. */ 155 #define HMVMX_ASSERT_PREEMPT_SAFE() Assert( VMMR0ThreadCtxHookIsEnabled(pVCpu) \156 || !RTThreadPreemptIsEnabled(NIL_RTTHREAD));155 #define HMVMX_ASSERT_PREEMPT_SAFE() Assert( VMMR0ThreadCtxHookIsEnabled(pVCpu) \ 156 || !RTThreadPreemptIsEnabled(NIL_RTTHREAD)) 157 157 158 158 /** Assert that we haven't migrated CPUs when thread-context hooks are not 159 159 * used. */ 160 #define HMVMX_ASSERT_CPU_SAFE() AssertMsg( VMMR0ThreadCtxHookIsEnabled(pVCpu) \ 161 || pVCpu->hm.s.idEnteredCpu == RTMpCpuId(), \ 162 ("Illegal migration! Entered on CPU %u Current %u\n", \ 163 pVCpu->hm.s.idEnteredCpu, RTMpCpuId())); \ 160 #define HMVMX_ASSERT_CPU_SAFE() AssertMsg( VMMR0ThreadCtxHookIsEnabled(pVCpu) \ 161 || pVCpu->hm.s.idEnteredCpu == RTMpCpuId(), \ 162 ("Illegal migration! Entered on CPU %u Current %u\n", \ 163 pVCpu->hm.s.idEnteredCpu, RTMpCpuId())) 164 165 /** Asserts that the given CPUMCTX_EXTRN_XXX bits are present in the guest-CPU 166 * context. */ 167 #define HMVMX_CPUMCTX_ASSERT(pVCpu, fExtrnMbz) AssertMsg(!((pVCpu)->cpum.GstCtx.fExtrn & (fExtrnMbz)), \ 168 ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", (pVCpu)->cpum.GstCtx.fExtrn, \ 169 (fExtrnMbz))) 164 170 165 171 /** Helper macro for VM-exit handlers called unexpectedly. */ … … 3391 3397 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_APIC_TPR) 3392 3398 { 3399 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_APIC_TPR); 3400 3393 3401 if ( PDMHasApic(pVCpu->CTX_SUFF(pVM)) 3394 3402 && APICIsEnabled(pVCpu)) … … 3535 3543 Assert(pVCpu->hm.s.vmx.u32XcptBitmap & RT_BIT_32(X86_XCPT_DB)); 3536 3544 3545 /** @todo Optimize by checking cache before writing to VMCS. */ 3537 3546 int rc = VMXWriteVmcs32(VMX_VMCS32_CTRL_EXCEPTION_BITMAP, pVCpu->hm.s.vmx.u32XcptBitmap); 3538 3547 AssertRCReturn(rc, rc); … … 3561 3570 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_RIP) 3562 3571 { 3572 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_RIP); 3573 3563 3574 rc = VMXWriteVmcsGstN(VMX_VMCS_GUEST_RIP, pMixedCtx->rip); 3564 3575 AssertRCReturn(rc, rc); … … 3592 3603 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_RSP) 3593 3604 { 3605 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_RSP); 3606 3594 3607 int rc = VMXWriteVmcsGstN(VMX_VMCS_GUEST_RSP, pMixedCtx->rsp); 3595 3608 AssertRCReturn(rc, rc); … … 3616 3629 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_RFLAGS) 3617 3630 { 3631 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_RFLAGS); 3632 3618 3633 /* Intel spec. 2.3.1 "System Flags and Fields in IA-32e Mode" claims the upper 32-bits of RFLAGS are reserved (MBZ). 3619 3634 Let us assert it as such and use 32-bit VMWRITE. */ … … 3666 3681 { 3667 3682 PVM pVM = pVCpu->CTX_SUFF(pVM); 3683 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0); 3668 3684 Assert(!RT_HI_U32(pMixedCtx->cr0)); 3685 3669 3686 uint32_t const u32ShadowCr0 = pMixedCtx->cr0; 3670 3687 uint32_t u32GuestCr0 = pMixedCtx->cr0; … … 3846 3863 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_CR3) 3847 3864 { 3865 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR3); 3866 3848 3867 RTGCPHYS GCPhysGuestCR3 = NIL_RTGCPHYS; 3849 3868 if (pVM->hm.s.fNestedPaging) … … 3942 3961 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_CR4) 3943 3962 { 3963 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR4); 3944 3964 Assert(!RT_HI_U32(pMixedCtx->cr4)); 3965 3945 3966 uint32_t u32GuestCr4 = pMixedCtx->cr4; 3946 3967 uint32_t const u32ShadowCr4 = pMixedCtx->cr4; … … 4478 4499 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_CS) 4479 4500 { 4501 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CS); 4480 4502 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4481 4503 pVCpu->hm.s.vmx.RealMode.AttrCS.u = pMixedCtx->cs.Attr.u; … … 4487 4509 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_SS) 4488 4510 { 4511 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_SS); 4489 4512 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4490 4513 pVCpu->hm.s.vmx.RealMode.AttrSS.u = pMixedCtx->ss.Attr.u; … … 4496 4519 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_DS) 4497 4520 { 4521 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_DS); 4498 4522 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4499 4523 pVCpu->hm.s.vmx.RealMode.AttrDS.u = pMixedCtx->ds.Attr.u; … … 4505 4529 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_ES) 4506 4530 { 4531 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_ES); 4507 4532 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4508 4533 pVCpu->hm.s.vmx.RealMode.AttrES.u = pMixedCtx->es.Attr.u; … … 4514 4539 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_FS) 4515 4540 { 4541 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_FS); 4516 4542 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4517 4543 pVCpu->hm.s.vmx.RealMode.AttrFS.u = pMixedCtx->fs.Attr.u; … … 4523 4549 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_GS) 4524 4550 { 4551 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_GS); 4525 4552 if (pVCpu->hm.s.vmx.RealMode.fRealOnV86Active) 4526 4553 pVCpu->hm.s.vmx.RealMode.AttrGS.u = pMixedCtx->gs.Attr.u; … … 4547 4574 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_TR) 4548 4575 { 4576 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_TR); 4577 4549 4578 /* 4550 4579 * Real-mode emulation using virtual-8086 mode with CR4.VME. Interrupt redirection is … … 4614 4643 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_GDTR) 4615 4644 { 4645 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_GDTR); 4646 4616 4647 rc = VMXWriteVmcs32(VMX_VMCS32_GUEST_GDTR_LIMIT, pMixedCtx->gdtr.cbGdt); 4617 4648 rc |= VMXWriteVmcsGstN(VMX_VMCS_GUEST_GDTR_BASE, pMixedCtx->gdtr.pGdt); … … 4630 4661 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_LDTR) 4631 4662 { 4663 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_LDTR); 4664 4632 4665 /* The unusable bit is specific to VT-x, if it's a null selector mark it as an unusable segment. */ 4633 4666 uint32_t u32Access = 0; … … 4667 4700 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_IDTR) 4668 4701 { 4702 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_IDTR); 4703 4669 4704 rc = VMXWriteVmcs32(VMX_VMCS32_GUEST_IDTR_LIMIT, pMixedCtx->idtr.cbIdt); 4670 4705 rc |= VMXWriteVmcsGstN(VMX_VMCS_GUEST_IDTR_BASE, pMixedCtx->idtr.pIdt); … … 4716 4751 { 4717 4752 #if HC_ARCH_BITS == 32 4753 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_SYSCALL_MSRS | CPUMCTX_EXTRN_KERNEL_GS_BASE); 4754 4718 4755 int rc = hmR0VmxAddAutoLoadStoreMsr(pVCpu, MSR_K8_LSTAR, pMixedCtx->msrLSTAR, false, NULL); 4719 4756 rc |= hmR0VmxAddAutoLoadStoreMsr(pVCpu, MSR_K6_STAR, pMixedCtx->msrSTAR, false, NULL); … … 4738 4775 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_SYSENTER_MSR_MASK) 4739 4776 { 4777 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_SYSENTER_MSRS); 4778 4740 4779 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_SYSENTER_CS_MSR) 4741 4780 { … … 4762 4801 if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_GUEST_EFER_MSR) 4763 4802 { 4803 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_EFER); 4804 4764 4805 if (hmR0VmxShouldSwapEferMsr(pVCpu, pMixedCtx)) 4765 4806 {
Note:
See TracChangeset
for help on using the changeset viewer.

