儲存庫 vbox 的更動 49767
- 時間撮記:
- 2013-12-4 上午09:22:51 (11 年 以前)
- 位置:
- trunk/src/VBox/HostDrivers/Support
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r49634 r49767 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 227 227 /** Pointer to vmx_use_count. */ 228 228 static int volatile *g_pVmxUseCount = NULL; 229 230 #ifdef SUPDRV_WITH_MSR_PROBER 231 /** Pointer to rdmsr_carefully if found. Returns 0 on success. */ 232 static int (*g_pfnRdMsrCarefully)(uint32_t uMsr, uint32_t *puLow, uint32_t *puHigh) = NULL; 233 /** Pointer to rdmsr64_carefully if found. Returns 0 on success. */ 234 static int (*g_pfnRdMsr64Carefully)(uint32_t uMsr, uint64_t *uValue) = NULL; 235 /** Pointer to wrmsr[64]_carefully if found. Returns 0 on success. */ 236 static int (*g_pfnWrMsr64Carefully)(uint32_t uMsr, uint64_t uValue) = NULL; 237 #endif 229 238 230 239 … … 347 356 } 348 357 358 #ifdef SUPDRV_WITH_MSR_PROBER 359 /* MSR prober stuff. */ 360 int rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr_carefully", (void **)&g_pfnRdMsrCarefully); 361 if (RT_FAILURE(rc)) 362 g_pfnRdMsrCarefully = NULL; 363 rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr64_carefully", (void **)&g_pfnRdMsr64Carefully); 364 if (RT_FAILURE(rc)) 365 g_pfnRdMsr64Carefully = NULL; 366 # ifdef RT_ARCH_AMD64 /* Missing 64 in name, so if implemented on 32-bit it could have different signature. */ 367 rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "wrmsr_carefully", (void **)&g_pfnWrMsr64Carefully); 368 if (RT_FAILURE(rc)) 369 # endif 370 g_pfnWrMsr64Carefully = NULL; 371 #endif /* SUPDRV_WITH_MSR_PROBER */ 372 349 373 RTR0DbgKrnlInfoRelease(hKrnlInfo); 350 374 } … … 945 969 #ifdef SUPDRV_WITH_MSR_PROBER 946 970 971 typedef struct SUPDRVDARWINMSRARGS 972 { 973 RTUINT64U uValue; 974 uint32_t uMsr; 975 int rc; 976 } SUPDRVDARWINMSRARGS, *PSUPDRVDARWINMSRARGS; 977 978 /** 979 * On CPU worker for supdrvOSMsrProberRead. 980 * 981 * @param idCpu Ignored. 982 * @param pvUser1 Pointer to a SUPDRVDARWINMSRARGS. 983 * @param pvUser2 Ignored. 984 */ 985 static DECLCALLBACK(void) supdrvDarwinMsrProberReadOnCpu(RTCPUID idCpu, void *pvUser1, void *pvUser2) 986 { 987 PSUPDRVDARWINMSRARGS pArgs = (PSUPDRVDARWINMSRARGS)pvUser1; 988 if (g_pfnRdMsr64Carefully) 989 pArgs->rc = g_pfnRdMsr64Carefully(pArgs->uMsr, &pArgs->uValue.u); 990 else if (g_pfnRdMsrCarefully) 991 pArgs->rc = g_pfnRdMsrCarefully(pArgs->uMsr, &pArgs->uValue.s.Lo, &pArgs->uValue.s.Hi); 992 else 993 pArgs->rc = 2; 994 NOREF(idCpu); NOREF(pvUser2); 995 } 996 997 947 998 int VBOXCALL supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue) 948 999 { 949 NOREF(uMsr); NOREF(idCpu); NOREF(puValue); 950 return VERR_NOT_SUPPORTED; 1000 if (!g_pfnRdMsr64Carefully && !g_pfnRdMsrCarefully) 1001 return VERR_NOT_SUPPORTED; 1002 1003 SUPDRVDARWINMSRARGS Args; 1004 Args.uMsr = uMsr; 1005 Args.uValue.u = 0; 1006 Args.rc = -1; 1007 1008 if (idCpu == NIL_RTCPUID) 1009 supdrvDarwinMsrProberReadOnCpu(idCpu, &Args, NULL); 1010 else 1011 { 1012 int rc = RTMpOnSpecific(idCpu, supdrvDarwinMsrProberReadOnCpu, &Args, NULL); 1013 if (RT_FAILURE(rc)) 1014 return rc; 1015 } 1016 1017 if (Args.rc) 1018 return VERR_ACCESS_DENIED; 1019 *puValue = Args.uValue.u; 1020 return VINF_SUCCESS; 1021 } 1022 1023 1024 /** 1025 * On CPU worker for supdrvOSMsrProberWrite. 1026 * 1027 * @param idCpu Ignored. 1028 * @param pvUser1 Pointer to a SUPDRVDARWINMSRARGS. 1029 * @param pvUser2 Ignored. 1030 */ 1031 static DECLCALLBACK(void) supdrvDarwinMsrProberWriteOnCpu(RTCPUID idCpu, void *pvUser1, void *pvUser2) 1032 { 1033 PSUPDRVDARWINMSRARGS pArgs = (PSUPDRVDARWINMSRARGS)pvUser1; 1034 if (g_pfnWrMsr64Carefully) 1035 pArgs->rc = g_pfnWrMsr64Carefully(pArgs->uMsr, pArgs->uValue.u); 1036 else 1037 pArgs->rc = 2; 1038 NOREF(idCpu); NOREF(pvUser2); 951 1039 } 952 1040 … … 954 1042 int VBOXCALL supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue) 955 1043 { 956 NOREF(uMsr); NOREF(idCpu); NOREF(uValue); 957 return VERR_NOT_SUPPORTED; 1044 if (!g_pfnWrMsr64Carefully) 1045 return VERR_NOT_SUPPORTED; 1046 1047 SUPDRVDARWINMSRARGS Args; 1048 Args.uMsr = uMsr; 1049 Args.uValue.u = uValue; 1050 Args.rc = -1; 1051 1052 if (idCpu == NIL_RTCPUID) 1053 supdrvDarwinMsrProberWriteOnCpu(idCpu, &Args, NULL); 1054 else 1055 { 1056 int rc = RTMpOnSpecific(idCpu, supdrvDarwinMsrProberWriteOnCpu, &Args, NULL); 1057 if (RT_FAILURE(rc)) 1058 return rc; 1059 } 1060 1061 if (Args.rc) 1062 return VERR_ACCESS_DENIED; 1063 return VINF_SUCCESS; 1064 } 1065 1066 1067 /** 1068 * Worker for supdrvOSMsrProberModify. 1069 */ 1070 static DECLCALLBACK(void) supdrvDarwinMsrProberModifyOnCpu(RTCPUID idCpu, void *pvUser1, void *pvUser2) 1071 { 1072 PSUPMSRPROBER pReq = (PSUPMSRPROBER)pvUser1; 1073 register uint32_t uMsr = pReq->u.In.uMsr; 1074 bool const fFaster = pReq->u.In.enmOp == SUPMSRPROBEROP_MODIFY_FASTER; 1075 uint64_t uBefore; 1076 uint64_t uWritten; 1077 uint64_t uAfter; 1078 int rcBefore, rcWrite, rcAfter, rcRestore; 1079 RTCCUINTREG fOldFlags; 1080 1081 /* Initialize result variables. */ 1082 uBefore = uWritten = uAfter = 0; 1083 rcWrite = rcAfter = rcRestore = -1; 1084 1085 /* 1086 * Do the job. 1087 */ 1088 fOldFlags = ASMIntDisableFlags(); 1089 ASMCompilerBarrier(); /* paranoia */ 1090 if (!fFaster) 1091 ASMWriteBackAndInvalidateCaches(); 1092 1093 rcBefore = g_pfnRdMsr64Carefully(uMsr, &uBefore); 1094 if (rcBefore >= 0) 1095 { 1096 register uint64_t uRestore = uBefore; 1097 uWritten = uRestore; 1098 uWritten &= pReq->u.In.uArgs.Modify.fAndMask; 1099 uWritten |= pReq->u.In.uArgs.Modify.fOrMask; 1100 1101 rcWrite = g_pfnWrMsr64Carefully(uMsr, uWritten); 1102 rcAfter = g_pfnRdMsr64Carefully(uMsr, &uAfter); 1103 rcRestore = g_pfnWrMsr64Carefully(uMsr, uRestore); 1104 1105 if (!fFaster) 1106 { 1107 ASMWriteBackAndInvalidateCaches(); 1108 ASMReloadCR3(); 1109 ASMNopPause(); 1110 } 1111 } 1112 1113 ASMCompilerBarrier(); /* paranoia */ 1114 ASMSetFlags(fOldFlags); 1115 1116 /* 1117 * Write out the results. 1118 */ 1119 pReq->u.Out.uResults.Modify.uBefore = uBefore; 1120 pReq->u.Out.uResults.Modify.uWritten = uWritten; 1121 pReq->u.Out.uResults.Modify.uAfter = uAfter; 1122 pReq->u.Out.uResults.Modify.fBeforeGp = rcBefore != 0; 1123 pReq->u.Out.uResults.Modify.fModifyGp = rcWrite != 0; 1124 pReq->u.Out.uResults.Modify.fAfterGp = rcAfter != 0; 1125 pReq->u.Out.uResults.Modify.fRestoreGp = rcRestore != 0; 1126 RT_ZERO(pReq->u.Out.uResults.Modify.afReserved); 958 1127 } 959 1128 … … 961 1130 int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq) 962 1131 { 963 NOREF(idCpu); NOREF(pReq); 964 return VERR_NOT_SUPPORTED; 1132 if (!g_pfnWrMsr64Carefully || !g_pfnRdMsr64Carefully) 1133 return VERR_NOT_SUPPORTED; 1134 if (idCpu == NIL_RTCPUID) 1135 { 1136 supdrvDarwinMsrProberModifyOnCpu(idCpu, pReq, NULL); 1137 return VINF_SUCCESS; 1138 } 1139 return RTMpOnSpecific(idCpu, supdrvDarwinMsrProberModifyOnCpu, pReq, NULL); 965 1140 } 966 1141 -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r49728 r49767 966 966 RT_ZERO(pReq->u.Out.uResults.Modify.afReserved); 967 967 } 968 969 968 # endif 970 969
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器