Changeset 69654 in vbox for trunk/src/VBox
- Timestamp:
- Nov 10, 2017 7:22:45 PM (7 years ago)
- Location:
- trunk/src/VBox/VMM/tools
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/tools/Makefile.kmk
r69582 r69654 60 60 VBoxCpuReport_SOURCES = \ 61 61 VBoxCpuReport.cpp \ 62 MsrSup.cpp \ 63 ../VMMR3/CPUMR3CpuId.cpp 64 VBoxCpuReport_SOURCES.linux = MsrLinux.cpp 62 VBoxCpuReportMsrSup.cpp \ 63 ../VMMR3/CPUMR3CpuId.cpp 64 VBoxCpuReport_SOURCES.linux = \ 65 VBoxCpuReportMsrLinux.cpp 65 66 VBoxCpuReport_DEFS.linux = VBCR_HAVE_PLATFORM_MSR_PROBER 66 67 VBoxCpuReport_LIBS = \ -
trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp
r69653 r69654 79 79 static uint64_t g_uMsrIntelP6FsbFrequency = UINT64_MAX; 80 80 81 /** MSR prober routines. */ 82 static VBMSRFNS g_MsrAcc; 83 /** Wheter MSR prober can read/modify/restore MSRs more or less 84 * atomically, without allowing other code to be executed. */ 85 static bool g_fAtomicMsrMod; 81 /** The MSR accessors interface. */ 82 static VBCPUREPMSRACCESSORS g_MsrAcc; 83 84 86 85 87 86 void vbCpuRepDebug(const char *pszMsg, ...) … … 226 225 { 227 226 bool fGp; 228 int rc = g_MsrAcc. msrWrite(uMsr, NIL_RTCPUID, uValue, &fGp);227 int rc = g_MsrAcc.pfnMsrWrite(uMsr, NIL_RTCPUID, uValue, &fGp); 229 228 AssertRC(rc); 230 229 return RT_SUCCESS(rc) && !fGp; … … 237 236 *puValue = 0; 238 237 bool fGp; 239 int rc = g_MsrAcc. msrRead(uMsr, NIL_RTCPUID, puValue, &fGp);238 int rc = g_MsrAcc.pfnMsrProberRead(uMsr, NIL_RTCPUID, puValue, &fGp); 240 239 AssertRC(rc); 241 240 return RT_SUCCESS(rc) && !fGp; … … 247 246 { 248 247 SUPMSRPROBERMODIFYRESULT Result; 249 int rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, UINT64_MAX, 0, &Result);248 int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, UINT64_MAX, 0, &Result); 250 249 return RT_SUCCESS(rc) 251 250 && !Result.fBeforeGp … … 260 259 { 261 260 SUPMSRPROBERMODIFYRESULT Result; 262 int rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, 0, 0, &Result);261 int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, 0, 0, &Result); 263 262 return RT_SUCCESS(rc) 264 263 && !Result.fBeforeGp … … 288 287 /* Set it. */ 289 288 SUPMSRPROBERMODIFYRESULT ResultSet; 290 int rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);289 int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet); 291 290 if (RT_FAILURE(rc)) 292 return RTMsgErrorRc(rc, " msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);291 return RTMsgErrorRc(rc, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc); 293 292 294 293 /* Clear it. */ 295 294 SUPMSRPROBERMODIFYRESULT ResultClear; 296 rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);295 rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear); 297 296 if (RT_FAILURE(rc)) 298 return RTMsgErrorRc(rc, " msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);297 return RTMsgErrorRc(rc, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc); 299 298 300 299 if (ResultSet.fModifyGp || ResultClear.fModifyGp) … … 331 330 /* Set it. */ 332 331 SUPMSRPROBERMODIFYRESULT ResultSet; 333 int rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);332 int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet); 334 333 if (RT_FAILURE(rc)) 335 return RTMsgErrorRc(-2, " msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);334 return RTMsgErrorRc(-2, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc); 336 335 337 336 /* Clear it. */ 338 337 SUPMSRPROBERMODIFYRESULT ResultClear; 339 rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);338 rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear); 340 339 if (RT_FAILURE(rc)) 341 return RTMsgErrorRc(-2, " msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);340 return RTMsgErrorRc(-2, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc); 342 341 343 342 if (ResultSet.fModifyGp || ResultClear.fModifyGp) … … 370 369 { 371 370 SUPMSRPROBERMODIFYRESULT Result; 372 int rc = g_MsrAcc. msrModify(uMsr, NIL_RTCPUID, fAndMask, fOrMask, &Result);371 int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, fAndMask, fOrMask, &Result); 373 372 if (RT_FAILURE(rc)) 374 373 { 375 RTMsgError("g_MsrAcc. msrModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, fAndMask, fOrMask, rc);374 RTMsgError("g_MsrAcc.pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, fAndMask, fOrMask, rc); 376 375 return false; 377 376 } … … 538 537 uint64_t uValue = 0; 539 538 bool fGp = true; 540 int rc = g_MsrAcc. msrRead(uMsr, NIL_RTCPUID, &uValue, &fGp);539 int rc = g_MsrAcc.pfnMsrProberRead(uMsr, NIL_RTCPUID, &uValue, &fGp); 541 540 if (RT_FAILURE(rc)) 542 541 { 543 542 RTMemFree(*ppaMsrs); 544 543 *ppaMsrs = NULL; 545 return RTMsgErrorRc(rc, " msrRead failed on %#x: %Rrc\n", uMsr, rc);544 return RTMsgErrorRc(rc, "pfnMsrProberRead failed on %#x: %Rrc\n", uMsr, rc); 546 545 } 547 546 … … 569 568 #endif 570 569 fGp = true; 571 rc = g_MsrAcc. msrWrite(uMsr, NIL_RTCPUID, 0, &fGp);570 rc = g_MsrAcc.pfnMsrProberWrite(uMsr, NIL_RTCPUID, 0, &fGp); 572 571 if (RT_FAILURE(rc)) 573 572 { 574 573 RTMemFree(*ppaMsrs); 575 574 *ppaMsrs = NULL; 576 return RTMsgErrorRc(rc, " msrWrite failed on %#x: %Rrc\n", uMsr, rc);575 return RTMsgErrorRc(rc, "pfnMsrProberWrite failed on %#x: %Rrc\n", uMsr, rc); 577 576 } 578 577 uValue = 0; … … 2558 2557 */ 2559 2558 case 0x00000010: /* IA32_TIME_STAMP_COUNTER */ 2560 if (!g_ fAtomicMsrMod)2559 if (!g_MsrAcc.fAtomic) 2561 2560 return VBCPUREPBADNESS_BOND_VILLAIN; 2562 2561 break; … … 2575 2574 case 0xc0000101: /* AMD64_GS_BASE */ 2576 2575 case 0xc0000102: /* AMD64_KERNEL_GS_BASE */ 2577 if (!g_ fAtomicMsrMod)2576 if (!g_MsrAcc.fAtomic) 2578 2577 return VBCPUREPBADNESS_MIGHT_BITE; 2579 2578 break; … … 3364 3363 3365 3364 /* If the OS uses the APIC, we have to be super careful. */ 3366 if (!g_ fAtomicMsrMod)3365 if (!g_MsrAcc.fAtomic) 3367 3366 fSkipMask |= UINT64_C(0x0000000ffffff000); 3368 3367 … … 3394 3393 3395 3394 /* If the OS is using MONITOR/MWAIT we'd better not disable it! */ 3396 if (!g_ fAtomicMsrMod)3395 if (!g_MsrAcc.fAtomic) 3397 3396 fSkipMask |= RT_BIT(18); 3398 3397 … … 3692 3691 { 3693 3692 fSkipMask |= MSR_K6_EFER_LME; 3694 if (!g_ fAtomicMsrMod&& (uValue & MSR_K6_EFER_SCE))3693 if (!g_MsrAcc.fAtomic && (uValue & MSR_K6_EFER_SCE)) 3695 3694 fSkipMask |= MSR_K6_EFER_SCE; 3696 3695 } … … 4404 4403 * First try the the support library (also checks if we can really read MSRs). 4405 4404 */ 4406 int rc = SupDrvMsrProberInit(&g_MsrAcc, &g_fAtomicMsrMod);4405 int rc = VbCpuRepMsrProberInitSupDrv(&g_MsrAcc); 4407 4406 if (RT_FAILURE(rc)) 4408 4407 { 4409 4408 #ifdef VBCR_HAVE_PLATFORM_MSR_PROBER 4410 4409 /* Next try a platform-specific interface. */ 4411 rc = PlatformMsrProberInit(&g_MsrAcc, &g_fAtomicMsrMod);4410 rc = VbCpuRepMsrProberInitPlatform(&g_MsrAcc); 4412 4411 #endif 4413 4412 if (RT_FAILURE(rc)) … … 4420 4419 uint64_t uValue; 4421 4420 bool fGp; 4422 rc = g_MsrAcc. msrRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp);4421 rc = g_MsrAcc.pfnMsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp); 4423 4422 if (RT_FAILURE(rc)) 4424 4423 { … … 4427 4426 } 4428 4427 vbCpuRepDebug("MSR_IA32_TSC: %#llx fGp=%RTbool\n", uValue, fGp); 4429 rc = g_MsrAcc. msrRead(0xdeadface, NIL_RTCPUID, &uValue, &fGp);4428 rc = g_MsrAcc.pfnMsrProberRead(0xdeadface, NIL_RTCPUID, &uValue, &fGp); 4430 4429 vbCpuRepDebug("0xdeadface: %#llx fGp=%RTbool rc=%Rrc\n", uValue, fGp, rc); 4431 4430 … … 4485 4484 paMsrs = NULL; 4486 4485 } 4487 g_MsrAcc.msrProberTerm(); 4486 if (g_MsrAcc.pfnTerm) 4487 g_MsrAcc.pfnTerm(); 4488 4488 RT_ZERO(g_MsrAcc); 4489 4489 return rc; -
trunk/src/VBox/VMM/tools/VBoxCpuReport.h
r69653 r69654 16 16 */ 17 17 18 typedef struct VBMSRFNS { 19 int (*msrRead)(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp); 20 int (*msrWrite)(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp); 21 int (*msrModify)(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, PSUPMSRPROBERMODIFYRESULT pResult); 22 int (*msrProberTerm)(void); 23 } VBMSRFNS; 18 19 #ifndef ___VBoxCpuReport_h___ 20 #define ___VBoxCpuReport_h___ 21 22 #include <VBox/sup.h> 23 24 RT_C_DECLS_BEGIN 25 26 typedef struct VBCPUREPMSRACCESSORS 27 { 28 /** Wheter MSR prober can read/modify/restore MSRs more or less 29 * atomically, without allowing other code to be executed. */ 30 bool fAtomic; 31 /** @copydoc SUPR3MsrProberRead */ 32 DECLCALLBACKMEMBER(int, pfnMsrProberRead)(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp); 33 /** @copydoc SUPR3MsrProberWrite */ 34 DECLCALLBACKMEMBER(int, pfnMsrProberWrite)(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp); 35 /** @copydoc SUPR3MsrProberModify */ 36 DECLCALLBACKMEMBER(int, pfnMsrProberModify)(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, 37 PSUPMSRPROBERMODIFYRESULT pResult); 38 /** Termination callback, optional. */ 39 DECLCALLBACKMEMBER(void, pfnTerm)(void); 40 } VBCPUREPMSRACCESSORS; 41 typedef VBCPUREPMSRACCESSORS *PVBCPUREPMSRACCESSORS; 24 42 25 43 extern void vbCpuRepDebug(const char *pszMsg, ...); 26 44 extern void vbCpuRepPrintf(const char *pszMsg, ...); 27 extern int SupDrvMsrProberInit(VBMSRFNS *fnsMsr, bool *pfAtomicMsrMod);28 extern int PlatformMsrProberInit(VBMSRFNS *fnsMsr, bool *pfAtomicMsrMod);45 extern int VbCpuRepMsrProberInitSupDrv(PVBCPUREPMSRACCESSORS pMsrAccessors); 46 extern int VbCpuRepMsrProberInitPlatform(PVBCPUREPMSRACCESSORS pMsrAccessors); 29 47 48 RT_C_DECLS_END 49 50 #endif 51 -
trunk/src/VBox/VMM/tools/VBoxCpuReportMsrLinux.cpp
r69653 r69654 20 20 * Header Files * 21 21 *********************************************************************************************************************************/ 22 #include <iprt/ctype.h> 22 #include "VBoxCpuReport.h" 23 24 #include <iprt/file.h> 23 25 #include <iprt/thread.h> 24 26 25 #include <VBox/sup.h> 26 #include "VBoxCpuReport.h" 27 28 #include <unistd.h> 27 #ifndef RT_OS_WINDOWS 28 # include <unistd.h> 29 #else /* RT_OS_WINDOWS: for test compiling this file on windows */ 30 # include <io.h> 31 int pread(int, void *, size_t, off_t); 32 int pwrite(int, void const *, size_t, off_t); 33 #endif 29 34 #include <fcntl.h> 30 35 #include <errno.h> 31 36 32 37 38 /********************************************************************************************************************************* 39 * Defined Constants And Macros * 40 *********************************************************************************************************************************/ 33 41 #define MSR_DEV_NAME "/dev/cpu/0/msr" 34 35 36 /*********************************************************************************************************************************37 * Structures and Typedefs *38 *********************************************************************************************************************************/39 42 40 43 … … 46 49 47 50 51 /** 52 * @interface_method_impl{VBCPUREPMSRACCESSORS,pfnMsrProberRead} 53 */ 48 54 static int linuxMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp) 49 55 { … … 65 71 } 66 72 73 74 /** 75 * @interface_method_impl{VBCPUREPMSRACCESSORS,pfnMsrProberWrite} 76 */ 67 77 static int linuxMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp) 68 78 { … … 84 94 } 85 95 86 static int linuxMsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, PSUPMSRPROBERMODIFYRESULT pResult) 96 /** 97 * @interface_method_impl{VBCPUREPMSRACCESSORS,pfnMsrProberModify} 98 */ 99 static DECLCALLBACK(int) linuxMsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, 100 PSUPMSRPROBERMODIFYRESULT pResult) 87 101 { 88 102 int rc = VINF_SUCCESS; … … 100 114 RTThreadSleep(10); 101 115 #endif 102 rcBefore = pread(g_fdMsr, &uBefore, sizeof(uBefore), uMsr) != sizeof(uBefore);116 rcBefore = pread(g_fdMsr, &uBefore, sizeof(uBefore), uMsr); 103 117 uWrite = (uBefore & fAndMask) | fOrMask; 104 118 rcWrite = pwrite(g_fdMsr, &uWrite, sizeof(uWrite), uMsr); 105 rcAfter = pread(g_fdMsr, &uAfter, sizeof(uAfter), uMsr) != sizeof(uAfter);106 rcRestore = pwrite(g_fdMsr, &uBefore, sizeof(uBefore), uMsr) != sizeof(uBefore);119 rcAfter = pread(g_fdMsr, &uAfter, sizeof(uAfter), uMsr); 120 rcRestore = pwrite(g_fdMsr, &uBefore, sizeof(uBefore), uMsr); 107 121 108 122 #if 0 … … 114 128 pResult->uWritten = uWrite; 115 129 pResult->uAfter = uAfter; 116 pResult->fBeforeGp = rcBefore ;117 pResult->fModifyGp = rcWrite != sizeof(uWrite);118 pResult->fAfterGp = rcAfter ;119 pResult->fRestoreGp = rcRestore ;130 pResult->fBeforeGp = rcBefore != sizeof(uBefore); 131 pResult->fModifyGp = rcWrite != sizeof(uWrite); 132 pResult->fAfterGp = rcAfter != sizeof(uAfter); 133 pResult->fRestoreGp = rcRestore != sizeof(uBefore); 120 134 121 135 return rc; 122 136 } 123 137 124 static int linuxMsrProberTerm(void) 138 139 /** 140 * @interface_method_impl{VBCPUREPMSRACCESSORS,pfnTerm} 141 */ 142 static DECLCALLBACK(void) linuxMsrProberTerm(void) 125 143 { 126 if (g_fdMsr <0)127 return VERR_INVALID_STATE;128 129 close(g_fdMsr);130 return VINF_SUCCESS;144 if (g_fdMsr >= 0) 145 { 146 close(g_fdMsr); 147 g_fdMsr = -1; 148 } 131 149 } 132 150 133 int PlatformMsrProberInit(VBMSRFNS *fnsMsr, bool *pfAtomicMsrMod)151 int VbCpuRepMsrProberInitPlatform(PVBCPUREPMSRACCESSORS pMsrAccessors) 134 152 { 135 if (access(MSR_DEV_NAME, F_OK)) 153 RTFILE hFile; 154 int rc = RTFileOpen(&hFile, MSR_DEV_NAME, RTFILE_O_READWRITE | RTFILE_O_DENY_NONE | RTFILE_O_OPEN); 155 if (RT_SUCCESS(rc)) 136 156 { 137 vbCpuRepDebug("warning: The " MSR_DEV_NAME " device does not exist\n"); 138 return VERR_NOT_FOUND; 157 g_fdMsr = RTFileToNative(hFile); 158 Assert(g_fdMsr != -1); 159 160 pMsrAccessors->fAtomic = false; /* Can't modify/restore MSRs without trip to R3. */ 161 pMsrAccessors->pfnMsrProberRead = linuxMsrProberRead; 162 pMsrAccessors->pfnMsrProberWrite = linuxMsrProberWrite; 163 pMsrAccessors->pfnMsrProberModify = linuxMsrProberModify; 164 pMsrAccessors->pfnTerm = linuxMsrProberTerm; 165 return VINF_SUCCESS; 139 166 } 140 141 g_fdMsr = open(MSR_DEV_NAME, O_RDWR); 142 if (g_fdMsr <= 0) 143 { 144 vbCpuRepDebug("warning: Failed to open " MSR_DEV_NAME "\n"); 145 return VERR_ACCESS_DENIED; 146 } 147 148 fnsMsr->msrRead = linuxMsrProberRead; 149 fnsMsr->msrWrite = linuxMsrProberWrite; 150 fnsMsr->msrModify = linuxMsrProberModify; 151 fnsMsr->msrProberTerm = linuxMsrProberTerm; 152 *pfAtomicMsrMod = false; /* Can't modify/restore MSRs without trip to R3. */ 153 154 return VINF_SUCCESS; 167 vbCpuRepDebug("warning: Failed to open " MSR_DEV_NAME ": %Rrc\n", rc); 168 return rc; 155 169 } -
trunk/src/VBox/VMM/tools/VBoxCpuReportMsrSup.cpp
r69651 r69654 20 20 * Header Files * 21 21 *********************************************************************************************************************************/ 22 #include <iprt/ctype.h>22 #include "VBoxCpuReport.h" 23 23 #include <iprt/x86.h> 24 24 25 #include <VBox/sup.h>26 #include "VBoxCpuReport.h"27 25 26 int VbCpuRepMsrProberInitSupDrv(PVBCPUREPMSRACCESSORS pMsrFunctions) 27 { 28 int rc = SUPR3Init(NULL); 29 if (RT_SUCCESS(rc)) 30 { 31 /* Test if the MSR prober is available, since the interface is optional. The TSC MSR will exist on any supported CPU. */ 32 uint64_t uValue; 33 bool fGp; 34 rc = SUPR3MsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp); 35 if ( rc != VERR_NOT_IMPLEMENTED 36 && rc != VERR_INVALID_FUNCTION) 37 { 38 pMsrFunctions->fAtomic = true; 39 pMsrFunctions->pfnMsrProberRead = SUPR3MsrProberRead; 40 pMsrFunctions->pfnMsrProberWrite = SUPR3MsrProberWrite; 41 pMsrFunctions->pfnMsrProberModify = SUPR3MsrProberModify; 28 42 29 /* Wrappers to mask funny SUPR3 calling conventions on some platforms. */ 30 static int supMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp) 31 { 32 return SUPR3MsrProberRead(uMsr, idCpu, puValue, pfGp); 43 pMsrFunctions->pfnTerm = NULL; 44 return VINF_SUCCESS; 45 46 } 47 vbCpuRepDebug("warning: MSR probing not supported by the support driver (%Rrc).\n", rc); 48 } 49 else 50 vbCpuRepDebug("warning: Unable to initialize the support library (%Rrc).\n", rc); 51 return rc; 33 52 } 34 53 35 static int supMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp)36 {37 return SUPR3MsrProberWrite(uMsr, idCpu, uValue, pfGp);38 }39 40 static int supMsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, PSUPMSRPROBERMODIFYRESULT pResult)41 {42 return SUPR3MsrProberModify(uMsr, idCpu, fAndMask, fOrMask, pResult);43 }44 45 static int supMsrProberTerm(void)46 {47 return VINF_SUCCESS;48 }49 50 int SupDrvMsrProberInit(VBMSRFNS *fnsMsr, bool *pfAtomicMsrMod)51 {52 int rc = SUPR3Init(NULL);53 if (RT_FAILURE(rc))54 {55 vbCpuRepDebug("warning: Unable to initialize the support library (%Rrc).\n", rc);56 return VERR_NOT_FOUND;57 }58 59 /* Test if the MSR prober is available, since the interface is optional. The TSC MSR will exist on any supported CPU. */60 uint64_t uValue;61 bool fGp;62 rc = SUPR3MsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp);63 if (RT_FAILURE(rc))64 {65 vbCpuRepDebug("warning: MSR probing not supported by the support driver (%Rrc).\n", rc);66 return VERR_NOT_SUPPORTED;67 }68 69 fnsMsr->msrRead = supMsrProberRead;70 fnsMsr->msrWrite = supMsrProberWrite;71 fnsMsr->msrModify = supMsrProberModify;72 fnsMsr->msrProberTerm = supMsrProberTerm;73 *pfAtomicMsrMod = true;74 75 return VINF_SUCCESS;76 }
Note:
See TracChangeset
for help on using the changeset viewer.