Changeset 87515 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Feb 1, 2021 7:13:42 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142540
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r87511 r87515 988 988 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 989 989 AssertReturn(pVM, VERR_INVALID_PARAMETER); 990 Assert(pVM->hm.s.svm.fSupported); 991 990 991 /* 992 * Validate some parameters. 993 */ 994 AssertReturn(pVM->hm.s.svm.fSupported, VERR_INCOMPATIBLE_CONFIG); 995 bool const fNestedPaging = pVM->hm.s.fNestedPagingCfg; 996 AssertReturn( !fNestedPaging 997 || (pVM->hm.s.svm.fFeaturesForRing3 & X86_CPUID_SVM_FEATURE_EDX_NESTED_PAGING), 998 VERR_INCOMPATIBLE_CONFIG); 999 pVM->hmr0.s.fNestedPaging = fNestedPaging; 1000 1001 /* 1002 * Determin some configuration parameters. 1003 */ 992 1004 bool const fPauseFilter = RT_BOOL(pVM->hmr0.s.svm.fFeatures & X86_CPUID_SVM_FEATURE_EDX_PAUSE_FILTER); 993 1005 bool const fPauseFilterThreshold = RT_BOOL(pVM->hmr0.s.svm.fFeatures & X86_CPUID_SVM_FEATURE_EDX_PAUSE_FILTER_THRESHOLD); … … 999 1011 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM 1000 1012 bool const fVirtVmsaveVmload = RT_BOOL(pVM->hmr0.s.svm.fFeatures & X86_CPUID_SVM_FEATURE_EDX_VIRT_VMSAVE_VMLOAD); 1001 bool const fUseVirtVmsaveVmload = fVirtVmsaveVmload && pVM->hm.s.svm.fVirtVmsaveVmload && pVM->hm.s.fNestedPaging;1013 bool const fUseVirtVmsaveVmload = fVirtVmsaveVmload && pVM->hm.s.svm.fVirtVmsaveVmload && fNestedPaging; 1002 1014 1003 1015 bool const fVGif = RT_BOOL(pVM->hmr0.s.svm.fFeatures & X86_CPUID_SVM_FEATURE_EDX_VGIF); … … 1109 1121 1110 1122 /* Setup Nested Paging. This doesn't change throughout the execution time of the VM. */ 1111 pVmcbCtrl0->NestedPagingCtrl.n.u1NestedPaging = pVM->hm.s.fNestedPaging;1123 pVmcbCtrl0->NestedPagingCtrl.n.u1NestedPaging = fNestedPaging; 1112 1124 1113 1125 /* Without Nested Paging, we need additionally intercepts. */ 1114 if (! pVM->hm.s.fNestedPaging)1126 if (!fNestedPaging) 1115 1127 { 1116 1128 /* CR3 reads/writes must be intercepted; our shadow values differ from the guest values. */ … … 1530 1542 1531 1543 /* When Nested Paging is not available use shadow page tables and intercept #PFs (latter done in SVMR0SetupVM()). */ 1532 if (!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging)1544 if (!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging) 1533 1545 { 1534 1546 uShadowCr0 |= X86_CR0_PG /* Use shadow page tables. */ … … 1605 1617 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 1606 1618 1607 PVMCC 1619 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 1608 1620 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 1609 if (pVM->hm .s.fNestedPaging)1621 if (pVM->hmr0.s.fNestedPaging) 1610 1622 { 1611 1623 pVmcb->ctrl.u64NestedPagingCR3 = PGMGetHyperCR3(pVCpu); … … 1635 1647 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 1636 1648 uint64_t uShadowCr4 = pCtx->cr4; 1637 if (!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging)1649 if (!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging) 1638 1650 { 1639 1651 switch (pVCpu->hm.s.enmShadowMode) … … 2205 2217 2206 2218 /* Without nested paging, intercept CR3 reads and writes as we load shadow page tables. */ 2207 if (!pVM->hm .s.fNestedPaging)2219 if (!pVM->hmr0.s.fNestedPaging) 2208 2220 { 2209 2221 pVmcbNstGstCtrl->u16InterceptRdCRx |= RT_BIT(3); … … 2558 2570 * Trap0eHandler() in PGMAllBth.h). 2559 2571 */ 2560 pVmcbNstGstCtrl->NestedPagingCtrl.n.u1NestedPaging = pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging;2572 pVmcbNstGstCtrl->NestedPagingCtrl.n.u1NestedPaging = pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging; 2561 2573 2562 2574 /* Always enable V_INTR_MASKING as we do not want to allow access to the physical APIC TPR. */ … … 2600 2612 Assert(!pVCpu->hmr0.s.svm.fSyncVTpr); 2601 2613 Assert(pVmcbNstGstCtrl->u64IOPMPhysAddr == g_HCPhysIOBitmap); 2602 Assert(RT_BOOL(pVmcbNstGstCtrl->NestedPagingCtrl.n.u1NestedPaging) == pVCpu->CTX_SUFF(pVM)->hm.s.fNestedPaging); 2614 Assert(RT_BOOL(pVmcbNstGstCtrl->NestedPagingCtrl.n.u1NestedPaging) == pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 2615 Assert(pVCpu->CTX_SUFF(pVM)->hm.s.fNestedPagingCfg == pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 2603 2616 } 2604 2617 } … … 3130 3143 | CPUM_CHANGED_TR 3131 3144 | CPUM_CHANGED_HIDDEN_SEL_REGS); 3132 if ( pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging3145 if ( pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging 3133 3146 && CPUMIsGuestPagingEnabledEx(&pVCpu->cpum.GstCtx)) 3134 3147 { … … 4949 4962 { 4950 4963 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 4951 if (pVM->hm .s.fNestedPaging)4964 if (pVM->hmr0.s.fNestedPaging) 4952 4965 { 4953 4966 uint32_t const u32ErrCode = pVmcbNstGstCtrl->u64ExitInfo1; … … 5251 5264 case SVM_EXIT_NPF: 5252 5265 { 5253 Assert(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);5266 Assert(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 5254 5267 return hmR0SvmExitNestedPF(pVCpu, pSvmTransient); 5255 5268 } … … 5962 5975 { 5963 5976 HMSVM_VALIDATE_EXIT_HANDLER_PARAMS(pVCpu, pSvmTransient); 5964 Assert(!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);5977 Assert(!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 5965 5978 5966 5979 VBOXSTRICTRC rcStrict; … … 6819 6832 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 6820 6833 PCPUMCTX pCtx = &pVCpu->cpum.GstCtx; 6821 Assert(pVM->hm .s.fNestedPaging);6834 Assert(pVM->hmr0.s.fNestedPaging); 6822 6835 6823 6836 /* See AMD spec. 15.25.6 "Nested versus Guest Page Faults, Fault Ordering" for VMCB details for #NPF. */ … … 6998 7011 6999 7012 #ifndef HMSVM_ALWAYS_TRAP_TASK_SWITCH 7000 Assert(!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);7013 Assert(!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 7001 7014 #endif 7002 7015 … … 7161 7174 7162 7175 #if defined(HMSVM_ALWAYS_TRAP_ALL_XCPTS) || defined(HMSVM_ALWAYS_TRAP_PF) 7163 if (pVM->hm .s.fNestedPaging)7176 if (pVM->hmr0.s.fNestedPaging) 7164 7177 { 7165 7178 pVCpu->hm.s.Event.fPending = false; /* In case it's a contributory or vectoring #PF. */ … … 7183 7196 #endif 7184 7197 7185 Assert(!pVM->hm .s.fNestedPaging);7198 Assert(!pVM->hmr0.s.fNestedPaging); 7186 7199 7187 7200 /* -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r87491 r87515 947 947 return ( X86_CR0_PE 948 948 | X86_CR0_NE 949 | (pVM->hm .s.fNestedPaging ? 0 : X86_CR0_WP)949 | (pVM->hmr0.s.fNestedPaging ? 0 : X86_CR0_WP) 950 950 | X86_CR0_PG 951 951 | VMX_EXIT_HOST_CR0_IGNORE_MASK); … … 1191 1191 { 1192 1192 /* Validate we are not removing any essential exception intercepts. */ 1193 Assert(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging || !(uXcptMask & RT_BIT(X86_XCPT_PF)));1193 Assert(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging || !(uXcptMask & RT_BIT(X86_XCPT_PF))); 1194 1194 NOREF(pVCpu); 1195 1195 Assert(!(uXcptMask & RT_BIT(X86_XCPT_DB))); … … 2962 2962 VMCPU_FF_SET(pVCpu, VMCPU_FF_TLB_FLUSH); 2963 2963 } 2964 else if (pVM->hm .s.fNestedPaging)2964 else if (pVM->hmr0.s.fNestedPaging) 2965 2965 VMCPU_FF_SET(pVCpu, VMCPU_FF_TLB_FLUSH); 2966 2966 } … … 3026 3026 3027 3027 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 3028 AssertMsg(pVM->hm .s.fNestedPaging && pVM->hm.s.vmx.fVpid,3028 AssertMsg(pVM->hmr0.s.fNestedPaging && pVM->hm.s.vmx.fVpid, 3029 3029 ("hmR0VmxFlushTaggedTlbBoth cannot be invoked unless NestedPaging & VPID are enabled." 3030 "fNestedPaging=%RTbool fVpid=%RTbool", pVM->hm .s.fNestedPaging, pVM->hm.s.vmx.fVpid));3030 "fNestedPaging=%RTbool fVpid=%RTbool", pVM->hmr0.s.fNestedPaging, pVM->hm.s.vmx.fVpid)); 3031 3031 3032 3032 /* … … 3125 3125 AssertPtr(pHostCpu); 3126 3126 Assert(pHostCpu->idCpu != NIL_RTCPUID); 3127 AssertMsg(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging, ("hmR0VmxFlushTaggedTlbEpt cannot be invoked without NestedPaging."));3127 AssertMsg(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging, ("hmR0VmxFlushTaggedTlbEpt cannot be invoked without NestedPaging.")); 3128 3128 AssertMsg(!pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fVpid, ("hmR0VmxFlushTaggedTlbEpt cannot be invoked with VPID.")); 3129 3129 … … 3179 3179 Assert(pHostCpu->idCpu != NIL_RTCPUID); 3180 3180 AssertMsg(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fVpid, ("hmR0VmxFlushTlbVpid cannot be invoked without VPID.")); 3181 AssertMsg(!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging, ("hmR0VmxFlushTlbVpid cannot be invoked with NestedPaging"));3181 AssertMsg(!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging, ("hmR0VmxFlushTlbVpid cannot be invoked with NestedPaging")); 3182 3182 3183 3183 /* … … 3303 3303 * unrestricted guest execution (see hmR3InitFinalizeR0()). 3304 3304 */ 3305 if (pVM->hm .s.fNestedPaging)3305 if (pVM->hmr0.s.fNestedPaging) 3306 3306 { 3307 3307 if (pVM->hm.s.vmx.Msrs.u64EptVpidCaps & MSR_IA32_VMX_EPT_VPID_CAP_INVEPT) … … 3378 3378 * Setup the handler for flushing tagged-TLBs. 3379 3379 */ 3380 if (pVM->hm .s.fNestedPaging && pVM->hm.s.vmx.fVpid)3380 if (pVM->hmr0.s.fNestedPaging && pVM->hm.s.vmx.fVpid) 3381 3381 pVM->hm.s.vmx.enmTlbFlushType = VMXTLBFLUSHTYPE_EPT_VPID; 3382 else if (pVM->hm .s.fNestedPaging)3382 else if (pVM->hmr0.s.fNestedPaging) 3383 3383 pVM->hm.s.vmx.enmTlbFlushType = VMXTLBFLUSHTYPE_EPT; 3384 3384 else if (pVM->hm.s.vmx.fVpid) … … 3864 3864 3865 3865 /* Enable EPT (aka nested-paging). */ 3866 if (pVM->hm .s.fNestedPaging)3866 if (pVM->hmr0.s.fNestedPaging) 3867 3867 fVal |= VMX_PROC_CTLS2_EPT; 3868 3868 … … 3968 3968 3969 3969 /* Without nested paging, INVLPG (also affects INVPCID) and MOV CR3 instructions should cause VM-exits. */ 3970 if (!pVM->hm .s.fNestedPaging)3970 if (!pVM->hmr0.s.fNestedPaging) 3971 3971 { 3972 3972 Assert(!pVM->hm.s.vmx.fUnrestrictedGuest); … … 4110 4110 * #PF - To sync our shadow page tables when nested-paging is not used. 4111 4111 */ 4112 bool const fNestedPaging = pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging;4112 bool const fNestedPaging = pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging; 4113 4113 uint32_t const uXcptBitmap = RT_BIT(X86_XCPT_AC) 4114 4114 | RT_BIT(X86_XCPT_DB) … … 4529 4529 } 4530 4530 4531 /* 4532 * Check that nested paging is supported if enabled and copy over the flag to the 4533 * ring-0 only structure. 4534 */ 4535 bool const fNestedPaging = pVM->hm.s.fNestedPagingCfg; 4536 AssertReturn( !fNestedPaging 4537 || (pVM->hm.s.vmx.Msrs.ProcCtls2.n.allowed1 & VMX_PROC_CTLS2_EPT), /** @todo use a ring-0 copy of ProcCtls2.n.allowed1 */ 4538 VERR_INCOMPATIBLE_CONFIG); 4539 pVM->hmr0.s.fNestedPaging = fNestedPaging; 4540 4531 4541 /* Initialize these always, see hmR3InitFinalizeR0().*/ 4532 4542 pVM->hm.s.vmx.enmTlbFlushEpt = VMXTLBFLUSHEPT_NONE; … … 4951 4961 * actually be used while executing the guest and not the CR4 shadow value). 4952 4962 */ 4953 AssertMsg(pVM->hm.s.fNestedPaging || ( pVCpu->hm.s.enmShadowMode == PGMMODE_PAE 4954 || pVCpu->hm.s.enmShadowMode == PGMMODE_PAE_NX 4955 || pVCpu->hm.s.enmShadowMode == PGMMODE_AMD64 4956 || pVCpu->hm.s.enmShadowMode == PGMMODE_AMD64_NX), 4963 AssertMsg( pVM->hmr0.s.fNestedPaging 4964 || pVCpu->hm.s.enmShadowMode == PGMMODE_PAE 4965 || pVCpu->hm.s.enmShadowMode == PGMMODE_PAE_NX 4966 || pVCpu->hm.s.enmShadowMode == PGMMODE_AMD64 4967 || pVCpu->hm.s.enmShadowMode == PGMMODE_AMD64_NX, 4957 4968 ("enmShadowMode=%u\n", pVCpu->hm.s.enmShadowMode)); 4958 4969 if ((u64GuestEfer & MSR_K6_EFER_NXE) != (u64HostEfer & MSR_K6_EFER_NXE)) … … 5662 5673 */ 5663 5674 uint32_t uProcCtls = pVmcsInfo->u32ProcCtls; 5664 if (pVM->hm .s.fNestedPaging)5675 if (pVM->hmr0.s.fNestedPaging) 5665 5676 { 5666 5677 if (CPUMIsGuestPagingEnabled(pVCpu)) … … 5738 5749 if (pVCpu->hm.s.fTrapXcptGpForLovelyMesaDrv) 5739 5750 uXcptBitmap |= RT_BIT(X86_XCPT_GP); 5740 Assert(pVM->hm .s.fNestedPaging || (uXcptBitmap & RT_BIT(X86_XCPT_PF)));5751 Assert(pVM->hmr0.s.fNestedPaging || (uXcptBitmap & RT_BIT(X86_XCPT_PF))); 5741 5752 5742 5753 /* Apply the hardware specified CR0 fixed bits and enable caching. */ … … 5830 5841 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR3); 5831 5842 5832 if (pVM->hm .s.fNestedPaging)5843 if (pVM->hmr0.s.fNestedPaging) 5833 5844 { 5834 5845 PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo; … … 5964 5975 } 5965 5976 5966 if (pVM->hm .s.fNestedPaging)5977 if (pVM->hmr0.s.fNestedPaging) 5967 5978 { 5968 5979 if ( !CPUMIsGuestPagingEnabledEx(pCtx) … … 7012 7023 switch (uVmcsField) 7013 7024 { 7014 case VMX_VMCS64_CTRL_EPTP_FULL: fSupported = pVM->hm .s.fNestedPaging;break;7025 case VMX_VMCS64_CTRL_EPTP_FULL: fSupported = pVM->hmr0.s.fNestedPaging; break; 7015 7026 case VMX_VMCS16_VPID: fSupported = pVM->hm.s.vmx.fVpid; break; 7016 7027 case VMX_VMCS32_CTRL_PROC_EXEC2: … … 7881 7892 /* CR0.PG bit changes are always intercepted, so it's up to date. */ 7882 7893 if ( pVM->hm.s.vmx.fUnrestrictedGuest 7883 || ( pVM->hm .s.fNestedPaging7894 || ( pVM->hmr0.s.fNestedPaging 7884 7895 && CPUMIsGuestPagingEnabledEx(pCtx))) 7885 7896 { … … 8587 8598 | CPUM_CHANGED_TR 8588 8599 | CPUM_CHANGED_HIDDEN_SEL_REGS); 8589 if ( pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging8600 if ( pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging 8590 8601 && CPUMIsGuestPagingEnabledEx(&pVCpu->cpum.GstCtx)) 8591 8602 CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_GLOBAL_TLB_FLUSH); … … 10180 10191 /** @todo Checks on Guest Page-Directory-Pointer-Table Entries when guest is 10181 10192 * not using nested paging? */ 10182 if ( pVM->hm .s.fNestedPaging10193 if ( pVM->hmr0.s.fNestedPaging 10183 10194 && !fLongModeGuest 10184 10195 && CPUMIsGuestInPAEModeEx(pCtx)) … … 13936 13947 hmR0VmxReadExitQualVmcs(pVmxTransient); 13937 13948 13938 if (!pVM->hm .s.fNestedPaging)13949 if (!pVM->hmr0.s.fNestedPaging) 13939 13950 { /* likely */ } 13940 13951 else … … 14861 14872 { 14862 14873 HMVMX_VALIDATE_EXIT_HANDLER_PARAMS(pVCpu, pVmxTransient); 14863 Assert(!pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging || pVCpu->hmr0.s.fUsingDebugLoop);14874 Assert(!pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging || pVCpu->hmr0.s.fUsingDebugLoop); 14864 14875 14865 14876 PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo; … … 15109 15120 rc = VMXReadVmcsNw(VMX_VMCS_CTRL_CR4_READ_SHADOW, &u64Val); AssertRC(rc); 15110 15121 Log4(("VMX_VMCS_CTRL_CR4_READ_SHADOW %#RX64\n", u64Val)); 15111 if (pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging)15122 if (pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging) 15112 15123 { 15113 15124 rc = VMXReadVmcs64(VMX_VMCS64_CTRL_EPTP_FULL, &u64Val); AssertRC(rc); … … 15498 15509 */ 15499 15510 Assert( iCrReg != 3 15500 || !pVM->hm .s.fNestedPaging15511 || !pVM->hmr0.s.fNestedPaging 15501 15512 || !CPUMIsGuestPagingEnabledEx(&pVCpu->cpum.GstCtx) 15502 15513 || pVCpu->hmr0.s.fUsingDebugLoop); … … 15550 15561 */ 15551 15562 Assert( iCrReg != 3 15552 || !pVM->hm .s.fNestedPaging15563 || !pVM->hmr0.s.fNestedPaging 15553 15564 || !CPUMIsGuestPagingEnabledEx(&pVCpu->cpum.GstCtx) 15554 15565 || pVCpu->hmr0.s.fLeaveDone); … … 16092 16103 { 16093 16104 HMVMX_VALIDATE_EXIT_HANDLER_PARAMS(pVCpu, pVmxTransient); 16094 Assert(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);16105 Assert(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 16095 16106 16096 16107 hmR0VmxReadExitIntInfoVmcs(pVmxTransient); … … 16200 16211 { 16201 16212 HMVMX_VALIDATE_EXIT_HANDLER_PARAMS(pVCpu, pVmxTransient); 16202 Assert(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);16213 Assert(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 16203 16214 16204 16215 hmR0VmxReadExitQualVmcs(pVmxTransient); … … 16717 16728 16718 16729 /* Nested paging is currently a requirement, otherwise we would need to handle shadow #PFs in hmR0VmxExitXcptPF. */ 16719 Assert(pVCpu->CTX_SUFF(pVM)->hm .s.fNestedPaging);16730 Assert(pVCpu->CTX_SUFF(pVM)->hmr0.s.fNestedPaging); 16720 16731 return hmR0VmxExitXcpt(pVCpu, pVmxTransient); 16721 16732 }
Note:
See TracChangeset
for help on using the changeset viewer.