Changeset 2581 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- May 10, 2007 3:13:29 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TMAll.cpp
r2283 r2581 1336 1336 #endif /* !VBOX_STRICT */ 1337 1337 1338 -
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r2551 r2581 99 99 * @returns TSC ofset 100 100 * @param pVM The VM to operate on. 101 * @todo Remove this when the code has been switched to TMCpuTickCanUseRealTSC. 101 102 */ 102 103 TMDECL(uint64_t) TMCpuTickGetOffset(PVM pVM) … … 120 121 121 122 return u64 - ASMReadTSC(); 123 } 124 125 126 /** 127 * Checks if AMD-V / VT-x can use an offsetted hardware TSC or not. 128 * 129 * @returns true/false accordingly. 130 * @param pVM The VM handle. 131 * @param poffRealTSC The offset against the TSC of the current CPU. 132 * Can be NULL. 133 * @thread EMT. 134 */ 135 TMDECL(bool) TMCpuTickCanUseRealTSC(PVM pVM, uint64_t *poffRealTSC) 136 { 137 /* 138 * We require: 139 * 1. A fixed TSC, this is checked at init time. 140 * 2. That the TSC is ticking (we shouldn't be here if it isn't) 141 * 3. Either that we're using the real TSC as time source or 142 * a) We don't have any lag to catch up. 143 * b) The virtual sync clock hasn't been halted by an expired timer. 144 * c) We're not using warp drive (accelerated virtual guest time). 145 */ 146 if ( pVM->tm.s.fMaybeUseOffsettedHostTSC 147 && RT_LIKELY(pVM->tm.s.fTSCTicking) 148 && ( pVM->tm.s.fTSCUseRealTSC 149 || ( !pVM->tm.s.fVirtualSyncCatchUp 150 && RT_LIKELY(pVM->tm.s.fVirtualSyncTicking) 151 && !pVM->tm.s.fVirtualWarpDrive)) 152 ) 153 { 154 if (!pVM->tm.s.fTSCUseRealTSC) 155 { 156 /* The source is the timer synchronous virtual clock. */ 157 Assert(pVM->tm.s.fTSCVirtualized); 158 159 if (poffRealTSC) 160 { 161 uint64_t u64Now = tmCpuTickGetRawVirtual(pVM, false /* don't check for pending timers */) 162 - pVM->tm.s.u64TSCOffset; 163 /** @todo When we start collecting statistics on how much time we spend executing 164 * guest code before exiting, we should check this against the next virtual sync 165 * timer timeout. If it's lower than the avg. length, we should trap rdtsc to increase 166 * the chance that we'll get interrupted right after the timer expired. */ 167 *poffRealTSC = u64Now - ASMReadTSC(); 168 } 169 } 170 else if (poffRealTSC) 171 { 172 /* The source is the real TSC. */ 173 if (pVM->tm.s.fTSCVirtualized) 174 *poffRealTSC = pVM->tm.s.u64TSCOffset; 175 else 176 *poffRealTSC = 0; 177 } 178 return true; 179 } 180 181 return false; 122 182 } 123 183
Note:
See TracChangeset
for help on using the changeset viewer.