Changeset 59003 in vbox for trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
- Timestamp:
- Dec 4, 2015 9:46:44 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r58999 r59003 5507 5507 } 5508 5508 5509 if (fOffsettedTsc )5509 if (fOffsettedTsc && RT_LIKELY(!pVCpu->hm.s.fDebugWantRdTscExit)) 5510 5510 { 5511 5511 /* Note: VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT takes precedence over TSC_OFFSET, applies to RDTSCP too. */ … … 8877 8877 uint32_t uDtraceSettingsSeqNo; 8878 8878 /** Exits to check (one bit per exit). */ 8879 uint32_t bmExitsToCheck[ 2];8879 uint32_t bmExitsToCheck[3]; 8880 8880 8881 8881 /** The initial VMX_VMCS32_CTRL_PROC_EXEC value (helps with restore). */ … … 8887 8887 8888 8888 } VMXRUNDBGSTATE; 8889 AssertCompileMemberSize(VMXRUNDBGSTATE, bmExitsToCheck, (VMX_EXIT_MAX + 31) / 32 * 4);8889 AssertCompileMemberSize(VMXRUNDBGSTATE, bmExitsToCheck, (VMX_EXIT_MAX + 1 + 31) / 32 * 4); 8890 8890 typedef VMXRUNDBGSTATE *PVMXRUNDBGSTATE; 8891 8891 … … 8945 8945 pVCpu->hm.s.vmx.u32ProcCtls &= ~pDbgState->fCpe1Unwanted; 8946 8946 VMXWriteVmcs32(VMX_VMCS32_CTRL_PROC_EXEC, pVCpu->hm.s.vmx.u32ProcCtls); 8947 Log6(("hmR0VmxRunDebugStateRevert: VMX_VMCS32_CTRL_PROC_EXEC: %#RX32\n", pVCpu->hm.s.vmx.u32ProcCtls)); 8947 8948 pDbgState->fModifiedProcCtls = true; 8948 8949 } … … 8951 8952 { 8952 8953 pVCpu->hm.s.vmx.u32ProcCtls2 |= pDbgState->fCpe2Extra; 8953 VMXWriteVmcs32(VMX_VMCS32_CTRL_PROC_EXEC, pVCpu->hm.s.vmx.u32ProcCtls2); 8954 VMXWriteVmcs32(VMX_VMCS32_CTRL_PROC_EXEC2, pVCpu->hm.s.vmx.u32ProcCtls2); 8955 Log6(("hmR0VmxRunDebugStateRevert: VMX_VMCS32_CTRL_PROC_EXEC2: %#RX32\n", pVCpu->hm.s.vmx.u32ProcCtls2)); 8954 8956 pDbgState->fModifiedProcCtls2 = true; 8955 8957 } … … 8959 8961 pVCpu->hm.s.vmx.u32XcptBitmap |= pDbgState->bmXcptExtra; 8960 8962 VMXWriteVmcs32(VMX_VMCS32_CTRL_EXCEPTION_BITMAP, pVCpu->hm.s.vmx.u32XcptBitmap); 8963 Log6(("hmR0VmxRunDebugStateRevert: VMX_VMCS32_CTRL_EXCEPTION_BITMAP: %#RX32\n", pVCpu->hm.s.vmx.u32XcptBitmap)); 8961 8964 pDbgState->fModifiedXcptBitmap = true; 8962 8965 } … … 8966 8969 pVCpu->hm.s.vmx.u32CR0Mask = 0; 8967 8970 VMXWriteVmcs32(VMX_VMCS_CTRL_CR0_MASK, 0); 8971 Log6(("hmR0VmxRunDebugStateRevert: VMX_VMCS_CTRL_CR0_MASK: 0\n")); 8968 8972 } 8969 8973 … … 8972 8976 pVCpu->hm.s.vmx.u32CR4Mask = 0; 8973 8977 VMXWriteVmcs32(VMX_VMCS_CTRL_CR4_MASK, 0); 8978 Log6(("hmR0VmxRunDebugStateRevert: VMX_VMCS_CTRL_CR4_MASK: 0\n")); 8974 8979 } 8975 8980 } … … 8997 9002 cached value and reload the field. */ 8998 9003 if ( pDbgState->fModifiedProcCtls2 8999 && pVCpu->hm.s.vmx.u32ProcCtls2 != pDbgState->fProcCtls Initial)9004 && pVCpu->hm.s.vmx.u32ProcCtls2 != pDbgState->fProcCtls2Initial) 9000 9005 { 9001 9006 int rc2 = VMXWriteVmcs32(VMX_VMCS32_CTRL_PROC_EXEC2, pDbgState->fProcCtls2Initial); … … 9030 9035 * the necessary exits demanded by DBGF and DTrace. 9031 9036 * 9032 * @param pVM The cross context VM structure. 9033 * @param pVCpu The cross context virtual CPU structure. 9034 * @param pCtx Pointer to the guest-CPU context. 9035 * @param pDbgState The debug state. 9036 */ 9037 static void hmR0VmxPreRunGuestDebugStateUpdate(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, PVMXRUNDBGSTATE pDbgState) 9037 * @param pVM The cross context VM structure. 9038 * @param pVCpu The cross context virtual CPU structure. 9039 * @param pCtx Pointer to the guest-CPU context. 9040 * @param pDbgState The debug state. 9041 * @param pVmxTransient Pointer to the VMX transient structure. May update 9042 * fUpdateTscOffsettingAndPreemptTimer. 9043 */ 9044 static void hmR0VmxPreRunGuestDebugStateUpdate(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, 9045 PVMXRUNDBGSTATE pDbgState, PVMXTRANSIENT pVmxTransient) 9038 9046 { 9039 9047 /* … … 9105 9113 || RT_CONCAT3(VBOXVMM_, a_EventSubName, _ENABLED)() ) 9106 9114 #define SET_ONLY_XBM_IF_EITHER_EN(a_EventSubName, a_uExit) \ 9107 if (IS_EITHER_ENABLED(pVM, a_EventSubName)) ASMBitSet((pDbgState)->bmExitsToCheck, a_uExit); else do { } while (0) 9115 if (IS_EITHER_ENABLED(pVM, a_EventSubName)) \ 9116 { AssertCompile((unsigned)(a_uExit) < sizeof(pDbgState->bmExitsToCheck) * 8); \ 9117 ASMBitSet((pDbgState)->bmExitsToCheck, a_uExit); \ 9118 } else do { } while (0) 9108 9119 #define SET_CPE1_XBM_IF_EITHER_EN(a_EventSubName, a_uExit, a_fCtrlProcExec) \ 9109 9120 if (IS_EITHER_ENABLED(pVM, a_EventSubName)) \ 9110 9121 { \ 9111 9122 (pDbgState)->fCpe1Extra |= (a_fCtrlProcExec); \ 9123 AssertCompile((unsigned)(a_uExit) < sizeof(pDbgState->bmExitsToCheck) * 8); \ 9112 9124 ASMBitSet((pDbgState)->bmExitsToCheck, a_uExit); \ 9113 9125 } else do { } while (0) … … 9116 9128 { \ 9117 9129 (pDbgState)->fCpe1Unwanted |= (a_fUnwantedCtrlProcExec); \ 9130 AssertCompile((unsigned)(a_uExit) < sizeof(pDbgState->bmExitsToCheck) * 8); \ 9118 9131 ASMBitSet((pDbgState)->bmExitsToCheck, a_uExit); \ 9119 9132 } else do { } while (0) … … 9122 9135 { \ 9123 9136 (pDbgState)->fCpe2Extra |= (a_fCtrlProcExec2); \ 9137 AssertCompile((unsigned)(a_uExit) < sizeof(pDbgState->bmExitsToCheck) * 8); \ 9124 9138 ASMBitSet((pDbgState)->bmExitsToCheck, a_uExit); \ 9125 9139 } else do { } while (0) … … 9136 9150 SET_ONLY_XBM_IF_EITHER_EN(EXIT_INVD, VMX_EXIT_INVD); /* unconditional */ 9137 9151 SET_CPE1_XBM_IF_EITHER_EN(EXIT_INVLPG, VMX_EXIT_INVLPG, VMX_VMCS_CTRL_PROC_EXEC_INVLPG_EXIT); 9138 #if 09139 9152 SET_CPE1_XBM_IF_EITHER_EN(EXIT_RDPMC, VMX_EXIT_RDPMC, VMX_VMCS_CTRL_PROC_EXEC_RDPMC_EXIT); 9140 9153 SET_CPE1_XBM_IF_EITHER_EN(EXIT_RDTSC, VMX_EXIT_RDTSC, VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT); … … 9159 9172 AssertRC(rc2); 9160 9173 9174 #if 0 /** @todo fix me */ 9161 9175 pDbgState->fClearCr0Mask = true; 9162 9176 pDbgState->fClearCr4Mask = true; 9177 #endif 9163 9178 if (IS_EITHER_ENABLED(pVM, EXIT_CRX_READ)) 9164 9179 pDbgState->fCpe1Extra |= VMX_VMCS_CTRL_PROC_EXEC_CR3_STORE_EXIT | VMX_VMCS_CTRL_PROC_EXEC_CR8_STORE_EXIT; … … 9195 9210 SET_CPE1_XBM_IF_EITHER_EN(EXIT_MWAIT, VMX_EXIT_MWAIT, VMX_VMCS_CTRL_PROC_EXEC_MWAIT_EXIT); /* parnoia */ 9196 9211 SET_CPE1_XBM_IF_EITHER_EN(EXIT_MONITOR, VMX_EXIT_MONITOR, VMX_VMCS_CTRL_PROC_EXEC_MONITOR_EXIT); /* parnoia */ 9212 #if 0 /** @todo too slow, fix handler. */ 9197 9213 SET_CPE1_XBM_IF_EITHER_EN(EXIT_PAUSE, VMX_EXIT_PAUSE, VMX_VMCS_CTRL_PROC_EXEC_PAUSE_EXIT); 9214 #endif 9198 9215 9199 9216 if ( IS_EITHER_ENABLED(pVM, EXIT_SGDT) … … 9226 9243 SET_ONLY_XBM_IF_EITHER_EN(EXIT_XSAVES, VMX_EXIT_XSAVES); /* unconditional (enabled by host, guest cfg) */ 9227 9244 SET_ONLY_XBM_IF_EITHER_EN(EXIT_XRSTORS, VMX_EXIT_XRSTORS); /* unconditional (enabled by host, guest cfg) */ 9228 #endif 9245 9229 9246 #undef IS_EITHER_ENABLED 9230 9247 #undef SET_ONLY_XBM_IF_EITHER_EN … … 9236 9253 * Sanitize the control stuff. 9237 9254 */ 9255 pDbgState->fCpe2Extra &= pVM->hm.s.vmx.Msrs.VmxProcCtls2.n.allowed1; 9256 if (pDbgState->fCpe2Extra) 9257 pDbgState->fCpe1Extra |= VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL; 9238 9258 pDbgState->fCpe1Extra &= pVM->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1; 9239 9259 pDbgState->fCpe1Unwanted &= ~pVM->hm.s.vmx.Msrs.VmxProcCtls.n.disallowed0; 9240 pDbgState->fCpe2Extra &= pVM->hm.s.vmx.Msrs.VmxProcCtls2.n.allowed1; 9260 if (pVCpu->hm.s.fDebugWantRdTscExit != RT_BOOL(pDbgState->fCpe1Extra & VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT)) 9261 { 9262 pVCpu->hm.s.fDebugWantRdTscExit ^= true; 9263 pVmxTransient->fUpdateTscOffsettingAndPreemptTimer = true; 9264 } 9265 9241 9266 Log6(("HM: debug state: cpe1=%#RX32 cpeu=%#RX32 cpe2=%#RX32%s%s\n", 9242 9267 pDbgState->fCpe1Extra, pDbgState->fCpe1Unwanted, pDbgState->fCpe2Extra, … … 9254 9279 * 9255 9280 * @returns Strict VBox status code (i.e. informational status codes too). 9256 * @param pVM The cross context VM structure. 9257 * @param pVCpu The cross context virtual CPU structure. 9258 * @param pMixedCtx Pointer to the guest-CPU context. 9259 * @param pDbgState The debug state. 9281 * @param pVM The cross context VM structure. 9282 * @param pVCpu The cross context virtual CPU structure. 9283 * @param pMixedCtx Pointer to the guest-CPU context. 9284 * @param pVmxTransient Pointer to the VMX-transient structure. 9285 * @param uExitReason The VM-exit reason. 9260 9286 * 9261 9287 * @remarks The name of this function is displayed by dtrace, so keep it short … … 9732 9758 9733 9759 /* Set HMCPU indicators. */ 9734 bool const fSavedSingleInstruction = pVCpu->hm.s.fSingleInstruction; 9735 pVCpu->hm.s.fSingleInstruction = pVCpu->hm.s.fSingleInstruction || DBGFIsStepping(pVCpu); 9736 pVCpu->hm.s.fUsingDebugLoop = true; 9760 bool const fSavedSingleInstruction = pVCpu->hm.s.fSingleInstruction; 9761 pVCpu->hm.s.fSingleInstruction = pVCpu->hm.s.fSingleInstruction || DBGFIsStepping(pVCpu); 9762 pVCpu->hm.s.fDebugWantRdTscExit = false; 9763 pVCpu->hm.s.fUsingDebugLoop = true; 9737 9764 9738 9765 /* State we keep to help modify and later restore the VMCS fields we alter, and for detecting steps. */ 9739 9766 VMXRUNDBGSTATE DbgState; 9740 9767 hmR0VmxRunDebugStateInit(pVCpu, pCtx, &DbgState); 9741 hmR0VmxPreRunGuestDebugStateUpdate(pVM, pVCpu, pCtx, &DbgState );9768 hmR0VmxPreRunGuestDebugStateUpdate(pVM, pVCpu, pCtx, &DbgState, &VmxTransient); 9742 9769 9743 9770 /* … … 9832 9859 */ 9833 9860 if (VBOXVMM_GET_SETTINGS_SEQ_NO() != DbgState.uDtraceSettingsSeqNo) 9834 hmR0VmxPreRunGuestDebugStateUpdate(pVM, pVCpu, pCtx, &DbgState );9861 hmR0VmxPreRunGuestDebugStateUpdate(pVM, pVCpu, pCtx, &DbgState, &VmxTransient); 9835 9862 } 9836 9863 … … 9856 9883 9857 9884 /* Restore HMCPU indicators. */ 9858 pVCpu->hm.s.fUsingDebugLoop = false; 9859 pVCpu->hm.s.fSingleInstruction = fSavedSingleInstruction; 9885 pVCpu->hm.s.fUsingDebugLoop = false; 9886 pVCpu->hm.s.fDebugWantRdTscExit = false; 9887 pVCpu->hm.s.fSingleInstruction = fSavedSingleInstruction; 9860 9888 9861 9889 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x);
Note:
See TracChangeset
for help on using the changeset viewer.