Changeset 57218 in vbox for trunk/src/VBox/HostDrivers/Support/testcase
- Timestamp:
- Aug 6, 2015 2:53:27 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 101971
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
r57060 r57218 41 41 #include <iprt/x86.h> 42 42 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 66 43 int main(int argc, char **argv) 67 44 { … … 79 56 { "--reference", 'r', RTGETOPT_REQ_UINT64 }, /* reference value of CpuHz, display the 80 57 * 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) */ 81 60 }; 82 61 … … 85 64 bool fSpin = false; 86 65 bool fCompat = true; 66 bool fTestMode = true; 87 67 int ch; 88 uint64_t uCpuHzRef = 0;68 uint64_t uCpuHzRef = UINT64_MAX; 89 69 uint64_t uCpuHzOverallDeviation = 0; 90 70 uint32_t cCpuHzNotCompat = 0; … … 118 98 break; 119 99 100 case 't': 101 fTestMode = false; 102 break; 103 120 104 default: 121 105 return RTGetOptPrintError(ch, &ValueUnion); … … 132 116 if (g_pSUPGlobalInfoPage) 133 117 { 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 134 126 RTPrintf("tstGIP-2: cCpus=%d u32UpdateHz=%RU32 u32UpdateIntervalNS=%RU32 u64NanoTSLastUpdateHz=%RX64 u64CpuHz=%RU64 uCpuHzRef=%RU64 u32Mode=%d (%s) u32Version=%#x\n", 135 127 g_pSUPGlobalInfoPage->cCpus, … … 147 139 uCpuHzRef ? " CpuHz deviation Compat " : ""); 148 140 static SUPGIPCPU s_aaCPUs[2][256]; 141 149 142 for (uint32_t i = 0; i < cIterations; i++) 150 143 { … … 170 163 { 171 164 /* Wait until the history validation code takes effect. */ 165 bool fCurHzCompat = true; 172 166 if (pCpu->u32TransactionId > 23 + (8 * 2) + 1) 173 167 { … … 176 170 uCpuHzOverallDeviation += uCpuHzDeviation; 177 171 cCpuHzOverallDevCnt++; 172 fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /* fRelax */); 178 173 } 179 bool fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /* fRelax */);180 174 uint32_t uPct = (uint32_t)(uCpuHzDeviation * 100000 / uCpuHzRef + 5); 181 175 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%10RI64%3d.%02d%% %RTbool ", … … 271 265 RTPrintf("tstGIP-2: CpuHz compatibility: %RTbool (incompatible %u of %u times w/ %RU64 Hz)\n", fCompat, 272 266 cCpuHzNotCompat, cIterations * g_pSUPGlobalInfoPage->cCpus, uCpuHzRef); 267 268 if ( !fCompat 269 && g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_INVARIANT_TSC) 270 rc = -1; 273 271 } 272 273 /* Disable GIP test mode. */ 274 if (fTestMode) 275 SUPR3GipSetFlags(0, ~SUPGIP_FLAGS_TESTING_ENABLE); 274 276 } 275 277 else
Note:
See TracChangeset
for help on using the changeset viewer.