Changeset 49141 in vbox for trunk/src/VBox/VMM/VMMR3/VMMTests.cpp
- Timestamp:
- Oct 16, 2013 2:07:14 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89995
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VMMTests.cpp
r47843 r49141 618 618 } 619 619 620 621 #ifdef VBOX_WITH_RAW_MODE 622 623 /** 624 * Used by VMMDoBruteForceMsrs to dump the CPUID info of the host CPU as a 625 * prefix to the MSR report. 626 */ 627 static DECLCALLBACK(void) vmmDoPrintfVToStream(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list va) 628 { 629 PRTSTREAM pOutStrm = ((PRTSTREAM *)pHlp)[-1]; 630 RTStrmPrintfV(pOutStrm, pszFormat, va); 631 } 632 633 /** 634 * Used by VMMDoBruteForceMsrs to dump the CPUID info of the host CPU as a 635 * prefix to the MSR report. 636 */ 637 static DECLCALLBACK(void) vmmDoPrintfToStream(PCDBGFINFOHLP pHlp, const char *pszFormat, ...) 638 { 639 va_list va; 640 va_start(va, pszFormat); 641 vmmDoPrintfVToStream(pHlp, pszFormat, va); 642 va_end(va); 643 } 644 645 #endif 646 647 648 /** 649 * Uses raw-mode to query all possible MSRs on the real hardware. 650 * 651 * This generates a msr-report.txt file (appending, no overwriting) as well as 652 * writing the values and process to stdout. 653 * 654 * @returns VBox status code. 655 * @param pVM The VM handle. 656 */ 657 VMMDECL(int) VMMDoBruteForceMsrs(PVM pVM) 658 { 659 #ifdef VBOX_WITH_RAW_MODE 660 RTRCPTR RCPtrEP; 661 int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMRCTestReadMsrs", &RCPtrEP); 662 if (RT_SUCCESS(rc)) 663 { 664 RTPrintf("VMM: VMMRCTestReadMsrs=%RRv\n", RCPtrEP); 665 PRTSTREAM pOutStrm; 666 rc = RTStrmOpen("msr-report.txt", "a", &pOutStrm); 667 if (RT_SUCCESS(rc)) 668 { 669 /* Header */ 670 struct 671 { 672 PRTSTREAM pOutStrm; 673 DBGFINFOHLP Hlp; 674 } MyHlp = { pOutStrm, { vmmDoPrintfToStream, vmmDoPrintfVToStream } }; 675 DBGFR3Info(pVM->pUVM, "cpuid", "verbose", &MyHlp.Hlp); 676 RTStrmPrintf(pOutStrm, "\n"); 677 678 /* 679 * The MSRs. 680 */ 681 uint32_t const cMsrsPerCall = 1024; 682 uint32_t cbResults = cMsrsPerCall * sizeof(VMMTESTMSRENTRY); 683 PVMMTESTMSRENTRY paResults; 684 rc = MMHyperAlloc(pVM, cbResults, 0, MM_TAG_VMM, (void **)&paResults); 685 if (RT_SUCCESS(rc)) 686 { 687 RTRCPTR RCPtrResults = MMHyperR3ToRC(pVM, paResults); 688 uint32_t cMsrsFound = 0; 689 uint32_t uLastMsr = 0; 690 uint64_t uNsTsStart = RTTimeNanoTS(); 691 692 for (uint32_t uCurMsr = 0; ; uCurMsr += cMsrsPerCall) 693 { 694 if ( uCurMsr - uLastMsr > _64K 695 && (uCurMsr & (_4M - 1)) == 0) 696 { 697 if (uCurMsr - uLastMsr < 16U*_1M) 698 RTStrmFlush(pOutStrm); 699 RTPrintf("... %#010x [%u ns/msr] ...\n", uCurMsr, (RTTimeNanoTS() - uNsTsStart) / uCurMsr); 700 } 701 702 RT_BZERO(paResults, cbResults); 703 rc = VMMR3CallRC(pVM, RCPtrEP, 4, pVM->pVMRC, uCurMsr, cMsrsPerCall, RCPtrResults); 704 if (RT_FAILURE(rc)) 705 { 706 RTPrintf("VMM: VMMR3CallRC failed rc=%Rrc, uCurMsr=%#x\n", rc, uCurMsr); 707 break; 708 } 709 710 for (uint32_t i = 0; i < cMsrsPerCall; i++) 711 if (paResults[i].uMsr != UINT64_MAX) 712 { 713 RTStrmPrintf(pOutStrm, "%#010x = %#llx\n", paResults[i].uMsr, paResults[i].uValue); 714 RTPrintf("%#010x = %#llx\n", paResults[i].uMsr, paResults[i].uValue); 715 cMsrsFound++; 716 uLastMsr = paResults[i].uMsr; 717 } 718 if (uCurMsr + cMsrsPerCall < uCurMsr) 719 break; 720 } 721 722 RTStrmPrintf(pOutStrm, "Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 723 RTPrintf("Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 724 MMHyperFree(pVM, paResults); 725 } 726 RTStrmClose(pOutStrm); 727 } 728 } 729 else 730 AssertMsgFailed(("Failed to resolved VMMRC.rc::VMMRCEntry(), rc=%Rrc\n", rc)); 731 return rc; 732 #else 733 return VERR_NOT_SUPPORTED; 734 #endif 735 } 736
Note:
See TracChangeset
for help on using the changeset viewer.