Changeset 22243 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 13, 2009 3:43:06 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/HWACCMInternal.h
r22242 r22243 557 557 RTUINT uCurrentASID; 558 558 559 /* Last use TSC offset value. (cached) */560 uint64_t u64TSCOffset;561 562 559 struct 563 560 { … … 619 616 uint32_t cCachedMSRs; 620 617 uint32_t uAlignement; 618 619 /* Last use TSC offset value. (cached) */ 620 uint64_t u64TSCOffset; 621 621 622 622 /** VMCS cache. */ -
trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
r22018 r22243 899 899 if (TMCpuTickCanUseRealTSC(pVCpu, &pVMCB->ctrl.u64TSCOffset)) 900 900 { 901 pVMCB->ctrl.u32InterceptCtrl1 &= ~SVM_CTRL1_INTERCEPT_RDTSC; 902 pVMCB->ctrl.u32InterceptCtrl2 &= ~SVM_CTRL2_INTERCEPT_RDTSCP; 903 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatTSCOffset); 901 uint64_t u64CurTSC = ASMReadTSC(); 902 if (u64CurTSC + pVMCB->ctrl.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu)) 903 { 904 pVMCB->ctrl.u32InterceptCtrl1 &= ~SVM_CTRL1_INTERCEPT_RDTSC; 905 pVMCB->ctrl.u32InterceptCtrl2 &= ~SVM_CTRL2_INTERCEPT_RDTSCP; 906 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatTSCOffset); 907 } 908 else 909 { 910 /* Fall back to rdtsc emulation as we would otherwise pass decreasing tsc values to the guest. */ 911 Log(("TSC %RX64 offset %RX64 time=%RX64 last=%RX64 (diff=%RX64, virt_tsc=%RX64)\n", u64CurTSC, pVMCB->ctrl.u64TSCOffset, u64CurTSC + pVMCB->ctrl.u64TSCOffset, TMCpuTickGetLastSeen(pVCpu), TMCpuTickGetLastSeen(pVCpu) - u64CurTSC - pVMCB->ctrl.u64TSCOffset, TMCpuTickGet(pVCpu))); 912 } 904 913 } 905 914 else … … 1250 1259 pVCpu->hwaccm.s.svm.pfnVMRun(pVCpu->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu); 1251 1260 #endif 1261 /* Possibly the last TSC value seen by the guest (too high) (only when we're in tsc offset mode). */ 1262 if (!(pVMCB->ctrl.u32InterceptCtrl1 & SVM_CTRL1_INTERCEPT_RDTSC)) 1263 TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVMCB->ctrl.u64TSCOffset - 0x1000 /* guestimate of world switch overhead in clock ticks */); 1252 1264 TMNotifyEndOfExecution(pVCpu); 1253 1265 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r22242 r22243 1803 1803 AssertRC(rc); 1804 1804 1805 if (TMCpuTickCanUseRealTSC(pVCpu, &pVCpu->hwaccm.s. u64TSCOffset))1805 if (TMCpuTickCanUseRealTSC(pVCpu, &pVCpu->hwaccm.s.vmx.u64TSCOffset)) 1806 1806 { 1807 1807 uint64_t u64CurTSC = ASMReadTSC(); 1808 if (u64CurTSC + pVCpu->hwaccm.s. u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))1808 if (u64CurTSC + pVCpu->hwaccm.s.vmx.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu)) 1809 1809 { 1810 1810 /* Note: VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT takes precedence over TSC_OFFSET */ 1811 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_TSC_OFFSET_FULL, pVCpu->hwaccm.s. u64TSCOffset);1811 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_TSC_OFFSET_FULL, pVCpu->hwaccm.s.vmx.u64TSCOffset); 1812 1812 AssertRC(rc); 1813 1813 … … 1820 1820 { 1821 1821 /* Fall back to rdtsc emulation as we would otherwise pass decreasing tsc values to the guest. */ 1822 Log(("TSC %RX64 offset %RX64 time=%RX64 last=%RX64 (diff=%RX64, virt_tsc=%RX64)\n", u64CurTSC, pVCpu->hwaccm.s. u64TSCOffset, u64CurTSC + pVCpu->hwaccm.s.u64TSCOffset, TMCpuTickGetLastSeen(pVCpu), TMCpuTickGetLastSeen(pVCpu) - u64CurTSC - pVCpu->hwaccm.s.u64TSCOffset, TMCpuTickGet(pVCpu)));1822 Log(("TSC %RX64 offset %RX64 time=%RX64 last=%RX64 (diff=%RX64, virt_tsc=%RX64)\n", u64CurTSC, pVCpu->hwaccm.s.vmx.u64TSCOffset, u64CurTSC + pVCpu->hwaccm.s.vmx.u64TSCOffset, TMCpuTickGetLastSeen(pVCpu), TMCpuTickGetLastSeen(pVCpu) - u64CurTSC - pVCpu->hwaccm.s.vmx.u64TSCOffset, TMCpuTickGet(pVCpu))); 1823 1823 pVCpu->hwaccm.s.vmx.proc_ctls |= VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT; 1824 1824 rc = VMXWriteVMCS(VMX_VMCS_CTRL_PROC_EXEC_CONTROLS, pVCpu->hwaccm.s.vmx.proc_ctls); … … 2592 2592 /* Possibly the last TSC value seen by the guest (too high) (only when we're in tsc offset mode). */ 2593 2593 if (!(pVCpu->hwaccm.s.vmx.proc_ctls & VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT)) 2594 TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVCpu->hwaccm.s. u64TSCOffset - 0x1000 /* guestimate of world switch overhead in clock ticks */);2594 TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVCpu->hwaccm.s.vmx.u64TSCOffset - 0x1000 /* guestimate of world switch overhead in clock ticks */); 2595 2595 2596 2596 TMNotifyEndOfExecution(pVCpu);
Note:
See TracChangeset
for help on using the changeset viewer.