VirtualBox

Ignore:
Timestamp:
Aug 6, 2015 2:53:27 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101971
Message:

SUPDrv, tstGIP-2: Add support for GIP flags and testing TSC frequency compatibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp

    r57060 r57218  
    4141#include <iprt/x86.h>
    4242
    43 
    44 /**
    45  * Checks whether the CPU advertises an invariant TSC or not.
    46  *
    47  * @returns true if invariant, false otherwise.
    48  */
    49 bool tstIsInvariantTsc(void)
    50 {
    51     if (ASMHasCpuId())
    52     {
    53         uint32_t uEax, uEbx, uEcx, uEdx;
    54         ASMCpuId(0x80000000, &uEax, &uEbx, &uEcx, &uEdx);
    55         if (uEax >= 0x80000007)
    56         {
    57             ASMCpuId(0x80000007, &uEax, &uEbx, &uEcx, &uEdx);
    58             if (uEdx & X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR)
    59                 return true;
    60         }
    61     }
    62     return false;
    63 }
    64 
    65 
    6643int main(int argc, char **argv)
    6744{
     
    7956        { "--reference",        'r', RTGETOPT_REQ_UINT64 },  /* reference value of CpuHz, display the
    8057                                                              * CpuHz deviation in a separate column. */
     58        { "--notestmode",       't', RTGETOPT_REQ_NOTHING }  /* don't run GIP in test-mode (atm, test-mode
     59                                                              * implies updating GIP CpuHz even when invariant) */
    8160    };
    8261
     
    8564    bool fSpin = false;
    8665    bool fCompat = true;
     66    bool fTestMode = true;
    8767    int ch;
    88     uint64_t uCpuHzRef = 0;
     68    uint64_t uCpuHzRef = UINT64_MAX;
    8969    uint64_t uCpuHzOverallDeviation = 0;
    9070    uint32_t cCpuHzNotCompat = 0;
     
    11898                break;
    11999
     100            case 't':
     101                fTestMode = false;
     102                break;
     103
    120104            default:
    121105                return RTGetOptPrintError(ch, &ValueUnion);
     
    132116        if (g_pSUPGlobalInfoPage)
    133117        {
     118            /* Pick current CpuHz as the reference if none was specified. */
     119            if (uCpuHzRef == UINT64_MAX)
     120                uCpuHzRef = SUPGetCpuHzFromGip(g_pSUPGlobalInfoPage);
     121
     122            if (   fTestMode
     123                && g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_INVARIANT_TSC)
     124                SUPR3GipSetFlags(SUPGIP_FLAGS_TESTING_ENABLE, UINT32_MAX);
     125
    134126            RTPrintf("tstGIP-2: cCpus=%d  u32UpdateHz=%RU32  u32UpdateIntervalNS=%RU32  u64NanoTSLastUpdateHz=%RX64  u64CpuHz=%RU64  uCpuHzRef=%RU64  u32Mode=%d (%s) u32Version=%#x\n",
    135127                     g_pSUPGlobalInfoPage->cCpus,
     
    147139                     uCpuHzRef ? "  CpuHz deviation  Compat  " : "");
    148140            static SUPGIPCPU s_aaCPUs[2][256];
     141
    149142            for (uint32_t i = 0; i < cIterations; i++)
    150143            {
     
    170163                            {
    171164                                /* Wait until the history validation code takes effect. */
     165                                bool fCurHzCompat = true;
    172166                                if (pCpu->u32TransactionId > 23 + (8 * 2) + 1)
    173167                                {
     
    176170                                    uCpuHzOverallDeviation += uCpuHzDeviation;
    177171                                    cCpuHzOverallDevCnt++;
     172                                    fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /* fRelax */);
    178173                                }
    179                                 bool fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /* fRelax */);
    180174                                uint32_t uPct = (uint32_t)(uCpuHzDeviation * 100000 / uCpuHzRef + 5);
    181175                                RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%10RI64%3d.%02d%%  %RTbool   ",
     
    271265                RTPrintf("tstGIP-2: CpuHz compatibility: %RTbool (incompatible %u of %u times w/ %RU64 Hz)\n", fCompat,
    272266                         cCpuHzNotCompat, cIterations * g_pSUPGlobalInfoPage->cCpus, uCpuHzRef);
     267
     268                if (   !fCompat
     269                    && g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_INVARIANT_TSC)
     270                    rc = -1;
    273271            }
     272
     273            /* Disable GIP test mode. */
     274            if (fTestMode)
     275                SUPR3GipSetFlags(0, ~SUPGIP_FLAGS_TESTING_ENABLE);
    274276        }
    275277        else
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