Changeset 48368 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Sep 6, 2013 5:28:13 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r48357 r48368 872 872 873 873 /** 874 * Query an MSR. 875 * 876 * The caller is responsible for checking privilege if the call is the result 877 * of a RDMSR instruction. We'll do the rest. 878 * 879 * @retval VINF_SUCCESS on success. 880 * @retval VERR_CPUM_RAISE_GP_0 on failure (invalid MSR), the caller is 881 * expected to take the appropriate actions. @a *puValue is set to 0. 882 * @param pVCpu Pointer to the VMCPU. 883 * @param idMsr The MSR. 884 * @param puValue Where to return the value. 885 * 886 * @remarks This will always return the right values, even when we're in the 887 * recompiler. 888 */ 889 VMMDECL(int) CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue) 874 * Worker for CPUMQueryGuestMsr(). 875 * 876 * @retval VINF_SUCCESS 877 * @retval VERR_CPUM_RAISE_GP_0 878 * @param pVCpu The cross context CPU structure. 879 * @param idMsr The MSR to read. 880 * @param puValue Where to store the return value. 881 */ 882 static int cpumQueryGuestMsrInt(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue) 890 883 { 891 884 /* … … 1149 1142 case MSR_RAPL_POWER_UNIT: 1150 1143 case MSR_BBL_CR_CTL3: /* ca. core arch? */ 1144 case MSR_PKG_CST_CONFIG_CONTROL: /* Nahalem, Sandy Bridge */ 1151 1145 *puValue = 0; 1152 1146 if (CPUMGetGuestCpuVendor(pVCpu->CTX_SUFF(pVM)) != CPUMCPUVENDOR_INTEL) … … 1171 1165 0, /* bit 23 - L2 Not Present (RO). */ 1172 1166 0); 1167 break; 1168 case MSR_PKG_CST_CONFIG_CONTROL: 1169 *puValue = pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl; 1173 1170 break; 1174 1171 } … … 1231 1228 1232 1229 /** 1230 * Query an MSR. 1231 * 1232 * The caller is responsible for checking privilege if the call is the result 1233 * of a RDMSR instruction. We'll do the rest. 1234 * 1235 * @retval VINF_SUCCESS on success. 1236 * @retval VERR_CPUM_RAISE_GP_0 on failure (invalid MSR), the caller is 1237 * expected to take the appropriate actions. @a *puValue is set to 0. 1238 * @param pVCpu Pointer to the VMCPU. 1239 * @param idMsr The MSR. 1240 * @param puValue Where to return the value. 1241 * 1242 * @remarks This will always return the right values, even when we're in the 1243 * recompiler. 1244 */ 1245 VMMDECL(int) CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue) 1246 { 1247 int rc = cpumQueryGuestMsrInt(pVCpu, idMsr, puValue); 1248 LogFlow(("CPUMQueryGuestMsr: %#x -> %llx rc=%d\n", idMsr, *puValue, rc)); 1249 return rc; 1250 } 1251 1252 1253 /** 1233 1254 * Sets the MSR. 1234 1255 * … … 1250 1271 VMMDECL(int) CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue) 1251 1272 { 1273 LogFlow(("CPUSetGuestMsr: %#x <- %#llx\n", idMsr, uValue)); 1274 1252 1275 /* 1253 1276 * If we don't indicate MSR support in the CPUID feature bits, indicate … … 1457 1480 /*case MSR_IA32_MC0_CTL: - read-only? */ 1458 1481 /*case MSR_IA32_MC0_STATUS: - read-only? */ 1482 case MSR_PKG_CST_CONFIG_CONTROL: 1459 1483 if (CPUMGetGuestCpuVendor(pVCpu->CTX_SUFF(pVM)) != CPUMCPUVENDOR_INTEL) 1460 1484 { 1461 1485 Log(("CPUM: MSR %#x is Intel, the virtual CPU isn't an Intel one -> #GP\n", idMsr)); 1462 1486 return VERR_CPUM_RAISE_GP_0; 1487 } 1488 1489 switch (idMsr) 1490 { 1491 case MSR_PKG_CST_CONFIG_CONTROL: 1492 { 1493 if (pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl & RT_BIT_64(15)) 1494 { 1495 Log(("MSR_PKG_CST_CONFIG_CONTROL: Write protected -> #GP\n")); 1496 return VERR_CPUM_RAISE_GP_0; 1497 } 1498 static uint64_t s_fMask = UINT64_C(0x01f08407); /** @todo Only Nehalem has 24; Only Sandy has 27 and 28. */ 1499 static uint64_t s_fGpInvalid = UINT64_C(0xffffffff00ff0000); /** @todo figure out exactly what's off limits. */ 1500 if ((uValue & s_fGpInvalid) || (uValue & 7) >= 5) 1501 { 1502 Log(("MSR_PKG_CST_CONFIG_CONTROL: Invalid value %#llx -> #GP\n", uValue)); 1503 return VERR_CPUM_RAISE_GP_0; 1504 } 1505 pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl = uValue & s_fMask; 1506 break; 1507 } 1508 1463 1509 } 1464 1510 /* ignored */
Note:
See TracChangeset
for help on using the changeset viewer.