VirtualBox

Changeset 57071 in vbox


Ignore:
Timestamp:
Jul 24, 2015 2:13:40 PM (9 years ago)
Author:
vboxsync
Message:

sup.h: added SUPIsHostVirtualized and some parameter nits to SUPIsTscFreqCompatible.

File:
1 edited

Legend:

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

    r57059 r57071  
    3535#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    3636# include <iprt/asm-amd64-x86.h>
     37# include <iprt/x86.h>
    3738#endif
    3839
     
    585586 * frequency of the host.
    586587 *
    587  * @param   u64CpuHz        The TSC frequency to check.
     588 * @param   uCpuHz          The TSC frequency to check.
     589 * @param   puGipCpuHz      Where to store the GIP TSC frequency used
     590 *                          during the compatibility test (can be NULL).
    588591 * @param   fRelax          Whether to use a more relaxed threshold (like
    589592 *                          for when running in a virtualized environment).
     
    591594 * @returns true if it's compatible, false otherwise.
    592595 */
    593 DECLINLINE(bool) SUPIsTscFreqCompatible(uint64_t u64CpuHz, bool fRelax)
     596DECLINLINE(bool) SUPIsTscFreqCompatible(uint64_t uCpuHz, uint64_t *puGipCpuHz, bool fRelax)
    594597{
    595598    PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
    596599    if (   pGip
    597         && pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
    598         return SUPIsTscFreqCompatibleEx(pGip->u64CpuHz, u64CpuHz, fRelax);
     600        && pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
     601    {
     602        uint64_t uGipCpuHz = pGip->u64CpuHz;
     603        if (puGipCpuHz)
     604            *puGipCpuHz = uGipCpuHz;
     605        return SUPIsTscFreqCompatibleEx(uGipCpuHz, uCpuHz, fRelax);
     606    }
    599607    return false;
    600608}
     
    605613/** @internal */
    606614SUPDECL(uint64_t) SUPReadTscWithDelta(PSUPGLOBALINFOPAGE pGip);
     615
     616/**
     617 * Checks if we are may be running in a virtualized environment.
     618 *
     619 * @returns true if the host system may be virtualized, false otherwise.
     620 */
     621DECLINLINE(bool) SUPIsHostVirtualized(void)
     622{
     623    Assert(ASMHasCpuId());
     624    return RT_BOOL(ASMCpuId_ECX(1) & X86_CPUID_FEATURE_ECX_HVP);
     625}
    607626
    608627/**
Note: See TracChangeset for help on using the changeset viewer.

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