Changeset 49164 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Oct 17, 2013 1:55:36 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 90035
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VMMTests.cpp
r49148 r49164 52 52 53 53 #ifdef VBOX_WITH_RAW_MODE 54 55 static int vmmR3ReportMsrRange(PVM pVM, uint32_t uMsr, uint64_t cMsrs, PRTSTREAM pReportStrm, uint32_t *pcMsrsFound) 56 { 57 /* 58 * Preps. 59 */ 60 RTRCPTR RCPtrEP; 61 int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMRCTestReadMsrs", &RCPtrEP); 62 AssertMsgRCReturn(rc, ("Failed to resolved VMMRC.rc::VMMRCEntry(), rc=%Rrc\n", rc), rc); 63 64 uint32_t const cMsrsPerCall = 16384; 65 uint32_t cbResults = cMsrsPerCall * sizeof(VMMTESTMSRENTRY); 66 PVMMTESTMSRENTRY paResults; 67 rc = MMHyperAlloc(pVM, cbResults, 0, MM_TAG_VMM, (void **)&paResults); 68 AssertMsgRCReturn(rc, ("Error allocating %#x bytes off the hyper heap: %Rrc\n", cbResults, rc), rc); 69 /* 70 * The loop. 71 */ 72 RTRCPTR RCPtrResults = MMHyperR3ToRC(pVM, paResults); 73 uint32_t cMsrsFound = 0; 74 uint32_t uLastMsr = uMsr; 75 uint64_t uNsTsStart = RTTimeNanoTS(); 76 77 for (;;) 78 { 79 if ( pReportStrm 80 && uMsr - uLastMsr > _64K 81 && (uMsr & (_4M - 1)) == 0) 82 { 83 if (uMsr - uLastMsr < 16U*_1M) 84 RTStrmFlush(pReportStrm); 85 RTPrintf("... %#010x [%u ns/msr] ...\n", uMsr, (RTTimeNanoTS() - uNsTsStart) / uMsr); 86 } 87 88 /*RT_BZERO(paResults, cbResults);*/ 89 uint32_t const cBatch = RT_MIN(cMsrsPerCall, cMsrs); 90 rc = VMMR3CallRC(pVM, RCPtrEP, 4, pVM->pVMRC, uMsr, cBatch, RCPtrResults); 91 if (RT_FAILURE(rc)) 92 { 93 RTPrintf("VMM: VMMR3CallRC failed rc=%Rrc, uMsr=%#x\n", rc, uMsr); 94 break; 95 } 96 97 for (uint32_t i = 0; i < cBatch; i++) 98 if (paResults[i].uMsr != UINT64_MAX) 99 { 100 if (paResults[i].uValue == 0) 101 { 102 if (pReportStrm) 103 RTStrmPrintf(pReportStrm, "%#010llx = 0\n", paResults[i].uMsr); 104 RTPrintf("%#010llx = 0\n", paResults[i].uMsr); 105 } 106 else 107 { 108 if (pReportStrm) 109 RTStrmPrintf(pReportStrm, "%#010llx = %#010x`%08x\n", paResults[i].uMsr, 110 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue); 111 RTPrintf("%#010llx = %#010x`%08x\n", paResults[i].uMsr, 112 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue); 113 } 114 cMsrsFound++; 115 uLastMsr = paResults[i].uMsr; 116 } 117 118 /* Advance. */ 119 if (cMsrs <= cMsrsPerCall) 120 break; 121 cMsrs -= cMsrsPerCall; 122 uMsr += cMsrsPerCall; 123 } 124 125 *pcMsrsFound += cMsrsFound; 126 MMHyperFree(pVM, paResults); 127 return rc; 128 } 129 130 131 /** 132 * Produces a quick report of MSRs. 133 * 134 * @returns VBox status code. 135 * @param pVM Pointer to the cross context VM structure. 136 */ 137 static int vmmR3DoMsrQuickReport(PVM pVM) 138 { 139 uint64_t uTsStart = RTTimeNanoTS(); 140 RTPrintf("=== MSR Quick Report Start ===\n"); 141 RTStrmFlush(g_pStdOut); 142 DBGFR3InfoStdErr(pVM->pUVM, "cpuid", "verbose"); 143 RTPrintf("\n"); 144 uint32_t cMsrsFound = 0; 145 int rc = vmmR3ReportMsrRange(pVM, 0x00000000, 0x00042000, NULL, &cMsrsFound); 146 int rc2 = vmmR3ReportMsrRange(pVM, 0x40000000, 0x00012000, NULL, &cMsrsFound); 147 int rc3 = vmmR3ReportMsrRange(pVM, 0x80000000, 0x00012000, NULL, &cMsrsFound); 148 int rc4 = vmmR3ReportMsrRange(pVM, 0xc0000000, 0x00102000, NULL, &cMsrsFound); 149 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 150 rc = rc2; 151 if (RT_FAILURE(rc3) && RT_SUCCESS(rc)) 152 rc = rc3; 153 if (RT_FAILURE(rc4) && RT_SUCCESS(rc)) 154 rc = rc4; 155 RTPrintf("Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 156 RTPrintf("=== MSR Quick Report End (rc=%Rrc, %'llu ns) ===\n", rc, RTTimeNanoTS() - uTsStart); 157 return rc; 158 } 159 54 160 55 161 /** … … 468 574 469 575 rc = VINF_SUCCESS; 576 577 /* 578 * A quick MSR report. 579 */ 580 vmmR3DoMsrQuickReport(pVM); 470 581 } 471 582 else … … 658 769 { 659 770 #ifdef VBOX_WITH_RAW_MODE 660 RTRCPTR RCPtrEP;661 int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMRCTestReadMsrs", &RCPtrEP);771 PRTSTREAM pOutStrm; 772 int rc = RTStrmOpen("msr-report.txt", "a", &pOutStrm); 662 773 if (RT_SUCCESS(rc)) 663 774 { 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 = 16384; 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 if (paResults[i].uValue == 0) 714 { 715 RTStrmPrintf(pOutStrm, "%#010llx = 0\n", paResults[i].uMsr); 716 RTPrintf("%#010llx = 0\n", paResults[i].uMsr); 717 } 718 else 719 { 720 RTStrmPrintf(pOutStrm, "%#010llx = %#010x`%08x\n", paResults[i].uMsr, 721 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue); 722 RTPrintf("%#010llx = %#010x`%08x\n", paResults[i].uMsr, 723 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue); 724 } 725 cMsrsFound++; 726 uLastMsr = paResults[i].uMsr; 727 } 728 if (uCurMsr + cMsrsPerCall < uCurMsr) 729 break; 730 } 731 732 RTStrmPrintf(pOutStrm, "Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 733 RTPrintf("Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 734 MMHyperFree(pVM, paResults); 735 } 736 RTStrmClose(pOutStrm); 737 } 738 } 739 else 740 AssertMsgFailed(("Failed to resolved VMMRC.rc::VMMRCEntry(), rc=%Rrc\n", rc)); 775 /* Header */ 776 struct 777 { 778 PRTSTREAM pOutStrm; 779 DBGFINFOHLP Hlp; 780 } MyHlp = { pOutStrm, { vmmDoPrintfToStream, vmmDoPrintfVToStream } }; 781 DBGFR3Info(pVM->pUVM, "cpuid", "verbose", &MyHlp.Hlp); 782 RTStrmPrintf(pOutStrm, "\n"); 783 784 uint32_t cMsrsFound = 0; 785 vmmR3ReportMsrRange(pVM, 0, _4G, pOutStrm, &cMsrsFound); 786 787 RTStrmPrintf(pOutStrm, "Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 788 RTPrintf("Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 789 790 RTStrmClose(pOutStrm); 791 } 741 792 return rc; 742 793 #else
Note:
See TracChangeset
for help on using the changeset viewer.