VirtualBox

Ignore:
Timestamp:
Sep 17, 2014 5:35:42 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96159
Message:

HostDrivers/SupDrv: Function for querying invariant TSC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r52725 r52780  
    159159static DECLCALLBACK(void)   supdrvGipAsyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick);
    160160static DECLCALLBACK(void)   supdrvGipMpEvent(RTMPEVENT enmEvent, RTCPUID idCpu, void *pvUser);
     161static bool                 supdrvIsInvariantTsc(void);
    161162static void                 supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys,
    162163                                          uint64_t u64NanoTS, unsigned uUpdateHz, unsigned cCpus);
     
    60386039
    60396040/**
     6041 * Returns whether the host CPU sports an invariant TSC or not.
     6042 *
     6043 * @returns true if invariant TSC is supported, false otherwise.
     6044 */
     6045static bool supdrvIsInvariantTsc(void)
     6046{
     6047    static bool s_fQueried        = false;
     6048    static bool s_fIsInvariantTsc = false;
     6049    if (!s_fQueried)
     6050    {
     6051        uint32_t uEax, uEbx, uEcx, uEdx;
     6052        ASMCpuId(0x80000000, &uEax, &uEbx, &uEcx, &uEdx);
     6053        if (uEax >= 0x80000007)
     6054        {
     6055            ASMCpuId(0x80000007, &uEax, &uEbx, &uEcx, &uEdx);
     6056            if (uEdx & X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR)
     6057                s_fIsInvariantTsc = true;
     6058        }
     6059        s_fQueried = true;
     6060    }
     6061
     6062    return s_fIsInvariantTsc;
     6063}
     6064
     6065
     6066/**
    60406067 * Callback used by supdrvMeasureTscDeltas() to read the TSC on two CPUs and
    60416068 * compute the delta between them.
     
    60586085 *     minimum as an arbibtrary acceptable threshold. Therefore, it is still
    60596086 *     possible to get negative deltas where there are none when the worker is
    6060  *     earlier.
     6087 *     earlier. As long as these occasional negative deltas are lower than the
     6088 *     time it takes to exit guest-context and the OS to reschedule EMT on a
     6089 *     different CPU we won't expose a TSC that jumped backwards.
    60616090 */
    60626091static DECLCALLBACK(void) supdrvMeasureTscDeltaCallback(RTCPUID idCpu, void *pvUser1, void *pvUser2)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette