- Timestamp:
- Nov 2, 2013 4:28:37 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VMMTests.cpp
r49357 r49367 101 101 { 102 102 if (pReportStrm) 103 RTStrmPrintf(pReportStrm, "%#010llx = 0\n", paResults[i].uMsr); 103 RTStrmPrintf(pReportStrm, 104 " MVO(%#010llx, \"MSR\", UINT64_C(%#018llx)),\n", paResults[i].uMsr, paResults[i].uValue); 104 105 RTPrintf("%#010llx = 0\n", paResults[i].uMsr); 105 106 } … … 107 108 { 108 109 if (pReportStrm) 109 RTStrmPrintf(pReportStrm, "%#010llx = %#010x`%08x\n", paResults[i].uMsr,110 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue);110 RTStrmPrintf(pReportStrm, 111 " MVO(%#010llx, \"MSR\", UINT64_C(%#018llx)),\n", paResults[i].uMsr, paResults[i].uValue); 111 112 RTPrintf("%#010llx = %#010x`%08x\n", paResults[i].uMsr, 112 113 (uint32_t)(paResults[i].uValue >> 32), (uint32_t)paResults[i].uValue); … … 133 134 * 134 135 * @returns VBox status code. 135 * @param pVM Pointer to the cross context VM structure. 136 * @param pVM Pointer to the cross context VM structure. 137 * @param pReportStrm Pointer to the report output stream. Optional. 138 * @param fWithCpuId Whether CPUID should be included. 136 139 */ 137 static int vmmR3DoMsrQuickReport(PVM pVM )140 static int vmmR3DoMsrQuickReport(PVM pVM, PRTSTREAM pReportStrm, bool fWithCpuId) 138 141 { 139 142 uint64_t uTsStart = RTTimeNanoTS(); 140 143 RTPrintf("=== MSR Quick Report Start ===\n"); 141 144 RTStrmFlush(g_pStdOut); 142 DBGFR3InfoStdErr(pVM->pUVM, "cpuid", "verbose"); 143 RTPrintf("\n"); 145 if (fWithCpuId) 146 { 147 DBGFR3InfoStdErr(pVM->pUVM, "cpuid", "verbose"); 148 RTPrintf("\n"); 149 } 150 if (pReportStrm) 151 RTStrmPrintf(pReportStrm, "\n\n{\n"); 144 152 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 /* for some reason this crashes two AMD testboxes */ 149 // int rc4 = vmmR3ReportMsrRange(pVM, 0xc0000000, 0x00102000, NULL, &cMsrsFound); 150 int rc4 = vmmR3ReportMsrRange(pVM, 0xc0000000, 0x00010000, NULL, &cMsrsFound); 151 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 152 rc = rc2; 153 if (RT_FAILURE(rc3) && RT_SUCCESS(rc)) 154 rc = rc3; 155 if (RT_FAILURE(rc4) && RT_SUCCESS(rc)) 156 rc = rc4; 153 int aRc[] = 154 { 155 vmmR3ReportMsrRange(pVM, 0x00000000, 0x00042000, pReportStrm, &cMsrsFound), 156 vmmR3ReportMsrRange(pVM, 0x10000000, 0x00001000, pReportStrm, &cMsrsFound), 157 vmmR3ReportMsrRange(pVM, 0x20000000, 0x00001000, pReportStrm, &cMsrsFound), 158 vmmR3ReportMsrRange(pVM, 0x40000000, 0x00012000, pReportStrm, &cMsrsFound), 159 vmmR3ReportMsrRange(pVM, 0x80000000, 0x00012000, pReportStrm, &cMsrsFound), 160 vmmR3ReportMsrRange(pVM, 0xc0000000, 0x00102000, pReportStrm, &cMsrsFound), 161 }; 162 int rc = VINF_SUCCESS; 163 for (unsigned i = 0; i < RT_ELEMENTS(aRc); i++) 164 if (RT_FAILURE(aRc[i])) 165 { 166 rc = aRc[i]; 167 break; 168 } 169 if (pReportStrm) 170 RTStrmPrintf(pReportStrm, "}; /* %u (%#x) MSRs; rc=%Rrc */\n", cMsrsFound, cMsrsFound, rc); 157 171 RTPrintf("Total %u (%#x) MSRs\n", cMsrsFound, cMsrsFound); 158 172 RTPrintf("=== MSR Quick Report End (rc=%Rrc, %'llu ns) ===\n", rc, RTTimeNanoTS() - uTsStart); … … 580 594 * A quick MSR report. 581 595 */ 582 vmmR3DoMsrQuickReport(pVM );596 vmmR3DoMsrQuickReport(pVM, NULL, true); 583 597 } 584 598 else … … 768 782 * @param pVM The VM handle. 769 783 */ 770 VMM DECL(int) VMMDoBruteForceMsrs(PVM pVM)784 VMMR3DECL(int) VMMDoBruteForceMsrs(PVM pVM) 771 785 { 772 786 #ifdef VBOX_WITH_RAW_MODE … … 798 812 } 799 813 814 815 /** 816 * Uses raw-mode to query all known MSRS on the real hardware. 817 * 818 * This generates a known-msr-report.txt file (appending, no overwriting) as 819 * well as writing the values and process to stdout. 820 * 821 * @returns VBox status code. 822 * @param pVM The VM handle. 823 */ 824 VMMR3DECL(int) VMMDoKnownMsrs(PVM pVM) 825 { 826 #ifdef VBOX_WITH_RAW_MODE 827 PRTSTREAM pOutStrm; 828 int rc = RTStrmOpen("known-msr-report.txt", "a", &pOutStrm); 829 if (RT_SUCCESS(rc)) 830 { 831 vmmR3DoMsrQuickReport(pVM, pOutStrm, false); 832 RTStrmClose(pOutStrm); 833 } 834 return rc; 835 #else 836 return VERR_NOT_SUPPORTED; 837 #endif 838 } 839 840 841 /** 842 * MSR experimentation. 843 * 844 * @returns VBox status code. 845 * @param pVM The VM handle. 846 */ 847 VMMR3DECL(int) VMMDoMsrExperiments(PVM pVM) 848 { 849 #ifdef VBOX_WITH_RAW_MODE 850 /* 851 * Preps. 852 */ 853 RTRCPTR RCPtrEP; 854 int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMRCTestTestWriteMsr", &RCPtrEP); 855 AssertMsgRCReturn(rc, ("Failed to resolved VMMRC.rc::VMMRCEntry(), rc=%Rrc\n", rc), rc); 856 857 uint64_t *pauValues; 858 rc = MMHyperAlloc(pVM, 2 * sizeof(uint64_t), 0, MM_TAG_VMM, (void **)&pauValues); 859 AssertMsgRCReturn(rc, ("Error allocating %#x bytes off the hyper heap: %Rrc\n", 2 * sizeof(uint64_t), rc), rc); 860 RTRCPTR RCPtrValues = MMHyperR3ToRC(pVM, pauValues); 861 862 /* 863 * Do the experiments. 864 */ 865 uint32_t uMsr = 0xc0011011; 866 uint64_t uValue = 0x10000; 867 #if 0 868 rc = VMMR3CallRC(pVM, RCPtrEP, 6, pVM->pVMRC, uMsr, RT_LODWORD(uValue), RT_HIDWORD(uValue), 869 RCPtrValues, RCPtrValues + sizeof(uint64_t)); 870 RTPrintf("uMsr=%#010x before=%#018llx written=%#018llx after=%#018llx rc=%Rrc\n", 871 uMsr, pauValues[0], uValue, pauValues[1], rc); 872 #endif 873 for (uint32_t i = 0; i <= 63; i++) 874 { 875 uValue = RT_BIT_64(i); 876 rc = VMMR3CallRC(pVM, RCPtrEP, 6, pVM->pVMRC, uMsr, RT_LODWORD(uValue), RT_HIDWORD(uValue), 877 RCPtrValues, RCPtrValues + sizeof(uint64_t)); 878 RTPrintf("uMsr=%#010x before=%#018llx written=%#018llx after=%#018llx rc=%Rrc\n", 879 uMsr, pauValues[0], uValue, pauValues[1], rc); 880 } 881 882 uValue = 0; 883 rc = VMMR3CallRC(pVM, RCPtrEP, 6, pVM->pVMRC, uMsr, RT_LODWORD(uValue), RT_HIDWORD(uValue), 884 RCPtrValues, RCPtrValues + sizeof(uint64_t)); 885 RTPrintf("uMsr=%#010x before=%#018llx written=%#018llx after=%#018llx rc=%Rrc\n", 886 uMsr, pauValues[0], uValue, pauValues[1], rc); 887 888 uValue = UINT64_MAX; 889 rc = VMMR3CallRC(pVM, RCPtrEP, 6, pVM->pVMRC, uMsr, RT_LODWORD(uValue), RT_HIDWORD(uValue), 890 RCPtrValues, RCPtrValues + sizeof(uint64_t)); 891 RTPrintf("uMsr=%#010x before=%#018llx written=%#018llx after=%#018llx rc=%Rrc\n", 892 uMsr, pauValues[0], uValue, pauValues[1], rc); 893 894 /* 895 * Cleanups. 896 */ 897 MMHyperFree(pVM, pauValues); 898 return rc; 899 #else 900 return VERR_NOT_SUPPORTED; 901 #endif 902 } 903
Note:
See TracChangeset
for help on using the changeset viewer.