Changeset 53441 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Dec 4, 2014 11:06:26 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 97148
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r53430 r53441 67 67 /** @todo Test that pausing and resuming doesn't cause lag! (I.e. that we're 68 68 * unpaused before the virtual time and stopped after it. */ 69 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)69 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 70 70 pVCpu->tm.s.offTSCRawSrc = ASMReadTSC() - pVCpu->tm.s.u64TSC; 71 71 else … … 102 102 103 103 /* When resuming, use the TSC value of the last stopped VCPU to avoid the TSC going back. */ 104 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)104 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 105 105 pVCpu->tm.s.offTSCRawSrc = ASMReadTSC() - pVM->tm.s.u64LastPausedTSC; 106 106 else … … 182 182 { 183 183 /* Sample the reason for refusing. */ 184 if (pVM->tm.s.enm Mode != TMMODE_DYNAMIC)184 if (pVM->tm.s.enmTSCMode != TMTSCMODE_DYNAMIC) 185 185 STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotFixed); 186 186 else if (!pVCpu->tm.s.fTSCTicking) 187 187 STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotTicking); 188 else if (pVM->tm.s.enm Mode != TMMODE_REAL_TSC_OFFSET)188 else if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET) 189 189 { 190 190 if (pVM->tm.s.fVirtualSyncCatchUp) … … 235 235 */ 236 236 *pfParavirtTsc = GIMIsParavirtTscEnabled(pVM); 237 if ( pVM->tm.s.enm Mode == TMMODE_DYNAMIC237 if ( pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC 238 238 && RT_LIKELY(pVCpu->tm.s.fTSCTicking) 239 && ( pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET239 && ( pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET 240 240 || ( !pVM->tm.s.fVirtualSyncCatchUp 241 241 && RT_LIKELY(pVM->tm.s.fVirtualSyncTicking) 242 242 && !pVM->tm.s.fVirtualWarpDrive))) 243 243 { 244 if (pVM->tm.s.enm Mode != TMMODE_REAL_TSC_OFFSET)244 if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET) 245 245 { 246 246 /* The source is the timer synchronous virtual clock. */ … … 329 329 */ 330 330 *pfParavirtTsc = GIMIsParavirtTscEnabled(pVM); 331 if ( pVM->tm.s.enm Mode == TMMODE_DYNAMIC331 if ( pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC 332 332 && RT_LIKELY(pVCpu->tm.s.fTSCTicking) 333 && ( pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET333 && ( pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET 334 334 || ( !pVM->tm.s.fVirtualSyncCatchUp 335 335 && RT_LIKELY(pVM->tm.s.fVirtualSyncTicking) … … 337 337 { 338 338 *pfOffsettedTsc = true; 339 if (pVM->tm.s.enm Mode != TMMODE_REAL_TSC_OFFSET)339 if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET) 340 340 { 341 341 /* The source is the timer synchronous virtual clock. */ … … 383 383 { 384 384 PVM pVM = pVCpu->CTX_SUFF(pVM); 385 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)385 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 386 386 u64 = ASMReadTSC(); 387 387 else … … 505 505 /** @todo revisit this, not sure why we need to get the rate from GIP for 506 506 * real-tsc-offset. */ 507 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)507 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 508 508 { 509 509 uint64_t cTSCTicksPerSecond = SUPGetCpuHzFromGIP(g_pSUPGlobalInfoPage); -
trunk/src/VBox/VMM/VMMR3/TM.cpp
r53438 r53441 167 167 *******************************************************************************/ 168 168 static bool tmR3HasFixedTSC(PVM pVM); 169 static const char * tmR3Get ModeName(PVM pVM);169 static const char * tmR3GetTSCModeName(PVM pVM); 170 170 static uint64_t tmR3CalibrateTSC(PVM pVM); 171 171 static DECLCALLBACK(int) tmR3Save(PVM pVM, PSSMHANDLE pSSM); … … 360 360 * Determine the TSC configuration and frequency. 361 361 */ 362 /** @cfgm{/TM/ Mode, string, Depends on the CPU and VM config}363 * The name of the TSC mode to use: VirtTSCEmulated, RealTSCOffset or Dy amic.362 /** @cfgm{/TM/TSCMode, string, Depends on the CPU and VM config} 363 * The name of the TSC mode to use: VirtTSCEmulated, RealTSCOffset or Dynamic. 364 364 * The default depends on the VM configuration and the capabilities of the 365 365 * host CPU. Other config options or runtime changes may override the TSC 366 366 * mode specified here. 367 * @todo r=bird: s/Mode/TSCMode/g */368 char sz Mode[32];369 rc = CFGMR3QueryString(pCfgHandle, " Mode", szMode, sizeof(szMode));367 */ 368 char szTSCMode[32]; 369 rc = CFGMR3QueryString(pCfgHandle, "TSCMode", szTSCMode, sizeof(szTSCMode)); 370 370 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 371 371 { … … 375 375 * without any kind of coordination) will lead to inconsistent TSC behavior with 376 376 * guest SMP, including TSC going backwards. */ 377 pVM->tm.s.enm Mode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMMODE_DYNAMIC : TMMODE_VIRT_TSC_EMULATED;377 pVM->tm.s.enmTSCMode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMTSCMODE_DYNAMIC : TMTSCMODE_VIRT_TSC_EMULATED; 378 378 } 379 379 else if (RT_FAILURE(rc)) … … 381 381 else 382 382 { 383 if (!RTStrCmp(sz Mode, "VirtTSCEmulated"))384 pVM->tm.s.enm Mode = TMMODE_VIRT_TSC_EMULATED;385 else if (!RTStrCmp(sz Mode, "RealTSCOffset"))386 pVM->tm.s.enm Mode = TMMODE_REAL_TSC_OFFSET;387 else if (!RTStrCmp(sz Mode, "Dynamic"))388 pVM->tm.s.enm Mode = TMMODE_DYNAMIC;383 if (!RTStrCmp(szTSCMode, "VirtTSCEmulated")) 384 pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED; 385 else if (!RTStrCmp(szTSCMode, "RealTSCOffset")) 386 pVM->tm.s.enmTSCMode = TMTSCMODE_REAL_TSC_OFFSET; 387 else if (!RTStrCmp(szTSCMode, "Dynamic")) 388 pVM->tm.s.enmTSCMode = TMTSCMODE_DYNAMIC; 389 389 else 390 return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM mode value \"%s\""), sz Mode);390 return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM mode value \"%s\""), szTSCMode); 391 391 } 392 392 393 393 /** @cfgm{/TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP} 394 394 * The number of TSC ticks per second (i.e. the TSC frequency). This will 395 * override TSCtTSC, TSCVirtualized and MaybeUseOffsettedHostTSC.395 * override enmTSCMode. 396 396 */ 397 397 rc = CFGMR3QueryU64(pCfgHandle, "TSCTicksPerSecond", &pVM->tm.s.cTSCTicksPerSecond); … … 399 399 { 400 400 pVM->tm.s.cTSCTicksPerSecond = tmR3CalibrateTSC(pVM); 401 if ( pVM->tm.s.enm Mode != TMMODE_REAL_TSC_OFFSET401 if ( pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET 402 402 && pVM->tm.s.cTSCTicksPerSecond >= _4G) 403 403 { 404 404 pVM->tm.s.cTSCTicksPerSecond = _4G - 1; /* (A limitation of our math code) */ 405 pVM->tm.s.enm Mode = TMMODE_VIRT_TSC_EMULATED;405 pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED; 406 406 } 407 407 } … … 416 416 else 417 417 { 418 pVM->tm.s.enm Mode = TMMODE_VIRT_TSC_EMULATED;418 pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED; 419 419 } 420 420 … … 431 431 N_("Configuration error: Failed to querying bool value \"TSCTiedToExecution\"")); 432 432 if (pVM->tm.s.fTSCTiedToExecution) 433 pVM->tm.s.enm Mode = TMMODE_VIRT_TSC_EMULATED;433 pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED; 434 434 435 435 /** @cfgm{/TM/TSCNotTiedToHalt, bool, true} … … 544 544 if (pVM->tm.s.fVirtualWarpDrive) 545 545 { 546 pVM->tm.s.enm Mode = TMMODE_VIRT_TSC_EMULATED;546 pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED; 547 547 LogRel(("TM: Warp-drive active. u32VirtualWarpDrivePercentage=%RI32\n", pVM->tm.s.u32VirtualWarpDrivePercentage)); 548 548 } … … 550 550 /* Setup and report */ 551 551 CPUMR3SetCR4Feature(pVM, X86_CR4_TSD, ~X86_CR4_TSD); 552 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enm Mode=%d (%s)\n"552 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmTSCMode=%d (%s)\n" 553 553 "TM: TSCTiedToExecution=%RTbool TSCNotTiedToHalt=%RTbool\n", 554 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enm Mode, tmR3GetModeName(pVM),554 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM), 555 555 pVM->tm.s.fTSCTiedToExecution, pVM->tm.s.fTSCNotTiedToHalt)); 556 556 … … 1317 1317 pVM->tm.s.u64LastPausedTSC = pVCpu->tm.s.u64TSC; 1318 1318 1319 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)1319 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 1320 1320 pVCpu->tm.s.offTSCRawSrc = 0; /** @todo TSC restore stuff and HWACC. */ 1321 1321 } … … 1324 1324 if (RT_FAILURE(rc)) 1325 1325 return rc; 1326 if (pVM->tm.s.enm Mode != TMMODE_REAL_TSC_OFFSET)1326 if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET) 1327 1327 pVM->tm.s.cTSCTicksPerSecond = u64Hz; 1328 1328 /** @todo Compare with real TSC rate even when restoring with real-tsc-offset 1329 1329 * mode. */ 1330 1330 1331 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enm Mode=%d (%s) (state load)\n",1332 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enm Mode, tmR3GetModeName(pVM)));1331 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmTSCMode=%d (%s) (state load)\n", 1332 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM))); 1333 1333 1334 1334 /* … … 2844 2844 TMR3NotifySuspend(pVM, pVCpu); 2845 2845 2846 /** @todo Should switch TM mode to virt-tsc-emulated if it isn't alread !.*/2846 /** @todo Should switch TM mode to virt-tsc-emulated if it isn't already! */ 2847 2847 pVM->tm.s.u32VirtualWarpDrivePercentage = u32Percent; 2848 2848 pVM->tm.s.fVirtualWarpDrive = u32Percent != 100; … … 3193 3193 u64TSC, u64TSC, TMCpuTicksPerSecond(pVM), 3194 3194 pVCpu->tm.s.fTSCTicking ? "ticking" : "paused"); 3195 if (pVM->tm.s.enm Mode == TMMODE_REAL_TSC_OFFSET)3195 if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET) 3196 3196 { 3197 3197 pHlp->pfnPrintf(pHlp, " - real tsc offset"); … … 3241 3241 3242 3242 /** 3243 * Gets the descriptive TM mode name.3243 * Gets the descriptive TM TSC mode name. 3244 3244 * 3245 3245 * @returns The name. 3246 3246 * @param pVM Pointer to the VM. 3247 3247 */ 3248 static const char *tmR3Get ModeName(PVM pVM)3248 static const char *tmR3GetTSCModeName(PVM pVM) 3249 3249 { 3250 3250 Assert(pVM); 3251 switch (pVM->tm.s.enm Mode)3252 { 3253 case TM MODE_REAL_TSC_OFFSET: return "RealTscOffset";3254 case TM MODE_VIRT_TSC_EMULATED: return "VirtTscEmulated";3255 case TM MODE_DYNAMIC: return "Dynamic";3256 default: return "?????";3257 } 3258 } 3259 3251 switch (pVM->tm.s.enmTSCMode) 3252 { 3253 case TMTSCMODE_REAL_TSC_OFFSET: return "RealTscOffset"; 3254 case TMTSCMODE_VIRT_TSC_EMULATED: return "VirtTscEmulated"; 3255 case TMTSCMODE_DYNAMIC: return "Dynamic"; 3256 default: return "?????"; 3257 } 3258 } 3259 -
trunk/src/VBox/VMM/include/TMInternal.h
r53439 r53441 321 321 * 322 322 * The main modes of how TM implements the TSC clock (TMCLOCK_TSC). 323 * @todo r=bird: s/TMMODE/TMTSCMODE/g 324 */ 325 typedef enum TMMODE 323 */ 324 typedef enum TMTSCMODE 326 325 { 327 326 /** The guest TSC is an emulated virtual TSC. */ 328 TM MODE_VIRT_TSC_EMULATED = 1,327 TMTSCMODE_VIRT_TSC_EMULATED = 1, 329 328 /** The guest TSC is an offset of the real TSC. */ 330 TM MODE_REAL_TSC_OFFSET,329 TMTSCMODE_REAL_TSC_OFFSET, 331 330 /** The guest TSC is dynamically derived through emulation or offsetting. */ 332 TM MODE_DYNAMIC333 } TM MODE;334 AssertCompileSize(TM MODE, sizeof(uint32_t));331 TMTSCMODE_DYNAMIC 332 } TMTSCMODE; 333 AssertCompileSize(TMTSCMODE, sizeof(uint32_t)); 335 334 336 335 … … 354 353 355 354 /** The current TSC mode of the VM. 356 * Config variable: Mode (string) 357 * @todo r=bird: s/enmMode/enmTscMode/g */ 358 TMMODE enmMode; 355 * Config variable: Mode (string). */ 356 TMTSCMODE enmTSCMode; 359 357 /** Whether the TSC is tied to the execution of code. 360 358 * Config variable: TSCTiedToExecution (bool) */ … … 370 368 /** The number of CPU clock ticks per second (TMCLOCK_TSC). 371 369 * Config variable: TSCTicksPerSecond (64-bit unsigned int) 372 * The config variable implies @c enm Mode would be373 * TM MODE_VIRT_TSC_EMULATED. */370 * The config variable implies @c enmTSCMode would be 371 * TMTSCMODE_VIRT_TSC_EMULATED. */ 374 372 uint64_t cTSCTicksPerSecond; 375 373 /** The TSC difference introduced by pausing the VM. */ -
trunk/src/VBox/VMM/testcase/tstVMStruct.h
r53430 r53441 1011 1011 GEN_CHECK_OFF(TM, pvGIPRC); 1012 1012 GEN_CHECK_OFF(TMCPU, fTSCTicking); 1013 GEN_CHECK_OFF(TM, enm Mode);1013 GEN_CHECK_OFF(TM, enmTSCMode); 1014 1014 GEN_CHECK_OFF(TM, fTSCTiedToExecution); 1015 1015 GEN_CHECK_OFF(TMCPU, offTSCRawSrc);
Note:
See TracChangeset
for help on using the changeset viewer.