VirtualBox

Changeset 48368 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Sep 6, 2013 5:28:13 PM (11 years ago)
Author:
vboxsync
Message:

Implement MSR_PKG_CST_CONFIG_CONTROL for mac os x.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r48357 r48368  
    872872
    873873/**
    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 */
     882static int cpumQueryGuestMsrInt(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue)
    890883{
    891884    /*
     
    11491142        case MSR_RAPL_POWER_UNIT:
    11501143        case MSR_BBL_CR_CTL3:               /* ca. core arch? */
     1144        case MSR_PKG_CST_CONFIG_CONTROL:   /* Nahalem, Sandy Bridge */
    11511145            *puValue = 0;
    11521146            if (CPUMGetGuestCpuVendor(pVCpu->CTX_SUFF(pVM)) != CPUMCPUVENDOR_INTEL)
     
    11711165                                                   0, /* bit 23 - L2 Not Present (RO). */
    11721166                                                   0);
     1167                    break;
     1168                case MSR_PKG_CST_CONFIG_CONTROL:
     1169                    *puValue = pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl;
    11731170                    break;
    11741171            }
     
    12311228
    12321229/**
     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 */
     1245VMMDECL(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/**
    12331254 * Sets the MSR.
    12341255 *
     
    12501271VMMDECL(int) CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue)
    12511272{
     1273    LogFlow(("CPUSetGuestMsr: %#x <- %#llx\n", idMsr, uValue));
     1274
    12521275    /*
    12531276     * If we don't indicate MSR support in the CPUID feature bits, indicate
     
    14571480        /*case MSR_IA32_MC0_CTL:     - read-only? */
    14581481        /*case MSR_IA32_MC0_STATUS:  - read-only? */
     1482        case MSR_PKG_CST_CONFIG_CONTROL:
    14591483            if (CPUMGetGuestCpuVendor(pVCpu->CTX_SUFF(pVM)) != CPUMCPUVENDOR_INTEL)
    14601484            {
    14611485                Log(("CPUM: MSR %#x is Intel, the virtual CPU isn't an Intel one -> #GP\n", idMsr));
    14621486                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
    14631509            }
    14641510            /* ignored */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette