VirtualBox

Changeset 76886 in vbox for trunk/src/VBox/VMM/tools


Ignore:
Timestamp:
Jan 18, 2019 10:57:02 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128254
Message:

VMM (and related changes): Add support for Shanghai/Zhaoxin CPUs. Modified and improved contribution by Journey Ren submitted under MIT license. Thank you!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp

    r76553 r76886  
    548548                if (!fGp)
    549549                    fFlags = 0;
    550                 /* VIA HACK - writing to 0x0000317e on a quad core make the core unresponsive. */
    551                 else if (uMsr == 0x0000317e && g_enmVendor == CPUMCPUVENDOR_VIA)
     550                /* VIA/Shanghai HACK - writing to 0x0000317e on a quad core make the core unresponsive. */
     551                else if (uMsr == 0x0000317e && (g_enmVendor == CPUMCPUVENDOR_VIA || g_enmVendor == CPUMCPUVENDOR_SHANGHAI))
    552552                {
    553553                    uValue = 0;
     
    601601                    if (RT_FAILURE(rc))
    602602                        return RTMsgErrorRc(rc, "Out of memory (uMsr=%#x).\n", uMsr);
    603                     if (   g_enmVendor != CPUMCPUVENDOR_VIA
     603                    if (   (g_enmVendor != CPUMCPUVENDOR_VIA && g_enmVendor != CPUMCPUVENDOR_SHANGHAI)
    604604                        || uValue
    605605                        || fFlags)
     
    25152515        case 0x00001438:
    25162516        case 0x0000317f:
    2517             if (g_enmVendor == CPUMCPUVENDOR_VIA)
     2517            if (g_enmVendor == CPUMCPUVENDOR_VIA || g_enmVendor == CPUMCPUVENDOR_SHANGHAI)
    25182518                return VBCPUREPBADNESS_BOND_VILLAIN;
    25192519            break;
     
    26022602
    26032603/**
    2604  * Checks if this might be a VIA dummy register.
     2604 * Checks if this might be a VIA/Shanghai dummy register.
    26052605 *
    26062606 * @returns true if it's a dummy, false if it isn't.
     
    26092609 * @param   fFlags              The flags.
    26102610 */
    2611 static bool isMsrViaDummy(uint32_t uMsr, uint64_t uValue, uint32_t fFlags)
    2612 {
    2613     if (g_enmVendor != CPUMCPUVENDOR_VIA)
     2611static bool isMsrViaShanghaiDummy(uint32_t uMsr, uint64_t uValue, uint32_t fFlags)
     2612{
     2613    if (g_enmVendor != CPUMCPUVENDOR_VIA && g_enmVendor != CPUMCPUVENDOR_SHANGHAI)
    26142614        return false;
    26152615
     
    32133213            || fGpMaskN   != fGpMask0)
    32143214        {
    3215             if (!fEarlyEndOk && !isMsrViaDummy(uMsr, paMsrs[i].uValue, paMsrs[i].fFlags))
     3215            if (!fEarlyEndOk && !isMsrViaShanghaiDummy(uMsr, paMsrs[i].uValue, paMsrs[i].fFlags))
    32163216            {
    32173217                vbCpuRepDebug("MSR %s (%#x) range ended unexpectedly early on %#x: ro=%d ign=%#llx/%#llx gp=%#llx/%#llx [N/0]\n",
     
    33033303
    33043304/**
    3305  * Reports a VIA dummy range.
     3305 * Reports a VIA/Shanghai dummy range.
    33063306 *
    33073307 * @returns VBox status code.
     
    33113311 *                              last MSR entry in the range.
    33123312 */
    3313 static int reportMsr_ViaDummyRange(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
     3313static int reportMsr_ViaShanghaiDummyRange(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
    33143314{
    33153315    /* Figure how many. */
     
    33183318    while (   cRegs < cMsrs
    33193319           && paMsrs[cRegs].uMsr == uMsr + cRegs
    3320            && isMsrViaDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags))
     3320           && isMsrViaShanghaiDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags))
    33213321    {
    33223322        cRegs++;
     
    34583458    while (   cRegs < cMsrs
    34593459           && paMsrs[cRegs].uMsr == uMsr + cRegs
    3460            && !isMsrViaDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags) )
     3460           && !isMsrViaShanghaiDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags) )
    34613461        cRegs++;
    34623462    if (cRegs & 1)
     
    42004200         * want to handle there to avoid making the code below unreadable.
    42014201         */
    4202         else if (isMsrViaDummy(uMsr, uValue, fFlags))
    4203             rc = reportMsr_ViaDummyRange(&paMsrs[i], cMsrs - i, &i);
     4202        /** @todo r=klaus check if Shanghai CPUs really are behaving the same */
     4203        else if (isMsrViaShanghaiDummy(uMsr, uValue, fFlags))
     4204            rc = reportMsr_ViaShanghaiDummyRange(&paMsrs[i], cMsrs - i, &i);
    42044205        /*
    42054206         * This shall be sorted by uMsr as much as possible.
     
    45674568        case CPUMCPUVENDOR_VIA:         return "VIA";
    45684569        case CPUMCPUVENDOR_CYRIX:       return "Cyrix";
     4570        case CPUMCPUVENDOR_SHANGHAI:    return "Shanghai";
    45694571        case CPUMCPUVENDOR_INVALID:
    45704572        case CPUMCPUVENDOR_UNKNOWN:
     
    46724674            char       *pszHit;
    46734675            while ((pszHit = strstr(pszName, pszWord)) != NULL)
    4674                 memmove(pszHit, pszHit + cchWord, strlen(pszHit + cchWord) + 1);
     4676                memset(pszHit, ' ', cchWord);
    46754677        }
    46764678
     
    47494751                       " */\n"
    47504752                       "\n"
    4751                        "#ifndef VBOX_CPUDB_%s\n"
    4752                        "#define VBOX_CPUDB_%s\n"
     4753                       "#ifndef VBOX_CPUDB_%s_h\n"
     4754                       "#define VBOX_CPUDB_%s_h\n"
    47534755                       "\n",
    47544756                       pszName,
     
    48074809                   "};\n"
    48084810                   "\n"
    4809                    "#endif /* !VBOX_DB_%s */\n"
     4811                   "#endif /* !VBOX_CPUDB_%s_h */\n"
    48104812                   "\n",
    48114813                   pszCpuDesc,
Note: See TracChangeset for help on using the changeset viewer.

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