Changeset 79142 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jun 14, 2019 4:54:41 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131309
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp
r78650 r79142 1238 1238 NOREF(pCtx); 1239 1239 1240 /* There shouldn't be any externally kept state at this point. */ 1241 AssertMsg(!(pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_ALL), 1242 ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", pVCpu->cpum.GstCtx.fExtrn, CPUMCTX_EXTRN_ALL)); 1240 /* 1241 * Transitions to ring-3 flag a full CPU-state change except if we transition to ring-3 1242 * in response to a physical CPU interrupt as no changes to the guest-CPU state are 1243 * expected (see VINF_EM_RAW_INTERRUPT handling in hmR0VmxExitToRing3). 1244 * 1245 * However, with nested-guests, the state -can- change on trips to ring-3 for we might 1246 * try to inject a nested-guest physical interrupt and cause a VMX_EXIT_EXT_INT VM-exit 1247 * for the nested-guest from ring-3. 1248 * 1249 * Flag reloading of just the guest-CPU state is -not- sufficient since HM also needs 1250 * to reload related state with VM-entry/VM-exit controls and so on. Flag reloading 1251 * the entire state. 1252 */ 1253 CPUM_ASSERT_NOT_EXTRN(pVCpu, CPUMCTX_EXTRN_ALL); 1254 ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_ALL_GUEST); 1243 1255 1244 1256 /* -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r79106 r79142 4464 4464 * For nested-guests, the "IA-32e mode guest" control we initialize with what is 4465 4465 * required to get the nested-guest working with hardware-assisted VMX execution. 4466 * It depends on the nested-guest's IA32_EFER.LMA bit. Remember, a nested-hypervisor4466 * It depends on the nested-guest's IA32_EFER.LMA bit. Remember, a guest hypervisor 4467 4467 * can skip intercepting changes to the EFER MSR. This is why it it needs to be done 4468 4468 * here rather than while merging the guest VMCS controls. … … 4912 4912 * Figure out fixed CR0 bits in VMX operation. 4913 4913 */ 4914 /** @todo Why do we need to OR and AND the fixed-0 and fixed-1 bits below? */ 4914 4915 uint64_t fSetCr0 = pVM->hm.s.vmx.Msrs.u64Cr0Fixed0 & pVM->hm.s.vmx.Msrs.u64Cr0Fixed1; 4915 4916 uint64_t const fZapCr0 = pVM->hm.s.vmx.Msrs.u64Cr0Fixed0 | pVM->hm.s.vmx.Msrs.u64Cr0Fixed1; … … 5036 5037 * originally supplied. We must copy those bits from the nested-guest CR0 into 5037 5038 * the nested-guest CR0 read-shadow. 5039 * 5040 * Note! We are zapping away any CR0 fixed bits of our VMX emulation and applying 5041 * the hardware's VMX CR0 fixed bits here. 5038 5042 */ 5039 5043 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0); … … 5199 5203 * Figure out fixed CR4 bits in VMX operation. 5200 5204 */ 5205 /** @todo Why do we need to OR and AND the fixed-0 and fixed-1 bits below? */ 5201 5206 uint64_t const fSetCr4 = pVM->hm.s.vmx.Msrs.u64Cr4Fixed0 & pVM->hm.s.vmx.Msrs.u64Cr4Fixed1; 5202 5207 uint64_t const fZapCr4 = pVM->hm.s.vmx.Msrs.u64Cr4Fixed0 | pVM->hm.s.vmx.Msrs.u64Cr4Fixed1; … … 7759 7764 u64Val = (u64Val & ~pVmcsInfo->u64Cr0Mask) 7760 7765 | (u64Shadow & pVmcsInfo->u64Cr0Mask); 7761 7766 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 7767 /* 7768 * Reapply the nested-guest's CR0 fixed bits that might have been altered while 7769 * exporting the nested-guest CR0 for executing using hardware-assisted VMX. 7770 */ 7771 if (CPUMIsGuestInVmxNonRootMode(pCtx)) 7772 { 7773 u64Val |= pCtx->hwvirt.vmx.Msrs.u64Cr0Fixed0; 7774 u64Val &= pCtx->hwvirt.vmx.Msrs.u64Cr0Fixed1; 7775 } 7776 #endif 7762 7777 VMMRZCallRing3Disable(pVCpu); /* May call into PGM which has Log statements. */ 7763 7778 CPUMSetGuestCR0(pVCpu, u64Val); … … 7782 7797 u64Val = (u64Val & ~pVmcsInfo->u64Cr4Mask) 7783 7798 | (u64Shadow & pVmcsInfo->u64Cr4Mask); 7799 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 7800 /* 7801 * Reapply the nested-guest's CR4 fixed bits that might have been altered while 7802 * exporting the nested-guest CR4 for executing using hardware-assisted VMX. 7803 */ 7804 if (CPUMIsGuestInVmxNonRootMode(pCtx)) 7805 { 7806 u64Val |= pCtx->hwvirt.vmx.Msrs.u64Cr4Fixed0; 7807 u64Val &= pCtx->hwvirt.vmx.Msrs.u64Cr4Fixed1; 7808 } 7809 #endif 7784 7810 pCtx->cr4 = u64Val; 7785 7811 } … … 9511 9537 * and update error record fields accordingly. 9512 9538 * 9513 * @return VMX_IGS_* returncodes.9539 * @returns VMX_IGS_* error codes. 9514 9540 * @retval VMX_IGS_REASON_NOT_FOUND if this function could not find anything 9515 9541 * wrong with the guest state. … … 9541 9567 * CR0. 9542 9568 */ 9569 /** @todo Why do we need to OR and AND the fixed-0 and fixed-1 bits below? */ 9543 9570 uint32_t fSetCr0 = (uint32_t)(pVM->hm.s.vmx.Msrs.u64Cr0Fixed0 & pVM->hm.s.vmx.Msrs.u64Cr0Fixed1); 9544 9571 uint32_t const fZapCr0 = (uint32_t)(pVM->hm.s.vmx.Msrs.u64Cr0Fixed0 | pVM->hm.s.vmx.Msrs.u64Cr0Fixed1); … … 9563 9590 * CR4. 9564 9591 */ 9592 /** @todo Why do we need to OR and AND the fixed-0 and fixed-1 bits below? */ 9565 9593 uint64_t const fSetCr4 = (pVM->hm.s.vmx.Msrs.u64Cr4Fixed0 & pVM->hm.s.vmx.Msrs.u64Cr4Fixed1); 9566 9594 uint64_t const fZapCr4 = (pVM->hm.s.vmx.Msrs.u64Cr4Fixed0 | pVM->hm.s.vmx.Msrs.u64Cr4Fixed1); … … 10246 10274 * These controls contains state that depends on the nested-guest state (primarily 10247 10275 * EFER MSR) and is thus not constant between VMLAUNCH/VMRESUME and the nested-guest 10248 * VM-exit. Although the nested-hypervisor cannot change it, we need to in order to10276 * VM-exit. Although the guest hypervisor cannot change it, we need to in order to 10249 10277 * properly continue executing the nested-guest if the EFER MSR changes but does not 10250 10278 * cause a nested-guest VM-exits. … … 10252 10280 * VM-exit controls: 10253 10281 * These controls specify the host state on return. We cannot use the controls from 10254 * the guest -hypervisor state as is as it would contain the guest state rather than10282 * the guest hypervisor state as is as it would contain the guest state rather than 10255 10283 * the host state. Since the host state is subject to change (e.g. preemption, trips 10256 10284 * to ring-3, longjmp and rescheduling to a different host CPU) they are not constant … … 10267 10295 * VM-exit MSR-load areas: 10268 10296 * This must contain the real host MSRs with hardware-assisted VMX execution. Hence, 10269 * we can entirely ignore what the nested-hypervisor wants to load here.10297 * we can entirely ignore what the guest hypervisor wants to load here. 10270 10298 */ 10271 10299
Note:
See TracChangeset
for help on using the changeset viewer.