TM.cpp revision fb79ffd3fe10f969fdc16f4ae6309447ea42270d
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * TM - Time Manager.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * available from http://www.virtualbox.org. This file is free software;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * General Public License (GPL) as published by the Free Software
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * additional information or have any questions.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync/** @page pg_tm TM - The Time Manager
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The Time Manager abstracts the CPU clocks and manages timers used by the VMM,
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * device and drivers.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @see grp_tm
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @section sec_tm_clocks Clocks
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * There are currently 4 clocks:
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Virtual (guest).
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Synchronous virtual (guest).
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - CPU Tick (TSC) (guest). Only current use is rdtsc emulation. Usually a
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * function of the virtual clock.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Real (host). This is only used for display updates atm.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The most important clocks are the three first ones and of these the second is
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * the most interesting.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The synchronous virtual clock is tied to the virtual clock except that it
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * will take into account timer delivery lag caused by host scheduling. It will
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * normally never advance beyond the head timer, and when lagging too far behind
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * it will gradually speed up to catch up with the virtual clock. All devices
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * implementing time sources accessible to and used by the guest is using this
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * clock (for timers and other things). This ensures consistency between the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * time sources.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The virtual clock is implemented as an offset to a monotonic, high
3a5a556c2fdc2f5e6e190344ced2fb0c01b46ae9vboxsync * resolution, wall clock. The current time source is using the RTTimeNanoTS()
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * machinery based upon the Global Info Pages (GIP), that is, we're using TSC
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * deltas (usually 10 ms) to fill the gaps between GIP updates. The result is
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * a fairly high res clock that works in all contexts and on all hosts. The
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * virtual clock is paused when the VM isn't in the running state.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The CPU tick (TSC) is normally virtualized as a function of the synchronous
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * virtual clock, where the frequency defaults to the host cpu frequency (as we
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * measure it). In this mode it is possible to configure the frequency. Another
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * (non-default) option is to use the raw unmodified host TSC values. And yet
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * another, to tie it to time spent executing guest code. All these things are
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * configurable should non-default behavior be desirable.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The real clock is a monotonic clock (when available) with relatively low
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * resolution, though this a bit host specific. Note that we're currently not
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * servicing timers using the real clock when the VM is not running, this is
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * simply because it has not been needed yet therefore not implemented.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @subsection subsec_tm_timesync Guest Time Sync / UTC time
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Guest time syncing is primarily taken care of by the VMM device. The
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * principle is very simple, the guest additions periodically asks the VMM
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * device what the current UTC time is and makes adjustments accordingly.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * A complicating factor is that the synchronous virtual clock might be doing
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * catchups and the guest perception is currently a little bit behind the world
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * but it will (hopefully) be catching up soon as we're feeding timer interrupts
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * at a slightly higher rate. Adjusting the guest clock to the current wall
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * time in the real world would be a bad idea then because the guest will be
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * advancing too fast and run ahead of world time (if the catchup works out).
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * To solve this problem TM provides the VMM device with an UTC time source that
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * gets adjusted with the current lag, so that when the guest eventually catches
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * up the lag it will be showing correct real world time.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @section sec_tm_timers Timers
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The timers can use any of the TM clocks described in the previous section.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Each clock has its own scheduling facility, or timer queue if you like.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * There are a few factors which makes it a bit complex. First, there is the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * usual R0 vs R3 vs. RC thing. Then there are multiple threads, and then there
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * is the timer thread that periodically checks whether any timers has expired
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * without EMT noticing. On the API level, all but the create and save APIs
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * must be mulithreaded. EMT will always run the timers.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * The design is using a doubly linked list of active timers which is ordered
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * by expire date. This list is only modified by the EMT thread. Updates to
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * the list are batched in a singly linked list, which is then processed by the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * EMT thread at the first opportunity (immediately, next time EMT modifies a
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * timer on that clock, or next timer timeout). Both lists are offset based and
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * all the elements are therefore allocated from the hyper heap.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * For figuring out when there is need to schedule and run timers TM will:
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Poll whenever somebody queries the virtual clock.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Poll the virtual clocks from the EM and REM loops.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Poll the virtual clocks from trap exit path.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Poll the virtual clocks and calculate first timeout from the halt loop.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * - Employ a thread which periodically (100Hz) polls all the timer queues.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @section sec_tm_timer Logging
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Level 2: Logs a most of the timer state transitions and queue servicing.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Level 3: Logs a few oddments.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Level 4: Logs TMCLOCK_VIRTUAL_SYNC catch-up events.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync/*******************************************************************************
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync* Header Files *
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync*******************************************************************************/
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync/*******************************************************************************
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync* Defined Constants And Macros *
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync*******************************************************************************/
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync/** The current saved state version.*/
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync/*******************************************************************************
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync* Internal Functions *
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsync*******************************************************************************/
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(int) tmR3Save(PVM pVM, PSSMHANDLE pSSM);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(int) tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(void) tmR3TimerCallback(PRTTIMER pTimer, void *pvUser, uint64_t iTick);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic void tmR3TimerQueueRun(PVM pVM, PTMTIMERQUEUE pQueue);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(void) tmR3TimerInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(void) tmR3TimerInfoActive(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsyncstatic DECLCALLBACK(void) tmR3InfoClocks(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Initializes the TM.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @returns VBox status code.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * @param pVM The VM to operate on.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Assert alignment and sizes.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync AssertRelease(sizeof(pVM->tm.s) <= sizeof(pVM->tm.padding));
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Init the structure.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync int rc = MMHyperAlloc(pVM, sizeof(pVM->tm.s.paTimerQueuesR3[0]) * TMCLOCK_MAX, 0, MM_TAG_TM, &pv);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR0 = MMHyperR3ToR0(pVM, pv);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesRC = MMHyperR3ToRC(pVM, pv);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_VIRTUAL].enmClock = TMCLOCK_VIRTUAL;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_VIRTUAL].u64Expire = INT64_MAX;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_VIRTUAL_SYNC].enmClock = TMCLOCK_VIRTUAL_SYNC;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_VIRTUAL_SYNC].u64Expire = INT64_MAX;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_REAL].enmClock = TMCLOCK_REAL;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_REAL].u64Expire = INT64_MAX;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_TSC].enmClock = TMCLOCK_TSC;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.paTimerQueuesR3[TMCLOCK_TSC].u64Expire = INT64_MAX;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * We directly use the GIP to calculate the virtual time. We map the
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * the GIP into the guest context so we can do this calculation there
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * as well and save costly world switches.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync AssertMsgReturn(pVM->tm.s.pvGIPR3, ("GIP support is now required!\n"), VERR_INTERNAL_ERROR);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync AssertMsgRCReturn(rc, ("Failed to get GIP physical address!\n"), rc);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync rc = MMR3HyperMapHCPhys(pVM, pVM->tm.s.pvGIPR3, NIL_RTR0PTR, HCPhysGIP, PAGE_SIZE, "GIP", &GCPtr);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync AssertMsgFailed(("Failed to map GIP into GC, rc=%Rrc!\n", rc));
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync LogFlow(("TMR3Init: HCPhysGIP=%RHp at %RRv\n", HCPhysGIP, pVM->tm.s.pvGIPRC));
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync /* Check assumptions made in TMAllVirtual.cpp about the GIP update interval. */
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync if ( g_pSUPGlobalInfoPage->u32Magic == SUPGLOBALINFOPAGE_MAGIC
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync && g_pSUPGlobalInfoPage->u32UpdateIntervalNS >= 250000000 /* 0.25s */)
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync N_("The GIP update interval is too big. u32UpdateIntervalNS=%RU32 (u32UpdateHz=%RU32)"),
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync g_pSUPGlobalInfoPage->u32UpdateIntervalNS, g_pSUPGlobalInfoPage->u32UpdateHz);
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync LogRel(("TM: GIP - u32Mode=%d (%s) u32UpdateHz=%u\n", g_pSUPGlobalInfoPage->u32Mode,
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC ? "SyncTSC"
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync : g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_ASYNC_TSC ? "AsyncTSC" : "Unknown",
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync * Setup the VirtualGetRaw backend.
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.VirtualGetRawDataR3.pu64Prev = &pVM->tm.s.u64VirtualRawPrev;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.VirtualGetRawDataR3.pfnBad = tmVirtualNanoTSBad;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.VirtualGetRawDataR3.pfnRediscover = tmVirtualNanoTSRediscover;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync if (g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC)
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceSync;
70b16f60a7378dd3a1e6007f823c8ea9377ddfe2vboxsync pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceAsync;
if (!pCfgHandle)
/** @cfgm{/TM/TSCVirtualized,bool,true}
/** @cfgm{/TM/UseRealTSC,bool,false}
/** @cfgm{/TM/MaybeUseOffsettedHostTSC,bool,detect}
/** @cfgm{TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP}
/** @cfgm{TM/TSCTiedToExecution, bool, false}
* halt state (see TM/TSCNotTiedToHalt). This setting will override all other
/** @cfgm{TM/TSCNotTiedToHalt, bool, true}
* For overriding the default of TM/TSCTiedToExecution, i.e. set this to false
pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.fTSCVirtualized, pVM->tm.s.fTSCUseRealTSC,
/** @cfgm{TM/ScheduleSlack, uint32_t, ns, 0, UINT32_MAX, 100000}
/** @cfgm{TM/CatchUpStopThreshold, uint64_t, ns, 0, UINT64_MAX, 500000}
rc = CFGMR3QueryU64(pCfgHandle, "CatchUpStopThreshold", &pVM->tm.s.u64VirtualSyncCatchUpStopThreshold);
/** @cfgm{TM/CatchUpGiveUpThreshold, uint64_t, ns, 0, UINT64_MAX, 60000000000}
rc = CFGMR3QueryU64(pCfgHandle, "CatchUpGiveUpThreshold", &pVM->tm.s.u64VirtualSyncCatchUpGiveUpThreshold);
/** @cfgm{TM/CatchUpPrecentage[0..9], uint32_t, %, 1, 2000, various}
/** @cfgm{TM/CatchUpStartThreshold[0..9], uint64_t, ns, 0, UINT64_MAX,
return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Failed to querying 64-bit integer value \"CatchUpThreshold" #iPeriod "\"")); \
return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Configuration error: Invalid start of period #" #iPeriod ": %RU64"), u64); \
rc = CFGMR3QueryU32(pCfgHandle, "CatchUpPrecentage" #iPeriod, &pVM->tm.s.aVirtualSyncCatchUpPeriods[iPeriod].u32Percentage); \
return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Failed to querying 32-bit integer value \"CatchUpPrecentage" #iPeriod "\"")); \
/** @cfgm{TM/WarpDrivePercentage, uint32_t, %, 0, 20000, 100}
rc = CFGMR3QueryU32(CFGMR3GetRoot(pVM), "WarpDrivePercentage", &pVM->tm.s.u32VirtualWarpDrivePercentage); /* legacy */
/** @cfgm{TM/TimerMillies, uint32_t, ms, 1, 1000, 10}
return rc;
return rc;
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR3.c1nsSteps,STAMTYPE_U32, "/TM/R3/1nsSteps", STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR3.cBadPrev, STAMTYPE_U32, "/TM/R3/cBadPrev", STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR0.c1nsSteps,STAMTYPE_U32, "/TM/R0/1nsSteps", STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR0.cBadPrev, STAMTYPE_U32, "/TM/R0/cBadPrev", STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataRC.c1nsSteps,STAMTYPE_U32, "/TM/GC/1nsSteps", STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataRC.cBadPrev, STAMTYPE_U32, "/TM/GC/cBadPrev", STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
STAM_REL_REG( pVM,(void*)&pVM->tm.s.offVirtualSync, STAMTYPE_U64, "/TM/VirtualSync/CurrentOffset", STAMUNIT_NS, "The current offset. (subtract GivenUp to get the lag)");
STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.offVirtualSyncGivenUp, STAMTYPE_U64, "/TM/VirtualSync/GivenUp", STAMUNIT_NS, "Nanoseconds of the 'CurrentOffset' that's been given up and won't ever be attemted caught up with.");
#ifdef VBOX_WITH_STATISTICS
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR3.cExpired, STAMTYPE_U32, "/TM/R3/cExpired", STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR3.cUpdateRaces,STAMTYPE_U32, "/TM/R3/cUpdateRaces", STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR0.cExpired, STAMTYPE_U32, "/TM/R0/cExpired", STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR0.cUpdateRaces,STAMTYPE_U32, "/TM/R0/cUpdateRaces", STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataRC.cExpired, STAMTYPE_U32, "/TM/GC/cExpired", STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataRC.cUpdateRaces,STAMTYPE_U32, "/TM/GC/cUpdateRaces", STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
STAM_REG(pVM, &pVM->tm.s.StatDoQueues, STAMTYPE_PROFILE, "/TM/DoQueues", STAMUNIT_TICKS_PER_CALL, "Profiling timer TMR3TimerQueuesDo.");
STAM_REG(pVM, &pVM->tm.s.StatDoQueuesSchedule, STAMTYPE_PROFILE_ADV, "/TM/DoQueues/Schedule", STAMUNIT_TICKS_PER_CALL, "The scheduling part.");
STAM_REG(pVM, &pVM->tm.s.StatDoQueuesRun, STAMTYPE_PROFILE_ADV, "/TM/DoQueues/Run", STAMUNIT_TICKS_PER_CALL, "The run part.");
STAM_REG(pVM, &pVM->tm.s.StatPollAlreadySet, STAMTYPE_COUNTER, "/TM/PollAlreadySet", STAMUNIT_OCCURENCES, "TMTimerPoll calls where the FF was already set.");
STAM_REG(pVM, &pVM->tm.s.StatPollVirtual, STAMTYPE_COUNTER, "/TM/PollHitsVirtual", STAMUNIT_OCCURENCES, "The number of times TMTimerPoll found an expired TMCLOCK_VIRTUAL queue.");
STAM_REG(pVM, &pVM->tm.s.StatPollVirtualSync, STAMTYPE_COUNTER, "/TM/PollHitsVirtualSync", STAMUNIT_OCCURENCES, "The number of times TMTimerPoll found an expired TMCLOCK_VIRTUAL_SYNC queue.");
STAM_REG(pVM, &pVM->tm.s.StatPollMiss, STAMTYPE_COUNTER, "/TM/PollMiss", STAMUNIT_OCCURENCES, "TMTimerPoll calls where nothing had expired.");
STAM_REG(pVM, &pVM->tm.s.StatPostponedR3, STAMTYPE_COUNTER, "/TM/PostponedR3", STAMUNIT_OCCURENCES, "Postponed due to unschedulable state, in ring-3.");
STAM_REG(pVM, &pVM->tm.s.StatPostponedRZ, STAMTYPE_COUNTER, "/TM/PostponedRZ", STAMUNIT_OCCURENCES, "Postponed due to unschedulable state, in ring-0 / RC.");
STAM_REG(pVM, &pVM->tm.s.StatScheduleOneR3, STAMTYPE_PROFILE, "/TM/ScheduleOneR3", STAMUNIT_TICKS_PER_CALL, "Profiling the scheduling of one queue during a TMTimer* call in EMT.");
STAM_REG(pVM, &pVM->tm.s.StatScheduleOneRZ, STAMTYPE_PROFILE, "/TM/ScheduleOneRZ", STAMUNIT_TICKS_PER_CALL, "Profiling the scheduling of one queue during a TMTimer* call in EMT.");
STAM_REG(pVM, &pVM->tm.s.StatScheduleSetFF, STAMTYPE_COUNTER, "/TM/ScheduleSetFF", STAMUNIT_OCCURENCES, "The number of times the timer FF was set instead of doing scheduling.");
STAM_REG(pVM, &pVM->tm.s.StatTimerSetR3, STAMTYPE_PROFILE, "/TM/TimerSetR3", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-3.");
STAM_REG(pVM, &pVM->tm.s.StatTimerSetRZ, STAMTYPE_PROFILE, "/TM/TimerSetRZ", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-0 / RC.");
STAM_REG(pVM, &pVM->tm.s.StatTimerStopR3, STAMTYPE_PROFILE, "/TM/TimerStopR3", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerStop calls made in ring-3.");
STAM_REG(pVM, &pVM->tm.s.StatTimerStopRZ, STAMTYPE_PROFILE, "/TM/TimerStopRZ", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerStop calls made in ring-0 / RC.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualGet, STAMTYPE_COUNTER, "/TM/VirtualGet", STAMUNIT_OCCURENCES, "The number of times TMTimerGet was called when the clock was running.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualGetSetFF, STAMTYPE_COUNTER, "/TM/VirtualGetSetFF", STAMUNIT_OCCURENCES, "Times we set the FF when calling TMTimerGet.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualGetSync, STAMTYPE_COUNTER, "/TM/VirtualGetSync", STAMUNIT_OCCURENCES, "The number of times TMTimerGetSync was called when the clock was running.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualGetSyncSetFF, STAMTYPE_COUNTER, "/TM/VirtualGetSyncSetFF", STAMUNIT_OCCURENCES, "Times we set the FF when calling TMTimerGetSync.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualPause, STAMTYPE_COUNTER, "/TM/VirtualPause", STAMUNIT_OCCURENCES, "The number of times TMR3TimerPause was called.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualResume, STAMTYPE_COUNTER, "/TM/VirtualResume", STAMUNIT_OCCURENCES, "The number of times TMR3TimerResume was called.");
STAM_REG(pVM, &pVM->tm.s.StatTimerCallbackSetFF, STAMTYPE_COUNTER, "/TM/CallbackSetFF", STAMUNIT_OCCURENCES, "The number of times the timer callback set FF.");
STAM_REG(pVM, &pVM->tm.s.StatTSCCatchupLE010, STAMTYPE_COUNTER, "/TM/TSC/Intercept/CatchupLE010", STAMUNIT_OCCURENCES, "In catch-up mode, 10% or lower.");
STAM_REG(pVM, &pVM->tm.s.StatTSCCatchupLE025, STAMTYPE_COUNTER, "/TM/TSC/Intercept/CatchupLE025", STAMUNIT_OCCURENCES, "In catch-up mode, 25%-11%.");
STAM_REG(pVM, &pVM->tm.s.StatTSCCatchupLE100, STAMTYPE_COUNTER, "/TM/TSC/Intercept/CatchupLE100", STAMUNIT_OCCURENCES, "In catch-up mode, 100%-26%.");
STAM_REG(pVM, &pVM->tm.s.StatTSCCatchupOther, STAMTYPE_COUNTER, "/TM/TSC/Intercept/CatchupOther", STAMUNIT_OCCURENCES, "In catch-up mode, > 100%.");
STAM_REG(pVM, &pVM->tm.s.StatTSCNotFixed, STAMTYPE_COUNTER, "/TM/TSC/Intercept/NotFixed", STAMUNIT_OCCURENCES, "TSC is not fixed, it may run at variable speed.");
STAM_REG(pVM, &pVM->tm.s.StatTSCNotTicking, STAMTYPE_COUNTER, "/TM/TSC/Intercept/NotTicking", STAMUNIT_OCCURENCES, "TSC is not ticking.");
STAM_REG(pVM, &pVM->tm.s.StatTSCSyncNotTicking, STAMTYPE_COUNTER, "/TM/TSC/Intercept/SyncNotTicking", STAMUNIT_OCCURENCES, "VirtualSync isn't ticking.");
STAM_REG(pVM, &pVM->tm.s.StatTSCWarp, STAMTYPE_COUNTER, "/TM/TSC/Intercept/Warp", STAMUNIT_OCCURENCES, "Warpdrive is active.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncCatchup, STAMTYPE_PROFILE_ADV, "/TM/VirtualSync/CatchUp", STAMUNIT_TICKS_PER_OCCURENCE, "Counting and measuring the times spent catching up.");
STAM_REG(pVM, (void *)&pVM->tm.s.fVirtualSyncCatchUp, STAMTYPE_U8, "/TM/VirtualSync/CatchUpActive", STAMUNIT_NONE, "Catch-Up active indicator.");
STAM_REG(pVM, (void *)&pVM->tm.s.u32VirtualSyncCatchUpPercentage, STAMTYPE_U32, "/TM/VirtualSync/CatchUpPercentage", STAMUNIT_PCT, "The catch-up percentage. (+100/100 to get clock multiplier)");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncGiveUp, STAMTYPE_COUNTER, "/TM/VirtualSync/GiveUp", STAMUNIT_OCCURENCES, "Times the catch-up was abandoned.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncGiveUpBeforeStarting, STAMTYPE_COUNTER, "/TM/VirtualSync/GiveUpBeforeStarting",STAMUNIT_OCCURENCES, "Times the catch-up was abandoned before even starting. (Typically debugging++.)");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncRun, STAMTYPE_COUNTER, "/TM/VirtualSync/Run", STAMUNIT_OCCURENCES, "Times the virtual sync timer queue was considered.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncRunRestart, STAMTYPE_COUNTER, "/TM/VirtualSync/Run/Restarts", STAMUNIT_OCCURENCES, "Times the clock was restarted after a run.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncRunStop, STAMTYPE_COUNTER, "/TM/VirtualSync/Run/Stop", STAMUNIT_OCCURENCES, "Times the clock was stopped when calculating the current time before examining the timers.");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncRunStoppedAlready, STAMTYPE_COUNTER, "/TM/VirtualSync/Run/StoppedAlready", STAMUNIT_OCCURENCES, "Times the clock was already stopped elsewhere (TMVirtualSyncGet).");
STAM_REG(pVM, &pVM->tm.s.StatVirtualSyncRunSlack, STAMTYPE_PROFILE, "/TM/VirtualSync/Run/Slack", STAMUNIT_NS_PER_OCCURENCE, "The scheduling slack. (Catch-up handed out when running timers.)");
STAMR3RegisterF(pVM, &pVM->tm.s.aVirtualSyncCatchUpPeriods[i].u32Percentage, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_PCT, "The catch-up percentage.", "/TM/VirtualSync/Periods/%u", i);
STAMR3RegisterF(pVM, &pVM->tm.s.aStatVirtualSyncCatchupAdjust[i], STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Times adjusted to this period.", "/TM/VirtualSync/Periods/%u/Adjust", i);
STAMR3RegisterF(pVM, &pVM->tm.s.aStatVirtualSyncCatchupInitial[i], STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Times started in this period.", "/TM/VirtualSync/Periods/%u/Initial", i);
STAMR3RegisterF(pVM, &pVM->tm.s.aVirtualSyncCatchUpPeriods[i].u64Start, STAMTYPE_U64, STAMVISIBILITY_ALWAYS, STAMUNIT_NS, "Start of this period (lag).", "/TM/VirtualSync/Periods/%u/Start", i);
DBGFR3InfoRegisterInternalEx(pVM, "timers", "Dumps all timers. No arguments.", tmR3TimerInfo, DBGFINFO_FLAGS_RUN_ON_EMT);
DBGFR3InfoRegisterInternalEx(pVM, "activetimers", "Dumps active all timers. No arguments.", tmR3TimerInfoActive, DBGFINFO_FLAGS_RUN_ON_EMT);
DBGFR3InfoRegisterInternalEx(pVM, "clocks", "Display the time of the various clocks.", tmR3InfoClocks, DBGFINFO_FLAGS_RUN_ON_EMT);
return VINF_SUCCESS;
return VINF_SUCCESS;
if (ASMHasCpuId())
if ( pGip
AssertReleaseMsgFailed(("iCpu=%d - the ApicId is too high. send VBox.log and hardware specs!\n", iCpu));
if ( pGip
return u64Hz;
RTTimeNanoTS();
unsigned cMillies;
unsigned iHigh = 0;
unsigned iLow = 0;
iLow = i;
iHigh = i;
return u64Hz;
int rc;
rc = PDMR3LdrGetSymbolRCLazy(pVM, NULL, "tmVirtualNanoTSBad", &pVM->tm.s.VirtualGetRawDataRC.pfnBad);
rc = PDMR3LdrGetSymbolRCLazy(pVM, NULL, "tmVirtualNanoTSRediscover", &pVM->tm.s.VirtualGetRawDataRC.pfnRediscover);
rc = PDMR3LdrGetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSBad", &pVM->tm.s.VirtualGetRawDataR0.pfnBad);
rc = PDMR3LdrGetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSRediscover", &pVM->tm.s.VirtualGetRawDataR0.pfnRediscover);
return VINF_SUCCESS;
int rc;
rc = PDMR3LdrGetSymbolRCLazy(pVM, NULL, "tmVirtualNanoTSBad", &pVM->tm.s.VirtualGetRawDataRC.pfnBad);
rc = PDMR3LdrGetSymbolRCLazy(pVM, NULL, "tmVirtualNanoTSRediscover", &pVM->tm.s.VirtualGetRawDataRC.pfnRediscover);
return VINF_SUCCESS;
LogRel(("TM: Aborting catch-up attempt on reset with a %RU64 ns lag on reset; new total: %RU64 ns\n", offNew - offOld, offNew));
for (int i = 0; i < TMCLOCK_MAX; i++)
#ifdef VBOX_STRICT
return VERR_SYMBOL_NOT_FOUND;
return VINF_SUCCESS;
#ifdef VBOX_STRICT
#ifdef VBOX_STRICT
return rc;
return VERR_SSM_VIRTUAL_CLOCK_HZ;
return rc;
return rc;
LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%RU64) fTSCVirtualized=%RTbool fTSCUseRealTSC=%RTbool (state load)\n",
pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.fTSCVirtualized, pVM->tm.s.fTSCUseRealTSC));
return VINF_SUCCESS;
if (!pTimer)
return rc;
#ifdef VBOX_STRICT
return VINF_SUCCESS;
VMMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer)
Log(("TM: Created device timer %p clock %d callback %p '%s'\n", (*ppTimer), enmClock, pfnCallback, pszDesc));
return rc;
VMMR3DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer)
Log(("TM: Created device timer %p clock %d callback %p '%s'\n", (*ppTimer), enmClock, pfnCallback, pszDesc));
return rc;
VMMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer)
Log(("TM: Created internal timer %p clock %d callback %p '%s'\n", pTimer, enmClock, pfnCallback, pszDesc));
return rc;
VMMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc)
Log(("TM: Created external timer %p clock %d callback %p '%s'\n", pTimer, enmClock, pfnCallback, pszDesc));
return pTimer;
return NULL;
if (!pDevIns)
return VERR_INVALID_PARAMETER;
while (pCur)
return VINF_SUCCESS;
if (!pDrvIns)
return VERR_INVALID_PARAMETER;
while (pCur)
return VINF_SUCCESS;
switch (enmClock)
return ~(uint64_t)0;
#ifdef VBOX_STRICT
if (!pNext)
Log2(("tmR3TimerQueueRun: pTimer=%p:{.enmState=%s, .enmClock=%d, .enmType=%d, u64Expire=%llx (now=%llx) .pszDesc=%s}\n",
pTimer, tmTimerState(pTimer->enmState), pTimer->enmClock, pTimer->enmType, pTimer->u64Expire, u64Now, pTimer->pszDesc));
bool fRc;
if (fRc)
if (pPrev)
if (pNext)
case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->u.Internal.pvUser); break;
uint64_t u64Sub = ASMMultU64ByU32DivByU32(u64Delta, pVM->tm.s.u32VirtualSyncCatchUpPercentage, 100);
Log4(("TM: %RU64/%RU64: sub %RU64 (run)\n", u64VirtualNow - off, off - pVM->tm.s.offVirtualSyncGivenUp, u64Sub));
Log4(("TM: %RU64/%RU64: exp tmr (run)\n", u64Now, u64VirtualNow - u64Now - pVM->tm.s.offVirtualSyncGivenUp));
#ifdef VBOX_STRICT
Log2(("tmR3TimerQueueRun: pTimer=%p:{.enmState=%s, .enmClock=%d, .enmType=%d, u64Expire=%llx (now=%llx) .pszDesc=%s}\n",
pTimer, tmTimerState(pTimer->enmState), pTimer->enmClock, pTimer->enmType, pTimer->u64Expire, u64Now, pTimer->pszDesc));
bool fRc;
if (fRc)
if (pPrev)
if (pNext)
#ifdef VBOX_STRICT
AssertMsg(pTimer->u64Expire >= u64Prev, ("%RU64 < %RU64 %s\n", pTimer->u64Expire, u64Prev, pTimer->pszDesc));
case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->u.Internal.pvUser); break;
AssertMsg(pVM->tm.s.u64VirtualSync >= u64Now, ("%RU64 < %RU64\n", pVM->tm.s.u64VirtualSync, u64Now));
if (offSlack)
p->cPeriods++;
u64Elapsed = 0;
if (pVM->tm.s.u32VirtualSyncCatchUpPercentage < pVM->tm.s.aVirtualSyncCatchUpPeriods[i].u32Percentage)
ASMAtomicXchgU32(&pVM->tm.s.u32VirtualSyncCatchUpPercentage, pVM->tm.s.aVirtualSyncCatchUpPeriods[i].u32Percentage);
Log4(("TM: %RU64/%RU64: adj %u%%\n", u64VirtualNow2 - offNew, offLag, pVM->tm.s.u32VirtualSyncCatchUpPercentage));
Log4(("TM: %RU64/%RU64: give up %u%%\n", u64VirtualNow2 - offNew, offLag, pVM->tm.s.u32VirtualSyncCatchUpPercentage));
LogRel(("TM: Giving up catch-up attempt at a %RU64 ns lag; new total: %RU64 ns\n", offLag, offNew));
ASMAtomicXchgU32(&pVM->tm.s.u32VirtualSyncCatchUpPercentage, pVM->tm.s.aVirtualSyncCatchUpPeriods[i].u32Percentage);
Log4(("TM: %RU64/%RU64: catch-up %u%%\n", u64VirtualNow2 - offNew, offLag, pVM->tm.s.u32VirtualSyncCatchUpPercentage));
LogRel(("TM: Not bothering to attempt catching up a %RU64 ns lag; new total: %RU64\n", offLag, offNew));
LogFlow(("TMR3TimerSave: pTimer=%p:{enmState=%s, .pszDesc={%s}} pSSM=%p\n", pTimer, tmTimerState(pTimer->enmState), pTimer->pszDesc, pSSM));
case TMTIMERSTATE_STOPPED:
if (!RTThreadYield())
case TMTIMERSTATE_ACTIVE:
case TMTIMERSTATE_EXPIRED:
case TMTIMERSTATE_FREE:
AssertMsgFailed(("Invalid timer state %d %s (%s)\n", pTimer->enmState, tmTimerState(pTimer->enmState), pTimer->pszDesc));
LogFlow(("TMR3TimerLoad: pTimer=%p:{enmState=%s, .pszDesc={%s}} pSSM=%p\n", pTimer, tmTimerState(pTimer->enmState), pTimer->pszDesc, pSSM));
return rc;
return rc;
return rc;
return pTime;
pVM,
pVM,