Changeset 19032 in vbox
- Timestamp:
- Apr 20, 2009 3:03:08 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46143
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/tm.h
r13778 r19032 73 73 74 74 75 VMMDECL(void) TMNotifyStartOfExecution(PVM pVM);76 VMMDECL(void) TMNotifyEndOfExecution(PVM pVM);77 VMMDECL(void) TMNotifyStartOfHalt(PVM pVM);78 VMMDECL(void) TMNotifyEndOfHalt(PVM pVM);75 VMMDECL(void) TMNotifyStartOfExecution(PVMCPU pVCpu); 76 VMMDECL(void) TMNotifyEndOfExecution(PVMCPU pVCpu); 77 VMMDECL(void) TMNotifyStartOfHalt(PVMCPU pVCpu); 78 VMMDECL(void) TMNotifyEndOfHalt(PVMCPU pVCpu); 79 79 80 80 … … 113 113 * @{ 114 114 */ 115 VMMDECL(int) TMCpuTickResume(PVM pVM);116 VMMDECL(int) TMCpuTickPause(PVM pVM);117 VMMDECL(uint64_t) TMCpuTickGet(PVM pVM);118 VMMDECL(bool) TMCpuTickCanUseRealTSC(PVM pVM, uint64_t *poffRealTSC);119 VMMDECL(int) TMCpuTickSet(PVM pVM, uint64_t u64Tick);115 VMMDECL(int) TMCpuTickResume(PVMCPU pVCpu); 116 VMMDECL(int) TMCpuTickPause(PVMCPU pVCpu); 117 VMMDECL(uint64_t) TMCpuTickGet(PVMCPU pVCpu); 118 VMMDECL(bool) TMCpuTickCanUseRealTSC(PVMCPU pVCpu, uint64_t *poffRealTSC); 119 VMMDECL(int) TMCpuTickSet(PVMCPU pVCpu, uint64_t u64Tick); 120 120 VMMDECL(uint64_t) TMCpuTicksPerSecond(PVM pVM); 121 121 /** @} */ -
trunk/src/VBox/VMM/EM.cpp
r19015 r19032 3509 3509 rc = TMVirtualResume(pVM); 3510 3510 Assert(rc == VINF_SUCCESS); 3511 rc = TMCpuTickResume(pV M);3511 rc = TMCpuTickResume(pVCpu); 3512 3512 Assert(rc == VINF_SUCCESS); 3513 3513 … … 3646 3646 Log2(("EMR3ExecuteVM: returns VINF_EM_OFF (%d -> %d)\n", pVCpu->em.s.enmState, EMSTATE_TERMINATING)); 3647 3647 TMVirtualPause(pVM); 3648 TMCpuTickPause(pV M);3648 TMCpuTickPause(pVCpu); 3649 3649 VMMR3Unlock(pVM); 3650 3650 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); … … 3658 3658 Log(("EMR3ExecuteVM returns VINF_EM_TERMINATE (%d -> %d)\n", pVCpu->em.s.enmState, EMSTATE_TERMINATING)); 3659 3659 TMVirtualPause(pVM); 3660 TMCpuTickPause(pV M);3660 TMCpuTickPause(pVCpu); 3661 3661 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); 3662 3662 return rc; … … 3670 3670 pVCpu->em.s.enmState = EMSTATE_SUSPENDED; 3671 3671 TMVirtualPause(pVM); 3672 TMCpuTickPause(pV M);3672 TMCpuTickPause(pVCpu); 3673 3673 VMMR3Unlock(pVM); 3674 3674 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); … … 3806 3806 case EMSTATE_SUSPENDED: 3807 3807 TMVirtualPause(pVM); 3808 TMCpuTickPause(pV M);3808 TMCpuTickPause(pVCpu); 3809 3809 VMMR3Unlock(pVM); 3810 3810 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); … … 3817 3817 case EMSTATE_DEBUG_GUEST_RAW: 3818 3818 TMVirtualPause(pVM); 3819 TMCpuTickPause(pV M);3819 TMCpuTickPause(pVCpu); 3820 3820 rc = emR3Debug(pVM, pVCpu, rc); 3821 3821 TMVirtualResume(pVM); 3822 TMCpuTickResume(pV M);3822 TMCpuTickResume(pVCpu); 3823 3823 Log2(("EMR3ExecuteVM: enmr3Debug -> %Rrc (state %d)\n", rc, pVCpu->em.s.enmState)); 3824 3824 break; … … 3830 3830 { 3831 3831 TMVirtualPause(pVM); 3832 TMCpuTickPause(pV M);3832 TMCpuTickPause(pVCpu); 3833 3833 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); 3834 3834 … … 3845 3845 STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatTotal, x); 3846 3846 TMVirtualResume(pVM); 3847 TMCpuTickResume(pV M);3847 TMCpuTickResume(pVCpu); 3848 3848 break; 3849 3849 } … … 3855 3855 { 3856 3856 TMVirtualPause(pVM); 3857 TMCpuTickPause(pV M);3857 TMCpuTickPause(pVCpu); 3858 3858 VMMR3FatalDump(pVM, pVCpu, rc); 3859 3859 emR3Debug(pVM, pVCpu, rc); … … 3872 3872 pVCpu->em.s.enmState = EMSTATE_GURU_MEDITATION; 3873 3873 TMVirtualPause(pVM); 3874 TMCpuTickPause(pV M);3874 TMCpuTickPause(pVCpu); 3875 3875 VMMR3Unlock(pVM); 3876 3876 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatTotal, x); … … 3886 3886 LogFlow(("EMR3ExecuteVM: returns %Rrc (longjmp / fatal error)\n", rc)); 3887 3887 TMVirtualPause(pVM); 3888 TMCpuTickPause(pV M);3888 TMCpuTickPause(pVCpu); 3889 3889 VMMR3FatalDump(pVM, pVCpu, rc); 3890 3890 emR3Debug(pVM, pVCpu, rc); -
trunk/src/VBox/VMM/TM.cpp
r15844 r19032 91 91 * Each clock has its own scheduling facility, or timer queue if you like. 92 92 * There are a few factors which makes it a bit complex. First, there is the 93 * usual R0 vs R3 vs. RC thing. Then there ismultiple threads, and then there93 * usual R0 vs R3 vs. RC thing. Then there are multiple threads, and then there 94 94 * is the timer thread that periodically checks whether any timers has expired 95 95 * without EMT noticing. On the API level, all but the create and save APIs … … 98 98 * The design is using a doubly linked list of active timers which is ordered 99 99 * by expire date. This list is only modified by the EMT thread. Updates to 100 * the list are batched in a singly linked list, which is then process by the100 * the list are batched in a singly linked list, which is then processed by the 101 101 * EMT thread at the first opportunity (immediately, next time EMT modifies a 102 102 * timer on that clock, or next timer timeout). Both lists are offset based and … … 310 310 { 311 311 if (!pVM->tm.s.fTSCUseRealTSC) 312 pVM->tm.s.fMaybeUseOffsettedHostTSC = tmR3HasFixedTSC(pVM); 312 { 313 /* @todo simple case for guest SMP; always emulate RDTSC */ 314 if (pVM->cCPUs == 1) 315 pVM->tm.s.fMaybeUseOffsettedHostTSC = tmR3HasFixedTSC(pVM); 316 } 313 317 else 314 318 pVM->tm.s.fMaybeUseOffsettedHostTSC = true; … … 346 350 /** @cfgm{TM/TSCTiedToExecution, bool, false} 347 351 * Whether the TSC should be tied to execution. This will exclude most of the 348 * virtualization overhead, but will by default include the time spen din the352 * virtualization overhead, but will by default include the time spent in the 349 353 * halt state (see TM/TSCNotTiedToHalt). This setting will override all other 350 354 * TSC settings except for TSCTicksPerSecond and TSCNotTiedToHalt, which should … … 984 988 static DECLCALLBACK(int) tmR3Save(PVM pVM, PSSMHANDLE pSSM) 985 989 { 990 unsigned i; 991 986 992 LogFlow(("tmR3Save:\n")); 987 Assert(!pVM->tm.s.fTSCTicking); 993 #ifdef VBOX_STRICT 994 for (i=0;i<pVM->cCPUs;i++) 995 { 996 PVMCPU pVCpu = &pVM->aCpus[i]; 997 Assert(!pVCpu->tm.s.fTSCTicking); 998 } 988 999 Assert(!pVM->tm.s.fVirtualTicking); 989 1000 Assert(!pVM->tm.s.fVirtualSyncTicking); 1001 #endif 990 1002 991 1003 /* … … 1006 1018 SSMR3PutU64(pSSM, TMCLOCK_FREQ_REAL); 1007 1019 1008 /* the cpu tick clock. */ 1009 SSMR3PutU64(pSSM, TMCpuTickGet(pVM)); 1020 for (i=0;i<pVM->cCPUs;i++) 1021 { 1022 PVMCPU pVCpu = &pVM->aCpus[i]; 1023 1024 /* the cpu tick clock. */ 1025 SSMR3PutU64(pSSM, TMCpuTickGet(pVCpu)); 1026 } 1010 1027 return SSMR3PutU64(pSSM, pVM->tm.s.cTSCTicksPerSecond); 1011 1028 } … … 1022 1039 static DECLCALLBACK(int) tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version) 1023 1040 { 1041 unsigned i; 1024 1042 LogFlow(("tmR3Load:\n")); 1025 Assert(!pVM->tm.s.fTSCTicking); 1043 1044 #ifdef VBOX_STRICT 1045 for (i=0;i<pVM->cCPUs;i++) 1046 { 1047 PVMCPU pVCpu = &pVM->aCpus[i]; 1048 Assert(!pVCpu->tm.s.fTSCTicking); 1049 } 1026 1050 Assert(!pVM->tm.s.fVirtualTicking); 1027 1051 Assert(!pVM->tm.s.fVirtualSyncTicking); 1052 #endif 1028 1053 1029 1054 /* … … 1081 1106 1082 1107 /* the cpu tick clock. */ 1083 pVM->tm.s.fTSCTicking = false; 1084 SSMR3GetU64(pSSM, &pVM->tm.s.u64TSC); 1108 for (i=0;i<pVM->cCPUs;i++) 1109 { 1110 PVMCPU pVCpu = &pVM->aCpus[i]; 1111 1112 pVCpu->tm.s.fTSCTicking = false; 1113 SSMR3GetU64(pSSM, &pVCpu->tm.s.u64TSC); 1114 1115 if (pVM->tm.s.fTSCUseRealTSC) 1116 pVCpu->tm.s.u64TSCOffset = 0; /** @todo TSC restore stuff and HWACC. */ 1117 } 1118 1085 1119 rc = SSMR3GetU64(pSSM, &u64Hz); 1086 1120 if (RT_FAILURE(rc)) 1087 1121 return rc; 1088 if (pVM->tm.s.fTSCUseRealTSC) 1089 pVM->tm.s.u64TSCOffset = 0; /** @todo TSC restore stuff and HWACC. */ 1090 else 1122 if (!pVM->tm.s.fTSCUseRealTSC) 1091 1123 pVM->tm.s.cTSCTicksPerSecond = u64Hz; 1124 1092 1125 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%RU64) fTSCVirtualized=%RTbool fTSCUseRealTSC=%RTbool (state load)\n", 1093 1126 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.fTSCVirtualized, pVM->tm.s.fTSCUseRealTSC)); … … 1360 1393 case TMCLOCK_VIRTUAL_SYNC: return TMVirtualSyncGet(pVM); 1361 1394 case TMCLOCK_REAL: return TMRealGet(pVM); 1362 case TMCLOCK_TSC: return TMCpuTickGet( pVM);1395 case TMCLOCK_TSC: return TMCpuTickGet(&pVM->aCpus[0] /* just take VCPU 0 */); 1363 1396 default: 1364 1397 AssertMsgFailed(("enmClock=%d\n", enmClock)); … … 2083 2116 * Read the times first to avoid more than necessary time variation. 2084 2117 */ 2085 const uint64_t u64TSC = TMCpuTickGet(pVM);2086 2118 const uint64_t u64Virtual = TMVirtualGet(pVM); 2087 2119 const uint64_t u64VirtualSync = TMVirtualSyncGet(pVM); 2088 2120 const uint64_t u64Real = TMRealGet(pVM); 2089 2121 2090 /* 2091 * TSC 2092 */ 2093 pHlp->pfnPrintf(pHlp, 2094 "Cpu Tick: %18RU64 (%#016RX64) %RU64Hz %s%s", 2095 u64TSC, u64TSC, TMCpuTicksPerSecond(pVM), 2096 pVM->tm.s.fTSCTicking ? "ticking" : "paused", 2097 pVM->tm.s.fTSCVirtualized ? " - virtualized" : ""); 2098 if (pVM->tm.s.fTSCUseRealTSC) 2099 { 2100 pHlp->pfnPrintf(pHlp, " - real tsc"); 2101 if (pVM->tm.s.u64TSCOffset) 2102 pHlp->pfnPrintf(pHlp, "\n offset %RU64", pVM->tm.s.u64TSCOffset); 2103 } 2104 else 2105 pHlp->pfnPrintf(pHlp, " - virtual clock"); 2106 pHlp->pfnPrintf(pHlp, "\n"); 2122 for (unsigned i=0;i<pVM->cCPUs;i++) 2123 { 2124 PVMCPU pVCpu = &pVM->aCpus[i]; 2125 2126 uint64_t u64TSC = TMCpuTickGet(pVCpu); 2127 /* 2128 * TSC 2129 */ 2130 pHlp->pfnPrintf(pHlp, 2131 "Cpu Tick: %18RU64 (%#016RX64) %RU64Hz %s%s", 2132 u64TSC, u64TSC, TMCpuTicksPerSecond(pVM), 2133 pVCpu->tm.s.fTSCTicking ? "ticking" : "paused", 2134 pVM->tm.s.fTSCVirtualized ? " - virtualized" : ""); 2135 if (pVM->tm.s.fTSCUseRealTSC) 2136 { 2137 pHlp->pfnPrintf(pHlp, " - real tsc"); 2138 if (pVCpu->tm.s.u64TSCOffset) 2139 pHlp->pfnPrintf(pHlp, "\n offset %RU64", pVCpu->tm.s.u64TSCOffset); 2140 } 2141 else 2142 pHlp->pfnPrintf(pHlp, " - virtual clock"); 2143 pHlp->pfnPrintf(pHlp, "\n"); 2144 } 2107 2145 2108 2146 /* -
trunk/src/VBox/VMM/TMInternal.h
r13742 r19032 287 287 RTUINT offVM; 288 288 289 /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */290 bool fTSCTicking;291 289 /** Set if we fully virtualize the TSC, i.e. intercept all rdtsc instructions. 292 290 * Config variable: TSCVirtualized (bool) */ … … 307 305 bool fTSCNotTiedToHalt; 308 306 bool afAlignment0[6]; /**< alignment padding */ 309 /** The offset between the host TSC and the Guest TSC.310 * Only valid if fTicking is set and and fTSCUseRealTSC is clear. */311 uint64_t u64TSCOffset;312 /** The guest TSC when fTicking is cleared. */313 uint64_t u64TSC;314 307 /** The number of CPU clock ticks per second (TMCLOCK_TSC). 315 308 * Config variable: TSCTicksPerSecond (64-bit unsigned int) … … 508 501 * See TMCPU2VM(). */ 509 502 RTUINT offVMCPU; 503 504 /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */ 505 bool fTSCTicking; 506 bool afAlignment0[3]; /**< alignment padding */ 507 508 /** The offset between the host TSC and the Guest TSC. 509 * Only valid if fTicking is set and and fTSCUseRealTSC is clear. */ 510 uint64_t u64TSCOffset; 511 512 /** The guest TSC when fTicking is cleared. */ 513 uint64_t u64TSC; 514 510 515 } TMCPU; 511 516 /** Pointer to TM VMCPU instance data. */ … … 518 523 #endif 519 524 520 int tmCpuTickPause(PVM pVM );521 int tmCpuTickResume(PVM pVM );525 int tmCpuTickPause(PVM pVM, PVMCPU pVCpu); 526 int tmCpuTickResume(PVM pVM, PVMCPU pVCpu); 522 527 523 528 DECLEXPORT(void) tmVirtualNanoTSBad(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS); -
trunk/src/VBox/VMM/VMEmt.cpp
r18927 r19032 985 985 VMMR3DECL(int) VMR3WaitHalted(PVM pVM, bool fIgnoreInterrupts) 986 986 { 987 PVMCPU pVCpu = VMMGetCpu(pVM); /* @todo SMP: get rid of this */ 988 987 989 LogFlow(("VMR3WaitHalted: fIgnoreInterrupts=%d\n", fIgnoreInterrupts)); 988 990 … … 1004 1006 */ 1005 1007 VMMR3YieldSuspend(pVM); 1006 TMNotifyStartOfHalt(pV M);1008 TMNotifyStartOfHalt(pVCpu); 1007 1009 1008 1010 /* … … 1037 1039 * Notify TM and resume the yielder 1038 1040 */ 1039 TMNotifyEndOfHalt(pV M);1041 TMNotifyEndOfHalt(pVCpu); 1040 1042 VMMR3YieldResume(pVM); 1041 1043 -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r18927 r19032 740 740 { 741 741 case MSR_IA32_TSC: 742 u64 = TMCpuTickGet(pVCpu ->CTX_SUFF(pVM));742 u64 = TMCpuTickGet(pVCpu); 743 743 break; 744 744 -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r19015 r19032 2555 2555 return VERR_EM_INTERPRETER; /* genuine #GP */ 2556 2556 2557 uint64_t uTicks = TMCpuTickGet(pV M);2557 uint64_t uTicks = TMCpuTickGet(pVCpu); 2558 2558 2559 2559 /* Same behaviour in 32 & 64 bits mode */ … … 2586 2586 return VERR_EM_INTERPRETER; /* genuine #GP */ 2587 2587 2588 uint64_t uTicks = TMCpuTickGet(pV M);2588 uint64_t uTicks = TMCpuTickGet(pVCpu); 2589 2589 2590 2590 /* Same behaviour in 32 & 64 bits mode */ … … 2799 2799 { 2800 2800 case MSR_IA32_TSC: 2801 val = TMCpuTickGet(pV M);2801 val = TMCpuTickGet(pVCpu); 2802 2802 break; 2803 2803 -
trunk/src/VBox/VMM/VMMAll/TMAll.cpp
r13633 r19032 53 53 * clocks that only ticks when we're executing guest code. 54 54 * 55 * @param pVM Pointer to the shared VM structure. 56 */ 57 VMMDECL(void) TMNotifyStartOfExecution(PVM pVM) 58 { 55 * @param pVCpu The VMCPU to operate on. 56 */ 57 VMMDECL(void) TMNotifyStartOfExecution(PVMCPU pVCpu) 58 { 59 PVM pVM = pVCpu->CTX_SUFF(pVM); 60 59 61 if (pVM->tm.s.fTSCTiedToExecution) 60 tmCpuTickResume(pVM );62 tmCpuTickResume(pVM, pVCpu); 61 63 } 62 64 … … 70 72 * clocks that only ticks when we're executing guest code. 71 73 * 72 * @param pVM Pointer to the shared VM structure. 73 */ 74 VMMDECL(void) TMNotifyEndOfExecution(PVM pVM) 75 { 74 * @param pVCpu The VMCPU to operate on. 75 */ 76 VMMDECL(void) TMNotifyEndOfExecution(PVMCPU pVCpu) 77 { 78 PVM pVM = pVCpu->CTX_SUFF(pVM); 79 76 80 if (pVM->tm.s.fTSCTiedToExecution) 77 tmCpuTickPause(pVM );81 tmCpuTickPause(pVM, pVCpu); 78 82 } 79 83 … … 87 91 * clocks that only ticks when we're halted. 88 92 * 89 * @param pVM Pointer to the shared VM structure. 90 */ 91 VMMDECL(void) TMNotifyStartOfHalt(PVM pVM) 92 { 93 * @param pVCpu The VMCPU to operate on. 94 */ 95 VMMDECL(void) TMNotifyStartOfHalt(PVMCPU pVCpu) 96 { 97 PVM pVM = pVCpu->CTX_SUFF(pVM); 98 93 99 if ( pVM->tm.s.fTSCTiedToExecution 94 100 && !pVM->tm.s.fTSCNotTiedToHalt) 95 tmCpuTickResume(pVM );101 tmCpuTickResume(pVM, pVCpu); 96 102 } 97 103 … … 105 111 * clocks that only ticks when we're halted. 106 112 * 107 * @param pVM Pointer to the shared VM structure. 108 */ 109 VMMDECL(void) TMNotifyEndOfHalt(PVM pVM) 110 { 113 * @param pVCpu The VMCPU to operate on. 114 */ 115 VMMDECL(void) TMNotifyEndOfHalt(PVMCPU pVCpu) 116 { 117 PVM pVM = pVCpu->CTX_SUFF(pVM); 118 111 119 if ( pVM->tm.s.fTSCTiedToExecution 112 120 && !pVM->tm.s.fTSCNotTiedToHalt) 113 tmCpuTickPause(pVM );121 tmCpuTickPause(pVM, pVCpu); 114 122 } 115 123 … … 659 667 VMMDECL(int) TMTimerSetMillies(PTMTIMER pTimer, uint32_t cMilliesToNext) 660 668 { 661 PVM pVM = pTimer->CTX_SUFF(pVM); 669 PVM pVM = pTimer->CTX_SUFF(pVM); 670 PVMCPU pVCpu = &pVM->aCpus[0]; /* just take the first VCPU */ 671 662 672 switch (pTimer->enmClock) 663 673 { … … 670 680 return TMTimerSet(pTimer, cMilliesToNext + TMRealGet(pVM)); 671 681 case TMCLOCK_TSC: 672 return TMTimerSet(pTimer, cMilliesToNext * pVM->tm.s.cTSCTicksPerSecond / 1000 + TMCpuTickGet(pV M));682 return TMTimerSet(pTimer, cMilliesToNext * pVM->tm.s.cTSCTicksPerSecond / 1000 + TMCpuTickGet(pVCpu)); 673 683 674 684 default: … … 688 698 VMMDECL(int) TMTimerSetMicro(PTMTIMER pTimer, uint64_t cMicrosToNext) 689 699 { 690 PVM pVM = pTimer->CTX_SUFF(pVM); 700 PVM pVM = pTimer->CTX_SUFF(pVM); 701 PVMCPU pVCpu = &pVM->aCpus[0]; /* just take the first VCPU */ 702 691 703 switch (pTimer->enmClock) 692 704 { … … 704 716 705 717 case TMCLOCK_TSC: 706 return TMTimerSet(pTimer, TMTimerFromMicro(pTimer, cMicrosToNext) + TMCpuTickGet(pV M));718 return TMTimerSet(pTimer, TMTimerFromMicro(pTimer, cMicrosToNext) + TMCpuTickGet(pVCpu)); 707 719 708 720 default: … … 722 734 VMMDECL(int) TMTimerSetNano(PTMTIMER pTimer, uint64_t cNanosToNext) 723 735 { 724 PVM pVM = pTimer->CTX_SUFF(pVM); 736 PVM pVM = pTimer->CTX_SUFF(pVM); 737 PVMCPU pVCpu = &pVM->aCpus[0]; /* just take the first VCPU */ 738 725 739 switch (pTimer->enmClock) 726 740 { … … 738 752 739 753 case TMCLOCK_TSC: 740 return TMTimerSet(pTimer, TMTimerFromNano(pTimer, cNanosToNext) + TMCpuTickGet(pV M));754 return TMTimerSet(pTimer, TMTimerFromNano(pTimer, cNanosToNext) + TMCpuTickGet(pVCpu)); 741 755 742 756 default: … … 847 861 { 848 862 uint64_t u64; 849 PVM pVM = pTimer->CTX_SUFF(pVM); 863 PVM pVM = pTimer->CTX_SUFF(pVM); 864 850 865 switch (pTimer->enmClock) 851 866 { … … 860 875 break; 861 876 case TMCLOCK_TSC: 862 u64 = TMCpuTickGet(pVM); 877 { 878 PVMCPU pVCpu = &pVM->aCpus[0]; /* just take the first VCPU */ 879 u64 = TMCpuTickGet(pVCpu); 863 880 break; 864 881 } 865 882 default: 866 883 AssertMsgFailed(("Invalid enmClock=%d\n", pTimer->enmClock)); -
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r13586 r19032 54 54 * @returns VBox status code. 55 55 * @param pVM The VM to operate on. 56 * @param pVCpu The VMCPU to operate on. 56 57 * @internal 57 58 */ 58 int tmCpuTickResume(PVM pVM )59 { 60 if (!pV M->tm.s.fTSCTicking)61 { 62 pV M->tm.s.fTSCTicking = true;59 int tmCpuTickResume(PVM pVM, PVMCPU pVCpu) 60 { 61 if (!pVCpu->tm.s.fTSCTicking) 62 { 63 pVCpu->tm.s.fTSCTicking = true; 63 64 if (pVM->tm.s.fTSCVirtualized) 64 65 { 65 66 if (pVM->tm.s.fTSCUseRealTSC) 66 pV M->tm.s.u64TSCOffset = ASMReadTSC() - pVM->tm.s.u64TSC;67 pVCpu->tm.s.u64TSCOffset = ASMReadTSC() - pVCpu->tm.s.u64TSC; 67 68 else 68 pV M->tm.s.u64TSCOffset = tmCpuTickGetRawVirtual(pVM, false /* don't check for pending timers */)69 - pVM->tm.s.u64TSC;69 pVCpu->tm.s.u64TSCOffset = tmCpuTickGetRawVirtual(pVM, false /* don't check for pending timers */) 70 - pVCpu->tm.s.u64TSC; 70 71 } 71 72 return VINF_SUCCESS; … … 80 81 * 81 82 * @returns VBox status code. 82 * @param pV M The VMto operate on.83 * @param pVCpu The VMCPU to operate on. 83 84 * @todo replace this with TMNotifyResume 84 85 */ 85 VMMDECL(int) TMCpuTickResume(PVM pVM) 86 { 86 VMMDECL(int) TMCpuTickResume(PVMCPU pVCpu) 87 { 88 PVM pVM = pVCpu->CTX_SUFF(pVM); 89 87 90 if (!pVM->tm.s.fTSCTiedToExecution) 88 return tmCpuTickResume(pVM );91 return tmCpuTickResume(pVM, pVCpu); 89 92 /* ignored */ 90 93 return VINF_SUCCESS; … … 97 100 * @returns VBox status code. 98 101 * @param pVM The VM to operate on. 102 * @param pVCpu The VMCPU to operate on. 99 103 * @internal 100 104 */ 101 int tmCpuTickPause(PVM pVM )102 { 103 if (pV M->tm.s.fTSCTicking)104 { 105 pV M->tm.s.u64TSC = TMCpuTickGet(pVM);106 pV M->tm.s.fTSCTicking = false;105 int tmCpuTickPause(PVM pVM, PVMCPU pVCpu) 106 { 107 if (pVCpu->tm.s.fTSCTicking) 108 { 109 pVCpu->tm.s.u64TSC = TMCpuTickGet(pVCpu); 110 pVCpu->tm.s.fTSCTicking = false; 107 111 return VINF_SUCCESS; 108 112 } … … 116 120 * 117 121 * @returns VBox status code. 118 * @param pV M The VMto operate on.122 * @param pVCpu The VMCPU to operate on. 119 123 * @todo replace this with TMNotifySuspend 120 124 */ 121 VMMDECL(int) TMCpuTickPause(PVM pVM) 122 { 125 VMMDECL(int) TMCpuTickPause(PVMCPU pVCpu) 126 { 127 PVM pVM = pVCpu->CTX_SUFF(pVM); 128 123 129 if (!pVM->tm.s.fTSCTiedToExecution) 124 return tmCpuTickPause(pVM );130 return tmCpuTickPause(pVM, pVCpu); 125 131 /* ignored */ 126 132 return VINF_SUCCESS; … … 132 138 * 133 139 * @returns true/false accordingly. 134 * @param pV M The VM handle.140 * @param pVCpu The VMCPU to operate on. 135 141 * @param poffRealTSC The offset against the TSC of the current CPU. 136 142 * Can be NULL. 137 143 * @thread EMT. 138 144 */ 139 VMMDECL(bool) TMCpuTickCanUseRealTSC(PVM pVM, uint64_t *poffRealTSC) 140 { 145 VMMDECL(bool) TMCpuTickCanUseRealTSC(PVMCPU pVCpu, uint64_t *poffRealTSC) 146 { 147 PVM pVM = pVCpu->CTX_SUFF(pVM); 148 141 149 /* 142 150 * We require: … … 149 157 */ 150 158 if ( pVM->tm.s.fMaybeUseOffsettedHostTSC 151 && RT_LIKELY(pV M->tm.s.fTSCTicking)159 && RT_LIKELY(pVCpu->tm.s.fTSCTicking) 152 160 && ( pVM->tm.s.fTSCUseRealTSC 153 161 || ( !pVM->tm.s.fVirtualSyncCatchUp … … 164 172 { 165 173 uint64_t u64Now = tmCpuTickGetRawVirtual(pVM, false /* don't check for pending timers */) 166 - pV M->tm.s.u64TSCOffset;174 - pVCpu->tm.s.u64TSCOffset; 167 175 /** @todo When we start collecting statistics on how much time we spend executing 168 176 * guest code before exiting, we should check this against the next virtual sync … … 176 184 /* The source is the real TSC. */ 177 185 if (pVM->tm.s.fTSCVirtualized) 178 *poffRealTSC = pV M->tm.s.u64TSCOffset;186 *poffRealTSC = pVCpu->tm.s.u64TSCOffset; 179 187 else 180 188 *poffRealTSC = 0; … … 188 196 if (!pVM->tm.s.fMaybeUseOffsettedHostTSC) 189 197 STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotFixed); 190 else if (!pV M->tm.s.fTSCTicking)198 else if (!pVCpu->tm.s.fTSCTicking) 191 199 STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotTicking); 192 200 else if (!pVM->tm.s.fTSCUseRealTSC) … … 217 225 * 218 226 * @returns Gets the CPU tsc. 219 * @param pVM The VM to operate on. 220 */ 221 VMMDECL(uint64_t) TMCpuTickGet(PVM pVM) 222 { 227 * @param pVCpu The VMCPU to operate on. 228 */ 229 VMMDECL(uint64_t) TMCpuTickGet(PVMCPU pVCpu) 230 { 231 PVM pVM = pVCpu->CTX_SUFF(pVM); 223 232 uint64_t u64; 224 if (RT_LIKELY(pVM->tm.s.fTSCTicking)) 233 234 if (RT_LIKELY(pVCpu->tm.s.fTSCTicking)) 225 235 { 226 236 if (pVM->tm.s.fTSCVirtualized) … … 230 240 else 231 241 u64 = tmCpuTickGetRawVirtual(pVM, true /* check for pending timers */); 232 u64 -= pV M->tm.s.u64TSCOffset;242 u64 -= pVCpu->tm.s.u64TSCOffset; 233 243 } 234 244 else … … 236 246 } 237 247 else 238 u64 = pV M->tm.s.u64TSC;248 u64 = pVCpu->tm.s.u64TSC; 239 249 return u64; 240 250 } … … 245 255 * 246 256 * @returns VBox status code. 247 * @param pV M The VMto operate on.257 * @param pVCpu The VMCPU to operate on. 248 258 * @param u64Tick The new timestamp value. 249 259 */ 250 VMMDECL(int) TMCpuTickSet(PVM pVM, uint64_t u64Tick)251 { 252 Assert(!pV M->tm.s.fTSCTicking);253 pV M->tm.s.u64TSC = u64Tick;260 VMMDECL(int) TMCpuTickSet(PVMCPU pVCpu, uint64_t u64Tick) 261 { 262 Assert(!pVCpu->tm.s.fTSCTicking); 263 pVCpu->tm.s.u64TSC = u64Tick; 254 264 return VINF_SUCCESS; 255 265 } -
trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp
r14299 r19032 32 32 #include "TMInternal.h" 33 33 #include <VBox/vm.h> 34 #include <VBox/vmm.h> 34 35 #include <VBox/err.h> 35 36 #include <VBox/log.h> … … 682 683 static DECLCALLBACK(int) tmVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent) 683 684 { 685 PVMCPU pVCpu = VMMGetCpu(pVM); 686 684 687 /* 685 688 * Validate it. … … 698 701 int rc = TMVirtualPause(pVM); 699 702 AssertRCReturn(rc, rc); 700 rc = TMCpuTickPause(pV M);703 rc = TMCpuTickPause(pVCpu); 701 704 AssertRCReturn(rc, rc); 702 705 } … … 711 714 int rc = TMVirtualResume(pVM); 712 715 AssertRCReturn(rc, rc); 713 rc = TMCpuTickResume(pV M);716 rc = TMCpuTickResume(pVCpu); 714 717 AssertRCReturn(rc, rc); 715 718 } -
trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp
r19016 r19032 798 798 return trpmGCExitTrap(pVM, VINF_EM_RAW_EMULATE_INSTR, pRegFrame); /* will trap (optimize later). */ 799 799 800 uint64_t uTicks = TMCpuTickGet(pV M);800 uint64_t uTicks = TMCpuTickGet(pVCpu); 801 801 pRegFrame->eax = uTicks; 802 802 pRegFrame->edx = uTicks >> 32; -
trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
r19015 r19032 792 792 793 793 /* TSC offset. */ 794 if (TMCpuTickCanUseRealTSC(pV M, &pVMCB->ctrl.u64TSCOffset))794 if (TMCpuTickCanUseRealTSC(pVCpu, &pVMCB->ctrl.u64TSCOffset)) 795 795 { 796 796 pVMCB->ctrl.u32InterceptCtrl1 &= ~SVM_CTRL1_INTERCEPT_RDTSC; … … 1053 1053 Assert(idCpuCheck == RTMpCpuId()); 1054 1054 #endif 1055 TMNotifyStartOfExecution(pV M);1055 TMNotifyStartOfExecution(pVCpu); 1056 1056 pVCpu->hwaccm.s.svm.pfnVMRun(pVM->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu); 1057 TMNotifyEndOfExecution(pV M);1057 TMNotifyEndOfExecution(pVCpu); 1058 1058 STAM_PROFILE_ADV_STOP(&pVCpu->hwaccm.s.StatInGC, x); 1059 1059 -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r19015 r19032 1600 1600 uint64_t u64TSCOffset; 1601 1601 1602 if (TMCpuTickCanUseRealTSC(pV M, &u64TSCOffset))1602 if (TMCpuTickCanUseRealTSC(pVCpu, &u64TSCOffset)) 1603 1603 { 1604 1604 /* Note: VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT takes precedence over TSC_OFFSET */ … … 2192 2192 #endif 2193 2193 2194 TMNotifyStartOfExecution(pV M);2194 TMNotifyStartOfExecution(pVCpu); 2195 2195 rc = pVCpu->hwaccm.s.vmx.pfnStartVM(pVCpu->hwaccm.s.fResumeVM, pCtx, &pVCpu->hwaccm.s.vmx.VMCSCache, pVM, pVCpu); 2196 TMNotifyEndOfExecution(pV M);2196 TMNotifyEndOfExecution(pVCpu); 2197 2197 2198 2198 AssertMsg(!pVCpu->hwaccm.s.vmx.VMCSCache.Write.cValidEntries, ("pVCpu->hwaccm.s.vmx.VMCSCache.Write.cValidEntries=%d\n", pVCpu->hwaccm.s.vmx.VMCSCache.Write.cValidEntries)); -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r18927 r19032 568 568 } 569 569 570 TMNotifyStartOfExecution(pV M);570 TMNotifyStartOfExecution(pVCpu); 571 571 rc = pVM->vmm.s.pfnHostToGuestR0(pVM); 572 572 pVM->vmm.s.iLastGZRc = rc; 573 TMNotifyEndOfExecution(pV M);573 TMNotifyEndOfExecution(pVCpu); 574 574 575 575 /* Re-enable VT-x if previously turned off. */ -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r19015 r19032 761 761 //GEN_CHECK_OFF(TM, pvGIPR0); 762 762 GEN_CHECK_OFF(TM, pvGIPRC); 763 GEN_CHECK_OFF(TM , fTSCTicking);763 GEN_CHECK_OFF(TMCPU, fTSCTicking); 764 764 GEN_CHECK_OFF(TM, fTSCUseRealTSC); 765 765 GEN_CHECK_OFF(TM, fTSCTiedToExecution); 766 GEN_CHECK_OFF(TM , u64TSCOffset);767 GEN_CHECK_OFF(TM , u64TSC);766 GEN_CHECK_OFF(TMCPU, u64TSCOffset); 767 GEN_CHECK_OFF(TMCPU, u64TSC); 768 768 GEN_CHECK_OFF(TM, cTSCTicksPerSecond); 769 769 GEN_CHECK_OFF(TM, fVirtualTicking); -
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r19015 r19032 1161 1161 { "STAMR3Register", (void *)(uintptr_t)&STAMR3Register, &g_aArgsSTAMR3Register[0], RT_ELEMENTS(g_aArgsSTAMR3Register), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1162 1162 { "STAMR3Deregister", (void *)(uintptr_t)&STAMR3Deregister, &g_aArgsSTAMR3Deregister[0], RT_ELEMENTS(g_aArgsSTAMR3Deregister), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1163 { "TMCpuTickGet", (void *)(uintptr_t)&TMCpuTickGet, &g_aArgsVM [0], RT_ELEMENTS(g_aArgsVM),REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },1164 { "TMCpuTickPause", (void *)(uintptr_t)&TMCpuTickPause, &g_aArgsVM [0], RT_ELEMENTS(g_aArgsVM),REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1165 { "TMCpuTickResume", (void *)(uintptr_t)&TMCpuTickResume, &g_aArgsVM [0], RT_ELEMENTS(g_aArgsVM),REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1166 { "TMNotifyEndOfExecution", (void *)(uintptr_t)&TMNotifyEndOfExecution, &g_aArgsVM [0], RT_ELEMENTS(g_aArgsVM),REMFNDESC_FLAGS_RET_VOID, 0, NULL },1167 { "TMNotifyStartOfExecution", (void *)(uintptr_t)&TMNotifyStartOfExecution, &g_aArgsVM [0], RT_ELEMENTS(g_aArgsVM),REMFNDESC_FLAGS_RET_VOID, 0, NULL },1163 { "TMCpuTickGet", (void *)(uintptr_t)&TMCpuTickGet, &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL }, 1164 { "TMCpuTickPause", (void *)(uintptr_t)&TMCpuTickPause, &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1165 { "TMCpuTickResume", (void *)(uintptr_t)&TMCpuTickResume, &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1166 { "TMNotifyEndOfExecution", (void *)(uintptr_t)&TMNotifyEndOfExecution, &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1167 { "TMNotifyStartOfExecution", (void *)(uintptr_t)&TMNotifyStartOfExecution, &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1168 1168 { "TMTimerPoll", (void *)(uintptr_t)&TMTimerPoll, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL }, 1169 1169 { "TMR3TimerQueuesDo", (void *)(uintptr_t)&TMR3TimerQueuesDo, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, -
trunk/src/recompiler_new/VBoxRecompiler.c
r19015 r19032 795 795 if (rc == EXCP_DEBUG) 796 796 { 797 TMCpuTickResume(pV M);798 TMCpuTickPause(pV M);797 TMCpuTickResume(pVCpu); 798 TMCpuTickPause(pVCpu); 799 799 TMVirtualResume(pVM); 800 800 TMVirtualPause(pVM); … … 924 924 * Now we set the execute single instruction flag and enter the cpu_exec loop. 925 925 */ 926 TMNotifyStartOfExecution(pV M);926 TMNotifyStartOfExecution(pVCpu); 927 927 pVM->rem.s.Env.interrupt_request = CPU_INTERRUPT_SINGLE_INSTR; 928 928 rc = cpu_exec(&pVM->rem.s.Env); 929 TMNotifyEndOfExecution(pV M);929 TMNotifyEndOfExecution(pVCpu); 930 930 switch (rc) 931 931 { … … 1051 1051 Assert(pVM->rem.s.fInREM); 1052 1052 1053 TMNotifyStartOfExecution(pV M);1053 TMNotifyStartOfExecution(pVCpu); 1054 1054 rc = cpu_exec(&pVM->rem.s.Env); 1055 TMNotifyEndOfExecution(pV M);1055 TMNotifyEndOfExecution(pVCpu); 1056 1056 switch (rc) 1057 1057 { … … 3995 3995 { 3996 3996 STAM_COUNTER_INC(&gStatCpuGetTSC); 3997 return TMCpuTickGet(env->pV M);3997 return TMCpuTickGet(env->pVCpu); 3998 3998 } 3999 3999
Note:
See TracChangeset
for help on using the changeset viewer.