Changeset 50506 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Feb 19, 2014 3:13:19 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r50426 r50506 1236 1236 * auto-load/store MSR area in the VMCS. 1237 1237 * 1238 * @returns VBox status code. 1238 * @returns true if the MSR was added -and- its value was updated, false 1239 * otherwise. 1239 1240 * @param pVCpu Pointer to the VMCPU. 1240 1241 * @param uMsr The MSR. … … 1243 1244 * necessary. 1244 1245 */ 1245 static inthmR0VmxAddAutoLoadStoreMsr(PVMCPU pVCpu, uint32_t uMsr, uint64_t uGuestMsrValue, bool fUpdateHostMsr)1246 static bool hmR0VmxAddAutoLoadStoreMsr(PVMCPU pVCpu, uint32_t uMsr, uint64_t uGuestMsrValue, bool fUpdateHostMsr) 1246 1247 { 1247 1248 PVMXAUTOMSR pGuestMsr = (PVMXAUTOMSR)pVCpu->hm.s.vmx.pvGuestMsr; … … 1283 1284 * updated by hmR0VmxSaveHostMsrs(). We do this for performance reasons. 1284 1285 */ 1286 bool fUpdatedMsrValue = false; 1285 1287 if ( fAdded 1286 1288 && fUpdateHostMsr) … … 1289 1291 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 1290 1292 pHostMsr->u64Value = ASMRdMsr(pHostMsr->u32Msr); 1291 } 1292 1293 return VINF_SUCCESS; 1293 fUpdatedMsrValue = true; 1294 } 1295 1296 return fUpdatedMsrValue; 1294 1297 } 1295 1298 … … 2775 2778 int rc = VERR_INTERNAL_ERROR_5; 2776 2779 2780 #if HC_ARCH_BITS == 64 2777 2781 /* 2778 * Quick fix for regression #7240. Restore the host state if we've messed2779 * it up already, otherwise all we'll get it all wrong below!2782 * If we've executed guest code using VT-x, the host-state bits will be messed up. We 2783 * should -not- save the messed up state without restoring the original host-state. See @bugref{7240}. 2780 2784 */ 2781 if ( (pVCpu->hm.s.vmx.fRestoreHostFlags & VMX_RESTORE_HOST_REQUIRED)2782 && (pVCpu->hm.s.vmx.fRestoreHostFlags & ~VMX_RESTORE_HOST_REQUIRED))2783 VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost); 2785 AssertMsgReturn(!(pVCpu->hm.s.vmx.fRestoreHostFlags & VMX_RESTORE_HOST_REQUIRED), 2786 ("Re-saving host-state after executing guest code without leaving VT-x!\n"), VERR_WRONG_ORDER); 2787 #endif 2784 2788 2785 2789 /* … … 3025 3029 hmR0VmxLazySaveHostMsrs(pVCpu); 3026 3030 #endif 3027 3028 if (pVCpu->hm.s.vmx.cMsrs > 0)3029 hmR0VmxUpdateAutoLoadStoreHostMsrs(pVCpu);3030 3031 3031 3032 /* … … 4563 4564 { 4564 4565 pVCpu->hm.s.vmx.pfnStartVM = VMXR0SwitcherStartVM64; 4565 HMCPU_CF_SET(pVCpu, HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_EXIT_CTLS | HM_CHANGED_VMX_ENTRY_CTLS); 4566 /* Currently, all mode changes sends us back to ring-3, so these should be set. See @bugref{6944}. */ 4567 Assert(HMCPU_CF_IS_SET(pVCpu, HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_EXIT_CTLS | HM_CHANGED_VMX_ENTRY_CTLS)); 4566 4568 } 4567 4569 #else … … 4577 4579 { 4578 4580 pVCpu->hm.s.vmx.pfnStartVM = VMXR0StartVM32; 4579 HMCPU_CF_SET(pVCpu, HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_EXIT_CTLS | HM_CHANGED_VMX_ENTRY_CTLS); 4581 /* Currently, all mode changes sends us back to ring-3, so these should be set. See @bugref{6944}. */ 4582 Assert(HMCPU_CF_IS_SET(pVCpu, HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_EXIT_CTLS | HM_CHANGED_VMX_ENTRY_CTLS)); 4580 4583 } 4581 4584 #else … … 6674 6677 #endif 6675 6678 6679 /* Update auto-load/store host MSRs values when we re-enter VT-x (as we could be on a different CPU). */ 6680 pVCpu->hm.s.vmx.fUpdatedHostMsrs = false; 6681 6676 6682 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry); 6677 6683 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatLoadGuestState); … … 6894 6900 } 6895 6901 #endif 6902 pVCpu->hm.s.vmx.fUpdatedHostMsrs = false; 6896 6903 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC); 6897 6904 if (pVCpu->hm.s.vmx.uVmcsState & HMVMX_VMCS_STATE_ACTIVE) … … 7077 7084 if (pVCpu->hm.s.Event.fPending) 7078 7085 { 7086 #if defined(DEBUG) || defined(VBOX_STRICT) || defined(VBOX_WITH_STATISTICS) 7087 uint32_t uIntType = VMX_EXIT_INTERRUPTION_INFO_TYPE(pVCpu->hm.s.Event.u64IntInfo); 7088 #endif 7079 7089 #if defined(VBOX_STRICT) || defined(VBOX_WITH_STATISTICS) 7080 uint32_t uIntType = VMX_EXIT_INTERRUPTION_INFO_TYPE(pVCpu->hm.s.Event.u64IntInfo);7081 7090 if (uIntType == VMX_EXIT_INTERRUPTION_INFO_TYPE_EXT_INT) 7082 7091 { … … 7094 7103 } 7095 7104 #endif 7096 Log4(("Injecting pending event vcpu[%RU32] u64IntInfo=%#RX64\n", pVCpu->idCpu, pVCpu->hm.s.Event.u64IntInfo)); 7105 Log4(("Injecting pending event vcpu[%RU32] u64IntInfo=%#RX64 Type=%#x\n", pVCpu->idCpu, pVCpu->hm.s.Event.u64IntInfo, 7106 (uint8_t)uIntType)); 7097 7107 rc = hmR0VmxInjectEventVmcs(pVCpu, pMixedCtx, pVCpu->hm.s.Event.u64IntInfo, pVCpu->hm.s.Event.cbInstr, 7098 7108 pVCpu->hm.s.Event.u32ErrCode, pVCpu->hm.s.Event.GCPtrFaultAddress, &uIntrState); … … 8102 8112 8103 8113 /* 8104 * The host MSR values the very first time around won't be updated, so we need to 8105 * fill those values in. Subsequently, it's updated as part of the host state. 8114 * Lazy-update of the host MSRs values in the auto-load/store MSR area. 8106 8115 */ 8107 8116 if ( !pVCpu->hm.s.vmx.fUpdatedHostMsrs 8108 8117 && pVCpu->hm.s.vmx.cMsrs > 0) 8109 8118 { 8110 HMCPU_CF_SET(pVCpu, HM_CHANGED_HOST_CONTEXT);8119 hmR0VmxUpdateAutoLoadStoreHostMsrs(pVCpu); 8111 8120 } 8112 8121 … … 8181 8190 AssertRC(rc2); 8182 8191 Assert(HMVMXCPU_GST_IS_UPDATED(pVCpu, HMVMX_UPDATED_GUEST_AUTO_LOAD_STORE_MSRS)); 8183 hmR0VmxAddAutoLoadStoreMsr(pVCpu, MSR_K8_TSC_AUX, CPUMR0GetGuestTscAux(pVCpu), true /* fUpdateHostMsr */); 8192 bool fMsrUpdated = hmR0VmxAddAutoLoadStoreMsr(pVCpu, MSR_K8_TSC_AUX, CPUMR0GetGuestTscAux(pVCpu), 8193 true /* fUpdateHostMsr */); 8194 Assert(fMsrUpdated || pVCpu->hm.s.vmx.fUpdatedHostMsrs); 8195 /* Finally, mark that all host MSR values are updated so we don't redo it without leaving VT-x. See @bugref{6956}. */ 8196 pVCpu->hm.s.vmx.fUpdatedHostMsrs = true; 8184 8197 } 8185 8198 else 8199 { 8186 8200 hmR0VmxRemoveAutoLoadStoreMsr(pVCpu, MSR_K8_TSC_AUX); 8201 Assert(!pVCpu->hm.s.vmx.cMsrs || pVCpu->hm.s.vmx.fUpdatedHostMsrs); 8202 } 8187 8203 } 8188 8204 #ifdef VBOX_STRICT … … 8242 8258 #endif 8243 8259 8260 #if HC_ARCH_BITS == 64 8244 8261 pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_REQUIRED; /* Host state messed up by VT-x, we must restore. */ 8262 #endif 8245 8263 pVCpu->hm.s.vmx.uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED; /* Use VMRESUME instead of VMLAUNCH in the next run. */ 8246 8264 ASMSetFlags(pVmxTransient->uEflags); /* Enable interrupts. */
Note:
See TracChangeset
for help on using the changeset viewer.