Changeset 69582 in vbox
- Timestamp:
- Nov 4, 2017 8:41:14 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 118932
- Location:
- trunk/src/VBox/VMM/tools
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/tools/Makefile.kmk
r69111 r69582 60 60 VBoxCpuReport_SOURCES = \ 61 61 VBoxCpuReport.cpp \ 62 MsrSup.cpp \ 62 63 ../VMMR3/CPUMR3CpuId.cpp 64 VBoxCpuReport_SOURCES.linux = MsrLinux.cpp 65 VBoxCpuReport_DEFS.linux = VBCR_HAVE_PLATFORM_MSR_PROBER 63 66 VBoxCpuReport_LIBS = \ 64 67 $(PATH_STAGE_LIB)/SUPR3Static$(VBOX_SUFF_LIB) \ -
trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp
r69221 r69582 40 40 #include <VBox/sup.h> 41 41 42 #include "VBoxCpuReport.h" 42 43 43 44 /********************************************************************************************************************************* … … 77 78 static uint64_t g_uMsrIntelP6FsbFrequency = UINT64_MAX; 78 79 79 80 static void vbCpuRepDebug(const char *pszMsg, ...) 80 /** MSR prober routines. */ 81 static VBMSRFNS g_MsrAcc; 82 83 84 void vbCpuRepDebug(const char *pszMsg, ...) 81 85 { 82 86 va_list va; … … 102 106 103 107 104 staticvoid vbCpuRepPrintf(const char *pszMsg, ...)108 void vbCpuRepPrintf(const char *pszMsg, ...) 105 109 { 106 110 va_list va; … … 219 223 { 220 224 bool fGp; 221 int rc = SUPR3MsrProberWrite(uMsr, NIL_RTCPUID, uValue, &fGp);225 int rc = g_MsrAcc.msrWrite(uMsr, NIL_RTCPUID, uValue, &fGp); 222 226 AssertRC(rc); 223 227 return RT_SUCCESS(rc) && !fGp; … … 230 234 *puValue = 0; 231 235 bool fGp; 232 int rc = SUPR3MsrProberRead(uMsr, NIL_RTCPUID, puValue, &fGp);236 int rc = g_MsrAcc.msrRead(uMsr, NIL_RTCPUID, puValue, &fGp); 233 237 AssertRC(rc); 234 238 return RT_SUCCESS(rc) && !fGp; … … 240 244 { 241 245 SUPMSRPROBERMODIFYRESULT Result; 242 int rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, UINT64_MAX, 0, &Result);246 int rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, UINT64_MAX, 0, &Result); 243 247 return RT_SUCCESS(rc) 244 248 && !Result.fBeforeGp … … 253 257 { 254 258 SUPMSRPROBERMODIFYRESULT Result; 255 int rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, 0, 0, &Result);259 int rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, 0, 0, &Result); 256 260 return RT_SUCCESS(rc) 257 261 && !Result.fBeforeGp … … 281 285 /* Set it. */ 282 286 SUPMSRPROBERMODIFYRESULT ResultSet; 283 int rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);287 int rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet); 284 288 if (RT_FAILURE(rc)) 285 return RTMsgErrorRc(rc, " SUPR3MsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);289 return RTMsgErrorRc(rc, "msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc); 286 290 287 291 /* Clear it. */ 288 292 SUPMSRPROBERMODIFYRESULT ResultClear; 289 rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);293 rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear); 290 294 if (RT_FAILURE(rc)) 291 return RTMsgErrorRc(rc, " SUPR3MsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);295 return RTMsgErrorRc(rc, "msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc); 292 296 293 297 if (ResultSet.fModifyGp || ResultClear.fModifyGp) … … 324 328 /* Set it. */ 325 329 SUPMSRPROBERMODIFYRESULT ResultSet; 326 int rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);330 int rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet); 327 331 if (RT_FAILURE(rc)) 328 return RTMsgErrorRc(-2, " SUPR3MsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);332 return RTMsgErrorRc(-2, "msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc); 329 333 330 334 /* Clear it. */ 331 335 SUPMSRPROBERMODIFYRESULT ResultClear; 332 rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);336 rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear); 333 337 if (RT_FAILURE(rc)) 334 return RTMsgErrorRc(-2, " SUPR3MsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);338 return RTMsgErrorRc(-2, "msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc); 335 339 336 340 if (ResultSet.fModifyGp || ResultClear.fModifyGp) … … 363 367 { 364 368 SUPMSRPROBERMODIFYRESULT Result; 365 int rc = SUPR3MsrProberModify(uMsr, NIL_RTCPUID, fAndMask, fOrMask, &Result);369 int rc = g_MsrAcc.msrModify(uMsr, NIL_RTCPUID, fAndMask, fOrMask, &Result); 366 370 if (RT_FAILURE(rc)) 367 371 { 368 RTMsgError(" SUPR3MsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, fAndMask, fOrMask, rc);372 RTMsgError("g_MsrAcc.msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, fAndMask, fOrMask, rc); 369 373 return false; 370 374 } … … 531 535 uint64_t uValue = 0; 532 536 bool fGp = true; 533 int rc = SUPR3MsrProberRead(uMsr, NIL_RTCPUID, &uValue, &fGp);537 int rc = g_MsrAcc.msrRead(uMsr, NIL_RTCPUID, &uValue, &fGp); 534 538 if (RT_FAILURE(rc)) 535 539 { 536 540 RTMemFree(*ppaMsrs); 537 541 *ppaMsrs = NULL; 538 return RTMsgErrorRc(rc, " SUPR3MsrProberRead failed on %#x: %Rrc\n", uMsr, rc);542 return RTMsgErrorRc(rc, "msrRead failed on %#x: %Rrc\n", uMsr, rc); 539 543 } 540 544 … … 562 566 #endif 563 567 fGp = true; 564 rc = SUPR3MsrProberWrite(uMsr, NIL_RTCPUID, 0, &fGp);568 rc = g_MsrAcc.msrWrite(uMsr, NIL_RTCPUID, 0, &fGp); 565 569 if (RT_FAILURE(rc)) 566 570 { 567 571 RTMemFree(*ppaMsrs); 568 572 *ppaMsrs = NULL; 569 return RTMsgErrorRc(rc, " SUPR3MsrProberWrite failed on %#x: %Rrc\n", uMsr, rc);573 return RTMsgErrorRc(rc, "msrWrite failed on %#x: %Rrc\n", uMsr, rc); 570 574 } 571 575 uValue = 0; … … 4343 4347 4344 4348 /* 4345 * Initialize the support library and check if we can read MSRs.4349 * First try the the support library (also checks if we can really read MSRs). 4346 4350 */ 4347 int rc = S UPR3Init(NULL);4351 int rc = SupDrvMsrProberInit(&g_MsrAcc); 4348 4352 if (RT_FAILURE(rc)) 4349 4353 { 4350 vbCpuRepDebug("warning: Unable to initialize the support library (%Rrc), skipping MSR detection.\n", rc); 4351 return VINF_SUCCESS; 4352 } 4354 #ifdef VBCR_HAVE_PLATFORM_MSR_PROBER 4355 /* Next try a platform-specific interface. */ 4356 rc = PlatformMsrProberInit(&g_MsrAcc); 4357 #endif 4358 if (RT_FAILURE(rc)) 4359 { 4360 vbCpuRepDebug("warning: Unable to initialize any MSR access interface (%Rrc), skipping MSR detection.\n", rc); 4361 return VINF_SUCCESS; 4362 } 4363 } 4364 4353 4365 uint64_t uValue; 4354 4366 bool fGp; 4355 rc = SUPR3MsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp);4367 rc = g_MsrAcc.msrRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp); 4356 4368 if (RT_FAILURE(rc)) 4357 4369 { … … 4360 4372 } 4361 4373 vbCpuRepDebug("MSR_IA32_TSC: %#llx fGp=%RTbool\n", uValue, fGp); 4362 rc = SUPR3MsrProberRead(0xdeadface, NIL_RTCPUID, &uValue, &fGp);4374 rc = g_MsrAcc.msrRead(0xdeadface, NIL_RTCPUID, &uValue, &fGp); 4363 4375 vbCpuRepDebug("0xdeadface: %#llx fGp=%RTbool rc=%Rrc\n", uValue, fGp, rc); 4364 4376 … … 4397 4409 uint32_t cMsrs; 4398 4410 rc = findMsrs(&paMsrs, &cMsrs, fMsrMask); 4399 if ( RT_FAILURE(rc))4411 if (!RT_FAILURE(rc)) 4400 4412 return rc; 4401 4413 … … 4418 4430 paMsrs = NULL; 4419 4431 } 4432 g_MsrAcc.msrProberTerm(); 4433 RT_ZERO(g_MsrAcc); 4420 4434 return rc; 4421 4435 }
Note:
See TracChangeset
for help on using the changeset viewer.