VirtualBox

Changeset 56952 in vbox


Ignore:
Timestamp:
Jul 16, 2015 12:57:28 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101661
Message:

sup.h: enabled compiling of SUPIsTscFreqCompatible().

File:
1 edited

Legend:

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

    r56817 r56952  
    552552
    553553
    554 #if 0 /* Not used anywhere.  Unsure where this would be useful. */
     554/**
     555 * Worker for SUPIsTscFreqCompatible().
     556 *
     557 * @param uBaseCpuHz        The reference CPU frequency of the system.
     558 * @param uCpuHz            The CPU frequency to compare with the base.
     559 *
     560 * @returns true if it's compatible, false otherwise.
     561 * @remarks Don't use directly, use SUPIsTscFreqCompatible() instead. This is
     562 *          to be used by tstGIP-2 (or the like).
     563 */
     564DECLINLINE(bool) SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz)
     565{
     566    if (uBaseCpuHz != uCpuHz)
     567    {
     568        /* Arbitrary tolerance threshold, tweak later if required, perhaps
     569           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        if (   uCpuHz < uLo
     573            || uCpuHz > uHi)
     574            return false;
     575    }
     576    return true;
     577}
     578
     579
    555580/**
    556581 * Checks if the provided TSC frequency is close enough to the computed TSC
    557582 * frequency of the host.
     583 *
     584 * @param   u64CpuHz        The TSC frequency to check.
    558585 *
    559586 * @returns true if it's compatible, false otherwise.
     
    564591    if (   pGip
    565592        && pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
    566     {
    567         if (pGip->u64CpuHz != u64CpuHz)
    568         {
    569             /* Arbitrary tolerance threshold, tweak later if required, perhaps
    570                more tolerance on lower frequencies and less tolerance on higher. */
    571             uint64_t uLo = (pGip->u64CpuHz << 10) / 1025;
    572             uint64_t uHi = pGip->u64CpuHz + (pGip->u64CpuHz - uLo);
    573             if (   u64CpuHz < uLo
    574                 || u64CpuHz > uHi)
    575                 return false;
    576         }
    577         return true;
    578     }
     593        return SUPIsTscFreqCompatibleEx(pGip->u64CpuHz, u64CpuHz);
    579594    return false;
    580595}
    581 #endif
     596
    582597
    583598#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
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