Changeset 104131 in vbox
- Timestamp:
- Apr 3, 2024 8:02:36 AM (8 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r100005 r104131 116 116 { 117 117 case TMTSCMODE_REAL_TSC_OFFSET: 118 pVCpu->tm.s.offTSCRawSrc = SUPReadTsc() - pVCpu->tm.s.u64TSC;118 pVCpu->tm.s.offTSCRawSrc = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier - pVCpu->tm.s.u64TSC; 119 119 break; 120 120 case TMTSCMODE_VIRT_TSC_EMULATED: … … 163 163 { 164 164 case TMTSCMODE_REAL_TSC_OFFSET: 165 pVCpu->tm.s.offTSCRawSrc = SUPReadTsc() - pVM->tm.s.u64LastPausedTSC;165 pVCpu->tm.s.offTSCRawSrc = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier - pVM->tm.s.u64LastPausedTSC; 166 166 break; 167 167 case TMTSCMODE_VIRT_TSC_EMULATED: … … 496 496 { 497 497 case TMTSCMODE_REAL_TSC_OFFSET: 498 u64 = SUPReadTsc() ;498 u64 = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier; 499 499 break; 500 500 case TMTSCMODE_VIRT_TSC_EMULATED: … … 642 642 #endif 643 643 if (RT_LIKELY(cTSCTicksPerSecond != ~(uint64_t)0)) 644 return cTSCTicksPerSecond ;644 return cTSCTicksPerSecond * pVM->tm.s.u8TSCMultiplier; 645 645 } 646 646 } -
trunk/src/VBox/VMM/VMMR3/TM.cpp
r100000 r104131 335 335 "TSCTiedToExecution|" 336 336 "TSCNotTiedToHalt|" 337 "TSCMultiplier|" 337 338 "ScheduleSlack|" 338 339 "CatchUpStopThreshold|" … … 420 421 } 421 422 423 /** @cfgm{/TM/TSCMultiplier, uint8_t} 424 * This is a multiplier to apply to the host TSC while calculating the guest 425 * TSC. It's recommended to avoid using a power-of-two value to reduce number 426 * of zeros in least-significant-bits of the scaled TSC. Defaults to 43 on 427 * ARM64 and 1 on all other hosts. */ 428 #ifdef RT_ARCH_ARM64 429 pVM->tm.s.u8TSCMultiplier = 43; /* 125/3 + some fudge to get us >= 1GHz from 24MHz */ 430 #else 431 pVM->tm.s.u8TSCMultiplier = 1; 432 #endif 433 rc = CFGMR3QueryU8Def(pCfgHandle, "TSCMultiplier", &pVM->tm.s.u8TSCMultiplier, pVM->tm.s.u8TSCMultiplier); 434 if (RT_FAILURE(rc)) 435 return VMSetError(pVM, rc, RT_SRC_POS, 436 N_("Configuration error: Failed to query 8-bit value \"TSCMultiplier\"")); 437 if (pVM->tm.s.u8TSCMultiplier == 0) 438 return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: \"TSCMultiplier\" must not be zero!")); 439 422 440 /** @cfgm{/TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP} 423 441 * The number of TSC ticks per second (i.e. the TSC frequency). This will … … 428 446 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 429 447 { 430 pVM->tm.s.cTSCTicksPerSecond = pVM->tm.s.cTSCTicksPerSecondHost ;448 pVM->tm.s.cTSCTicksPerSecond = pVM->tm.s.cTSCTicksPerSecondHost * pVM->tm.s.u8TSCMultiplier; 431 449 if ( ( pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC 432 450 || pVM->tm.s.enmTSCMode == TMTSCMODE_VIRT_TSC_EMULATED) … … 450 468 { 451 469 LogRel(("TM: NEM overrides the /TM/TSCTicksPerSecond=%RU64 setting.\n", pVM->tm.s.cTSCTicksPerSecond)); 452 pVM->tm.s.cTSCTicksPerSecond = pVM->tm.s.cTSCTicksPerSecondHost ;470 pVM->tm.s.cTSCTicksPerSecond = pVM->tm.s.cTSCTicksPerSecondHost * pVM->tm.s.u8TSCMultiplier; 453 471 } 454 472 … … 641 659 CPUMR3SetCR4Feature(pVM, X86_CR4_TSD, ~X86_CR4_TSD); 642 660 #endif 643 LogRel(("TM: cTSCTicksPerSecond=%'RU64 (%#RX64) enmTSCMode=%d (%s) \n"661 LogRel(("TM: cTSCTicksPerSecond=%'RU64 (%#RX64) enmTSCMode=%d (%s) TSCMultiplier=%u\n" 644 662 "TM: cTSCTicksPerSecondHost=%'RU64 (%#RX64)\n" 645 663 "TM: TSCTiedToExecution=%RTbool TSCNotTiedToHalt=%RTbool\n", 646 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM), 664 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM), pVM->tm.s.u8TSCMultiplier, 647 665 pVM->tm.s.cTSCTicksPerSecondHost, pVM->tm.s.cTSCTicksPerSecondHost, 648 666 pVM->tm.s.fTSCTiedToExecution, pVM->tm.s.fTSCNotTiedToHalt)); … … 1250 1268 { 1251 1269 case TMTSCMODE_REAL_TSC_OFFSET: 1252 offTscRawSrc = SUPReadTsc() ;1270 offTscRawSrc = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier; 1253 1271 break; 1254 1272 case TMTSCMODE_DYNAMIC: … … 3742 3760 */ 3743 3761 uint64_t uRawOldTsc = tmR3CpuTickGetRawVirtualNoCheck(pVM); 3744 uint64_t uRawNewTsc = SUPReadTsc() ;3762 uint64_t uRawNewTsc = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier; 3745 3763 uint32_t cCpus = pVM->cCpus; 3746 3764 for (uint32_t i = 0; i < cCpus; i++) … … 3796 3814 * See tmR3CpuTickParavirtEnable for an explanation of the conversion math. 3797 3815 */ 3798 uint64_t uRawOldTsc = SUPReadTsc() ;3816 uint64_t uRawOldTsc = SUPReadTsc() * pVM->tm.s.u8TSCMultiplier; 3799 3817 uint64_t uRawNewTsc = tmR3CpuTickGetRawVirtualNoCheck(pVM); 3800 3818 uint32_t cCpus = pVM->cCpus; -
trunk/src/VBox/VMM/include/TMInternal.h
r98103 r104131 478 478 /** Virtual timer synchronous time catch-up active. */ 479 479 bool volatile fVirtualSyncCatchUp; 480 /** Alignment padding. */481 bool afAlignment1[1];480 /** The multiplier for TSC. */ 481 uint8_t u8TSCMultiplier; 482 482 /** WarpDrive percentage. 483 483 * 100% is normal (fVirtualSyncNormal == true). When other than 100% we apply
Note:
See TracChangeset
for help on using the changeset viewer.