VirtualBox

Changeset 49977 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Dec 18, 2013 5:51:13 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91407
Message:

CPUM: Make sure a minimum of commonly used MSRs are present by default.

Location:
trunk/src/VBox/VMM/VMMR3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r49972 r49977  
    16771677    }
    16781678
     1679    /*
     1680     * MSR fudging.
     1681     */
     1682    /** @cfgm{CPUM/FudgeMSRs, boolean, true}
     1683     * Fudges some common MSRs if not present in the selected CPU database entry.
     1684     * This is for trying to keep VMs running when moved between different hosts
     1685     * and different CPU vendors. */
     1686    bool fEnable;
     1687    rc = CFGMR3QueryBoolDef(pCpumCfg, "FudgeMSRs", &fEnable, true);       AssertRCReturn(rc, rc);
     1688    if (fEnable)
     1689    {
     1690        rc = cpumR3MsrApplyFudge(pVM);
     1691        AssertLogRelRCReturn(rc, rc);
     1692    }
    16791693
    16801694    /*
     
    17041718
    17051719    /* Check if PAE was explicitely enabled by the user. */
    1706     bool fEnable;
    17071720    rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "EnablePAE", &fEnable, false);      AssertRCReturn(rc, rc);
    17081721    if (fEnable)
  • trunk/src/VBox/VMM/VMMR3/CPUMR3Db.cpp

    r49972 r49977  
    439439
    440440
     441/**
     442 * Fudges the MSRs that guest are known to access in some odd cases.
     443 *
     444 * A typical example is a VM that has been moved between different hosts where
     445 * for instance the cpu vendor differs.
     446 *
     447 * @returns VBox status code.
     448 * @param   pVM                 Pointer to the cross context VM structure.
     449 */
     450int cpumR3MsrApplyFudge(PVM pVM)
     451{
     452    static CPUMMSRRANGE const s_aFudgeMsrs[] =
     453    {
     454        MFO(0x00000099, "IA32_P5_MC_ADDR",          Ia32P5McAddr),
     455        MFX(0x00000001, "IA32_P5_MC_TYPE",          Ia32P5McType,   Ia32P5McType,   0, 0, UINT64_MAX),
     456        MVO(0x00000017, "IA32_PLATFORM_ID",         0),
     457        MFN(0x0000001b, "IA32_APIC_BASE",           Ia32ApicBase,   Ia32ApicBase),
     458        MVI(0x0000008b, "BIOS_SIGN",                0),
     459        MFX(0x000000fe, "IA32_MTRRCAP",             Ia32MtrrCap,    ReadOnly,       0x508, 0, 0),
     460        MFX(0x00000179, "IA32_MCG_CAP",             Ia32McgCap,     ReadOnly,       0x005, 0, 0),
     461        MFX(0x0000017a, "IA32_MCG_STATUS",          Ia32McgStatus,  Ia32McgStatus,  0, ~(uint64_t)UINT32_MAX, 0),
     462        MFN(0x000001a0, "IA32_MISC_ENABLE",         Ia32MiscEnable, Ia32MiscEnable),
     463        MFN(0x000001d9, "IA32_DEBUGCTL",            Ia32DebugCtl,   Ia32DebugCtl),
     464        MFO(0x000001db, "P6_LAST_BRANCH_FROM_IP",   P6LastBranchFromIp),
     465        MFO(0x000001dc, "P6_LAST_BRANCH_TO_IP",     P6LastBranchToIp),
     466        MFO(0x000001dd, "P6_LAST_INT_FROM_IP",      P6LastIntFromIp),
     467        MFO(0x000001de, "P6_LAST_INT_TO_IP",        P6LastIntToIp),
     468        MFS(0x00000277, "IA32_PAT",                 Ia32Pat, Ia32Pat, Guest.msrPAT),
     469        MFZ(0x000002ff, "IA32_MTRR_DEF_TYPE",       Ia32MtrrDefType, Ia32MtrrDefType, GuestMsrs.msr.MtrrDefType, 0, ~(uint64_t)0xc07),
     470        MFN(0x00000400, "IA32_MCi_CTL_STATUS_ADDR_MISC", Ia32McCtlStatusAddrMiscN, Ia32McCtlStatusAddrMiscN),
     471    };
     472
     473    for (uint32_t i = 0; i < RT_ELEMENTS(s_aFudgeMsrs); i++)
     474        if (!cpumLookupMsrRange(pVM, s_aFudgeMsrs[i].uFirst))
     475        {
     476            LogRel(("CPUM: MSR fudge: %#010x %s\n", s_aFudgeMsrs[i].uFirst, s_aFudgeMsrs[i].szName));
     477            int rc = cpumR3MsrRangesInsert(&pVM->cpum.s.GuestInfo.paMsrRangesR3, &pVM->cpum.s.GuestInfo.cMsrRanges,
     478                                           &s_aFudgeMsrs[i]);
     479            if (RT_FAILURE(rc))
     480                return rc;
     481        }
     482
     483    return VINF_SUCCESS;
     484}
     485
     486
    441487int cpumR3DbGetCpuInfo(const char *pszName, PCPUMINFO pInfo)
    442488{
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