Changeset 57090 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Jul 27, 2015 9:44:51 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 101813
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r57057 r57090 161 161 { "SUPGetTscDeltaSlow", (void *)SUPGetTscDeltaSlow }, 162 162 { "SUPGetCpuHzFromGipForAsyncMode", (void *)SUPGetCpuHzFromGipForAsyncMode }, 163 { "SUPIsTscFreqCompatible", (void *)SUPIsTscFreqCompatible }, 164 { "SUPIsTscFreqCompatibleEx", (void *)SUPIsTscFreqCompatibleEx }, 163 165 { "SUPR0ComponentDeregisterFactory", (void *)SUPR0ComponentDeregisterFactory }, 164 166 { "SUPR0ComponentQueryFactory", (void *)SUPR0ComponentQueryFactory }, -
trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp
r55246 r57090 270 270 271 271 272 273 /** 274 * Worker for SUPIsTscFreqCompatible(). 275 * 276 * @returns true if it's compatible, false otherwise. 277 * @param uBaseCpuHz The reference CPU frequency of the system. 278 * @param uCpuHz The CPU frequency to compare with the base. 279 * @param fRelax Whether to use a more relaxed threshold (like 280 * for when running in a virtualized environment). 281 * 282 * @remarks Don't use directly, use SUPIsTscFreqCompatible() instead. This is 283 * to be used by tstGIP-2 or the like. 284 */ 285 SUPDECL(bool) SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz, bool fRelax) 286 { 287 if (uBaseCpuHz != uCpuHz) 288 { 289 /* Arbitrary tolerance threshold, tweak later if required, perhaps 290 more tolerance on lower frequencies and less tolerance on higher. */ 291 uint16_t uThr = !fRelax ? 666 /* 0.15% */ : 125 /* 0.8% */; 292 uint64_t uLo = uBaseCpuHz / uThr; 293 uint64_t uHi = uBaseCpuHz + (uBaseCpuHz - uLo); 294 if ( uCpuHz < uLo 295 || uCpuHz > uHi) 296 return false; 297 } 298 return true; 299 } 300 301 302 /** 303 * Checks if the provided TSC frequency is close enough to the computed TSC 304 * frequency of the host. 305 * 306 * @returns true if it's compatible, false otherwise. 307 * @param uCpuHz The TSC frequency to check. 308 * @param puGipCpuHz Where to store the GIP TSC frequency used 309 * during the compatibility test - optional. 310 * @param fRelax Whether to use a more relaxed threshold (like 311 * for when running in a virtualized environment). 312 */ 313 SUPDECL(bool) SUPIsTscFreqCompatible(uint64_t uCpuHz, uint64_t *puGipCpuHz, bool fRelax) 314 { 315 PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage; 316 if ( pGip 317 && pGip->u32Mode != SUPGIPMODE_ASYNC_TSC) 318 { 319 uint64_t uGipCpuHz = pGip->u64CpuHz; 320 if (puGipCpuHz) 321 *puGipCpuHz = uGipCpuHz; 322 return SUPIsTscFreqCompatibleEx(uGipCpuHz, uCpuHz, fRelax); 323 } 324 return false; 325 } 326 272 327 #endif /* RT_ARCH_AMD64 || RT_ARCH_X86 */ 273 328
Note:
See TracChangeset
for help on using the changeset viewer.