VirtualBox

Changeset 57059 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jul 23, 2015 1:18:14 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101780
Message:

SUP: Threshold adjustment in SUPIsTscFreqCompatibleEx.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r57006 r57059  
    555555 * Worker for SUPIsTscFreqCompatible().
    556556 *
    557  * @param uBaseCpuHz        The reference CPU frequency of the system.
    558  * @param uCpuHz            The CPU frequency to compare with the base.
     557 * @param   uBaseCpuHz      The reference CPU frequency of the system.
     558 * @param   uCpuHz          The CPU frequency to compare with the base.
     559 * @param   fRelax          Whether to use a more relaxed threshold (like
     560 *                          for when running in a virtualized environment).
    559561 *
    560562 * @returns true if it's compatible, false otherwise.
    561563 * @remarks Don't use directly, use SUPIsTscFreqCompatible() instead. This is
    562  *          to be used by tstGIP-2 (or the like).
    563  */
    564 DECLINLINE(bool) SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz)
     564 *          to be used by tstGIP-2 or the like.
     565 */
     566DECLINLINE(bool) SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz, bool fRelax)
    565567{
    566568    if (uBaseCpuHz != uCpuHz)
     
    568570        /* Arbitrary tolerance threshold, tweak later if required, perhaps
    569571           more tolerance on lower frequencies and less tolerance on higher. */
    570         uint64_t uLo = (uBaseCpuHz << 11) / 2049;
    571         uint64_t uHi = uBaseCpuHz + (uBaseCpuHz - uLo);
     572        uint16_t uThr = !fRelax ? 666 /* 0.15% */ : 125 /* 0.8% */;
     573        uint64_t uLo  = uBaseCpuHz / uThr;
     574        uint64_t uHi  = uBaseCpuHz + (uBaseCpuHz - uLo);
    572575        if (   uCpuHz < uLo
    573576            || uCpuHz > uHi)
     
    583586 *
    584587 * @param   u64CpuHz        The TSC frequency to check.
     588 * @param   fRelax          Whether to use a more relaxed threshold (like
     589 *                          for when running in a virtualized environment).
    585590 *
    586591 * @returns true if it's compatible, false otherwise.
    587592 */
    588 DECLINLINE(bool) SUPIsTscFreqCompatible(uint64_t u64CpuHz)
     593DECLINLINE(bool) SUPIsTscFreqCompatible(uint64_t u64CpuHz, bool fRelax)
    589594{
    590595    PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
    591596    if (   pGip
    592597        && pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
    593         return SUPIsTscFreqCompatibleEx(pGip->u64CpuHz, u64CpuHz);
     598        return SUPIsTscFreqCompatibleEx(pGip->u64CpuHz, u64CpuHz, fRelax);
    594599    return false;
    595600}
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