VirtualBox

Changeset 81605 in vbox


Ignore:
Timestamp:
Oct 31, 2019 2:29:46 PM (5 years ago)
Author:
vboxsync
Message:

VMM (and related changes): Add support for Hygon Dhyana CPUs. Modified and improved contribution by Hongyong Zang submitted under MIT license. Thank you!

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r81369 r81605  
    9898    CPUMCPUVENDOR_CYRIX,
    9999    CPUMCPUVENDOR_SHANGHAI,
     100    CPUMCPUVENDOR_HYGON,
    100101    CPUMCPUVENDOR_UNKNOWN,
    101102    /** 32bit hackishness. */
     
    275276    kCpumMicroarch_Shanghai_Unknown,
    276277    kCpumMicroarch_Shanghai_End,
     278
     279    kCpumMicroarch_Hygon_First,
     280    kCpumMicroarch_Hygon_Dhyana = kCpumMicroarch_Hygon_First,
     281    kCpumMicroarch_Hygon_Unknown,
     282    kCpumMicroarch_Hygon_End,
    277283
    278284    kCpumMicroarch_Unknown,
  • trunk/include/iprt/asm-amd64-x86.h

    r81076 r81605  
    15871587
    15881588/**
     1589 * Tests if it a genuine Hygon CPU based on the ASMCpuId(0) output.
     1590 *
     1591 * @returns true/false.
     1592 * @param   uEBX    EBX return from ASMCpuId(0)
     1593 * @param   uECX    ECX return from ASMCpuId(0)
     1594 * @param   uEDX    EDX return from ASMCpuId(0)
     1595 */
     1596DECLINLINE(bool) ASMIsHygonCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
     1597{
     1598    return uEBX == UINT32_C(0x6f677948)
     1599        && uECX == UINT32_C(0x656e6975)
     1600        && uEDX == UINT32_C(0x6e65476e);
     1601}
     1602
     1603
     1604/**
     1605 * Tests if this is a genuine Hygon CPU.
     1606 *
     1607 * @returns true/false.
     1608 * @remarks ASSUMES that cpuid is supported by the CPU.
     1609 */
     1610DECLINLINE(bool) ASMIsHygonCpu(void)
     1611{
     1612    uint32_t uEAX, uEBX, uECX, uEDX;
     1613    ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
     1614    return ASMIsHygonCpuEx(uEBX, uECX, uEDX);
     1615}
     1616
     1617
     1618/**
    15891619 * Checks whether ASMCpuId_EAX(0x00000000) indicates a valid range.
    15901620 *
  • trunk/include/iprt/x86.h

    r81602 r81605  
    401401#define X86_CPUID_VENDOR_SHANGHAI_ECX   0x20206961      /* ai   */
    402402#define X86_CPUID_VENDOR_SHANGHAI_EDX   0x68676e61      /* angh */
     403
     404#define X86_CPUID_VENDOR_HYGON_EBX      0x6f677948      /* Hygo */
     405#define X86_CPUID_VENDOR_HYGON_ECX      0x656e6975      /* uine */
     406#define X86_CPUID_VENDOR_HYGON_EDX      0x6e65476e      /* nGen */
    403407/** @} */
    404408
  • trunk/include/iprt/x86.mac

    r76886 r81605  
    9191%define X86_CPUID_VENDOR_SHANGHAI_ECX   0x20206961
    9292%define X86_CPUID_VENDOR_SHANGHAI_EDX   0x68676e61
     93%define X86_CPUID_VENDOR_HYGON_EBX      0x6f677948
     94%define X86_CPUID_VENDOR_HYGON_ECX      0x656e6975
     95%define X86_CPUID_VENDOR_HYGON_EDX      0x6e65476e
    9396%define X86_CPUID_FEATURE_ECX_SSE3      RT_BIT_32(0)
    9497%define X86_CPUID_FEATURE_ECX_PCLMUL    RT_BIT_32(1)
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp

    r81304 r81605  
    41504150
    41514151            /* Check if the vendor is AMD (or compatible). */
    4152             if (ASMIsAmdCpuEx(uVendorEbx, uVendorEcx, uVendorEdx))
     4152            if (   ASMIsAmdCpuEx(uVendorEbx, uVendorEcx, uVendorEdx)
     4153                || ASMIsHygonCpuEx(uVendorEbx, uVendorEcx, uVendorEdx))
    41534154            {
    41544155                uint32_t fExtFeatEcx, uExtMaxId;
     
    45124513                }
    45134514            }
    4514             else if (ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX))
     4515            else if (   ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX)
     4516                     || ASMIsHygonCpuEx(uVendorEBX, uVendorECX, uVendorEDX))
    45154517            {
    45164518                /* Not well documented, but at least all AMD64 CPUs support this. */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp

    r81106 r81605  
    18011801    ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
    18021802    if (   ASMIsValidStdRange(uEAX)
    1803         && ASMIsAmdCpuEx(uEBX, uECX, uEDX))
     1803        && (ASMIsAmdCpuEx(uEBX, uECX, uEDX) || ASMIsHygonCpuEx(uEBX, uECX, uEDX)) )
    18041804    {
    18051805        /* Check for APM support. */
     
    40214021            && ASMIsValidStdRange(ASMCpuId_EAX(0))
    40224022            && (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_HTT)
    4023             && (   !ASMIsAmdCpu()
     4023            && (   (!ASMIsAmdCpu() && !ASMIsHygonCpu())
    40244024                || ASMGetCpuFamily(u32Tmp = ASMCpuId_EAX(1)) > 0x15
    40254025                || (   ASMGetCpuFamily(u32Tmp)   == 0x15           /* Piledriver+, not bulldozer (FX-4150 didn't like it). */
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r81305 r81605  
    347347            }
    348348            /* AMD-V */
    349             else if (ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX))
     349            else if (   ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX)
     350                     || ASMIsHygonCpuEx(uVendorEBX, uVendorECX, uVendorEDX))
    350351            {
    351352                if (   (fExtFeaturesEcx & X86_CPUID_AMD_FEATURE_ECX_SVM)
  • trunk/src/VBox/VMM/VMMAll/GIMAll.cpp

    r80333 r81605  
    425425    {
    426426        case CPUMCPUVENDOR_AMD:
     427        case CPUMCPUVENDOR_HYGON:
    427428        {
    428429            if (puDisOpcode)
  • trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp

    r80333 r81605  
    14041404                || enmGuestCpuVendor == CPUMCPUVENDOR_SHANGHAI))
    14051405        || (   uDisOpcode == OP_VMMCALL
    1406             && enmGuestCpuVendor == CPUMCPUVENDOR_AMD))
     1406            && (   enmGuestCpuVendor == CPUMCPUVENDOR_AMD
     1407                || enmGuestCpuVendor == CPUMCPUVENDOR_HYGON)) )
    14071408        return gimHvHypercall(pVCpu, pCtx);
    14081409
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r81002 r81605  
    359359 * Evaluates to true if we're presenting an AMD CPU to the guest.
    360360 */
    361 #define IEM_IS_GUEST_CPU_AMD(a_pVCpu)       ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD )
     361#define IEM_IS_GUEST_CPU_AMD(a_pVCpu)       ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD || (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_HYGON )
    362362
    363363/**
  • trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp

    r80333 r81605  
    723723            || ASMIsAmdCpuEx(u32EBX, u32ECX, u32EDX)
    724724            || ASMIsViaCentaurCpuEx(u32EBX, u32ECX, u32EDX)
    725             || ASMIsShanghaiCpuEx(u32EBX, u32ECX, u32EDX))
     725            || ASMIsShanghaiCpuEx(u32EBX, u32ECX, u32EDX)
     726            || ASMIsHygonCpuEx(u32EBX, u32ECX, u32EDX))
    726727        && ASMIsValidStdRange(uMaxLeaf))
    727728    {
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r80346 r81605  
    15291529# endif
    15301530# ifdef LOG_ENABLED
    1531         if (enmCpuVendor != CPUMCPUVENDOR_AMD)
     1531        if (enmCpuVendor != CPUMCPUVENDOR_AMD && enmCpuVendor != CPUMCPUVENDOR_HYGON)
    15321532            pInput->Names[iReg++] = HvX64RegisterIa32FeatureControl;
    15331533# endif
     
    21062106# endif
    21072107# ifdef LOG_ENABLED
    2108         if (enmCpuVendor != CPUMCPUVENDOR_AMD)
     2108        if (enmCpuVendor != CPUMCPUVENDOR_AMD && enmCPUVendor != CPUMCPUVENDOR_HYGON)
    21092109        {
    21102110            Assert(pInput->Names[iReg] == HvX64RegisterIa32FeatureControl);
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r81292 r81605  
    980980    uint32_t const u32Family = u32CpuVersion >> 8;
    981981    if (   u32Family >= 6      /* K7 and higher */
    982         && ASMIsAmdCpu())
     982        && (ASMIsAmdCpu() || ASMIsHygonCpu()) )
    983983    {
    984984        uint32_t cExt = ASMCpuId_EAX(0x80000000);
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r81249 r81605  
    483483    }
    484484
     485    if (enmVendor == CPUMCPUVENDOR_HYGON)
     486    {
     487        switch (bFamily)
     488        {
     489            case 0x18:
     490                return kCpumMicroarch_Hygon_Dhyana;
     491            default:
     492                break;
     493        }
     494        return kCpumMicroarch_Hygon_Unknown;
     495    }
     496
    485497    return kCpumMicroarch_Unknown;
    486498}
     
    624636        CASE_RET_STR(kCpumMicroarch_NEC_V20);
    625637        CASE_RET_STR(kCpumMicroarch_NEC_V30);
     638
     639        CASE_RET_STR(kCpumMicroarch_Hygon_Dhyana);
     640        CASE_RET_STR(kCpumMicroarch_Hygon_Unknown);
    626641
    627642        CASE_RET_STR(kCpumMicroarch_Unknown);
     
    646661        case kCpumMicroarch_NEC_End:
    647662        case kCpumMicroarch_Shanghai_End:
     663        case kCpumMicroarch_Hygon_End:
    648664        case kCpumMicroarch_32BitHack:
    649665            break;
     
    13141330                             || uEbx
    13151331                             || uEdx
    1316                              || ASMIsAmdCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)) )
     1332                             || ASMIsAmdCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)
     1333                             || ASMIsHygonCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)) )
    13171334                    fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC_ID;
    13181335
     
    13221339                else if (   uLeaf == UINT32_C(0x80000001)
    13231340                         && (   (uEdx & X86_CPUID_AMD_FEATURE_EDX_APIC)
    1324                              || ASMIsAmdCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)) )
     1341                             || ASMIsAmdCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)
     1342                             || ASMIsHygonCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)) )
    13251343                    fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC;
    13261344
     
    16331651            return CPUMCPUVENDOR_CYRIX;
    16341652
     1653        if (ASMIsHygonCpuEx(uEBX, uECX, uEDX))
     1654            return CPUMCPUVENDOR_HYGON;
     1655
    16351656        /* "Geode by NSC", example: family 5, model 9.  */
    16361657
     
    16601681        case CPUMCPUVENDOR_CYRIX:       return "CYRIX";
    16611682        case CPUMCPUVENDOR_SHANGHAI:    return "SHANGHAI";
     1683        case CPUMCPUVENDOR_HYGON:       return "HYGON";
    16621684        case CPUMCPUVENDOR_UNKNOWN:     return "UNKNOWN";
    16631685
     
    19271949
    19281950        if (   pExtLeaf
    1929             && pFeatures->enmCpuVendor == CPUMCPUVENDOR_AMD)
     1951            && (   pFeatures->enmCpuVendor == CPUMCPUVENDOR_AMD
     1952                || pFeatures->enmCpuVendor == CPUMCPUVENDOR_HYGON))
    19301953        {
    19311954            /* AMD features. */
     
    19701993        pFeatures->fLeakyFxSR = pExtLeaf
    19711994                             && (pExtLeaf->uEdx & X86_CPUID_AMD_FEATURE_EDX_FFXSR)
    1972                              && pFeatures->enmCpuVendor == CPUMCPUVENDOR_AMD
     1995                             && (   pFeatures->enmCpuVendor == CPUMCPUVENDOR_AMD
     1996                                 || pFeatures->enmCpuVendor == CPUMCPUVENDOR_HYGON)
    19731997                             && pFeatures->uFamily >= 6 /* K7 and up */;
    19741998
     
    29392963     * VME bug was fixed in AGESA 1.0.0.6, microcode patch level 8001126.
    29402964     */
    2941     if ( (pVM->cpum.s.GuestFeatures.enmMicroarch == kCpumMicroarch_AMD_Zen_Ryzen)
     2965    if (   (   pVM->cpum.s.GuestFeatures.enmMicroarch == kCpumMicroarch_AMD_Zen_Ryzen
     2966            || pVM->cpum.s.GuestFeatures.enmMicroarch == kCpumMicroarch_Hygon_Dhyana)
    29422967        && uMicrocodeRev < 0x8001126
    29432968        && !pConfig->fForceVme)
     
    30663091#ifdef VBOX_WITH_MULTI_CORE
    30673092        if (   pVM->cCpus > 1
    3068             && pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     3093            && (   pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     3094                || pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    30693095            pExtFeatureLeaf->uEcx |= X86_CPUID_AMD_FEATURE_ECX_CMPL; /* CmpLegacy */
    30703096#endif
     
    36603686    {
    36613687        pCurLeaf->uEax = pCurLeaf->uEbx = pCurLeaf->uEcx = 0;
    3662         if (pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     3688        if (   pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     3689            || pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON)
    36633690        {
    36643691            /*
     
    37153742#ifdef VBOX_WITH_MULTI_CORE
    37163743        if (   pVM->cCpus > 1
    3717             && pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     3744            && (   pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     3745                || pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    37183746            pCurLeaf->uEcx |= (pVM->cCpus - 1) & UINT32_C(0xff);
    37193747#endif
     
    37323760     *        EDX - SVM Feature identification.
    37333761     */
    3734     if (pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     3762    if (   pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     3763        || pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON)
    37353764    {
    37363765        pExtFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, UINT32_C(0x80000001), 0);
     
    38433872        {
    38443873            Assert(pCpum->GuestFeatures.enmCpuVendor != CPUMCPUVENDOR_AMD);
     3874            Assert(pCpum->GuestFeatures.enmCpuVendor != CPUMCPUVENDOR_HYGON);
    38453875            pCurLeaf->uEbx = 0; /* Reserved. */
    38463876            pCurLeaf->uEcx = 0; /* Reserved. */
     
    41224152    bool fQueryNestedHwvirt = false;
    41234153#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
    4124     fQueryNestedHwvirt |= RT_BOOL(pVM->cpum.s.HostFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD);
     4154    fQueryNestedHwvirt |= RT_BOOL(   pVM->cpum.s.HostFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     4155                                  || pVM->cpum.s.HostFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON);
    41254156#endif
    41264157#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     
    47174748            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    47184749            if (    pLeaf
    4719                 &&  pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     4750                &&  (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     4751                     || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    47204752                pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAE;
    47214753
     
    48014833            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    48024834            if (   pLeaf
    4803                 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     4835                && (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     4836                    || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    48044837                pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAT;
    48054838
     
    49414974                LogRel(("CPUM: SetGuestCpuIdFeature: Enabled Speculation Control.\n"));
    49424975            }
    4943             else if (pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     4976            else if (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     4977                     || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON)
    49444978            {
    49454979                /* The precise details of AMD's implementation are not yet clear. */
     
    50405074            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    50415075            if (   pLeaf
    5042                 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     5076                && (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     5077                    || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    50435078                pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAE;
    50445079
     
    50545089            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    50555090            if (   pLeaf
    5056                 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     5091                && (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     5092                    || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON))
    50575093                pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAT;
    50585094
     
    56635699    {
    56645700        /** @todo deal with no 0x80000001 on the host. */
    5665         bool const fHostAmd  = ASMIsAmdCpuEx(aHostRawStd[0].uEbx, aHostRawStd[0].uEcx, aHostRawStd[0].uEdx);
    5666         bool const fGuestAmd = ASMIsAmdCpuEx(aGuestCpuIdExt[0].uEbx, aGuestCpuIdExt[0].uEcx, aGuestCpuIdExt[0].uEdx);
     5701        bool const fHostAmd  = ASMIsAmdCpuEx(aHostRawStd[0].uEbx, aHostRawStd[0].uEcx, aHostRawStd[0].uEdx)
     5702                               || ASMIsHygonCpuEx(aHostRawStd[0].uEbx, aHostRawStd[0].uEcx, aHostRawStd[0].uEdx);
     5703        bool const fGuestAmd = ASMIsAmdCpuEx(aGuestCpuIdExt[0].uEbx, aGuestCpuIdExt[0].uEcx, aGuestCpuIdExt[0].uEdx)
     5704                               || ASMIsHygonCpuEx(aGuestCpuIdExt[0].uEbx, aGuestCpuIdExt[0].uEcx, aGuestCpuIdExt[0].uEdx);
    56675705
    56685706        /* CPUID(0x80000001).ecx */
  • trunk/src/VBox/VMM/VMMR3/CPUMR3Db.cpp

    r80333 r81605  
    217217#include "cpus/ZHAOXIN_KaiXian_KX_U5581_1_8GHz.h"
    218218
     219#include "cpus/Hygon_C86_7185_32_core.h"
    219220
    220221
     
    318319#ifdef VBOX_CPUDB_NEC_V20_h
    319320    &g_Entry_NEC_V20,
     321#endif
     322
     323#ifdef VBOX_CPUDB_Hygon_C86_7185_32_core_h
     324    &g_Entry_Hygon_C86_7185_32_core,
    320325#endif
    321326};
  • trunk/src/VBox/VMM/VMMR3/NEMR3.cpp

    r80333 r81605  
    196196         */
    197197        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
    198         if (CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_AMD)
     198        if (   CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_AMD
     199            || CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_HYGON)
    199200            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);            /* 64 bits only on Intel CPUs */
    200201        if (pVM->nem.s.fAllow64BitGuests)
  • trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp

    r76886 r81605  
    525525            /* Ditto for 0x0000002a (EBL_CR_POWERON) and 0x00000277 (MSR_IA32_CR_PAT) on Intel (Atom 330). */
    526526            /* And more of the same for 0x280 on Intel Pentium III. */
    527             if (   ((uMsr >= 0xc0011012 && uMsr <= 0xc0011013) && g_enmVendor == CPUMCPUVENDOR_AMD)
     527            if (   ((uMsr >= 0xc0011012 && uMsr <= 0xc0011013) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    528528                || (   (uMsr == 0x2a || uMsr == 0x277)
    529529                    && g_enmVendor == CPUMCPUVENDOR_INTEL
     
    696696        case 0x00000089: return "BBL_CR_D1";
    697697        case 0x0000008a: return "BBL_CR_D2";
    698         case 0x0000008b: return g_enmVendor == CPUMCPUVENDOR_AMD ? "AMD_K8_PATCH_LEVEL"
     698        case 0x0000008b: return (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor ==  CPUMCPUVENDOR_HYGON) ? "AMD_K8_PATCH_LEVEL"
    699699                              : g_fIntelNetBurst ? "IA32_BIOS_SIGN_ID" : "BBL_CR_D3|BIOS_SIGN";
    700700        case 0x0000008c: return "P6_UNK_0000_008c"; /* P6_M_Dothan. */
     
    19461946            return "IntelLastBranchFromToN";
    19471947
    1948         case 0x0000008b: return g_enmVendor == CPUMCPUVENDOR_AMD ? "AmdK8PatchLevel" : "Ia32BiosSignId";
     1948        case 0x0000008b: return (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON) ? "AmdK8PatchLevel" : "Ia32BiosSignId";
    19491949        case 0x0000009b: return "Ia32SmmMonitorCtl";
    19501950
     
    35663566        || (  g_enmVendor == CPUMCPUVENDOR_INTEL
    35673567            ? g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First
    3568             : g_enmVendor == CPUMCPUVENDOR_AMD
     3568            : (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON)
    35693569            ? g_enmMicroarch != kCpumMicroarch_AMD_K8_90nm_AMDV
    35703570            : true) )
     
    42064206         * This shall be sorted by uMsr as much as possible.
    42074207         */
    4208         else if (uMsr == 0x00000000 && g_enmVendor == CPUMCPUVENDOR_AMD && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
     4208        else if (uMsr == 0x00000000 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON) && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
    42094209            rc = printMsrAlias(uMsr, 0x00000402, NULL);
    4210         else if (uMsr == 0x00000001 && g_enmVendor == CPUMCPUVENDOR_AMD && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
     4210        else if (uMsr == 0x00000001 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON) && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
    42114211            rc = printMsrAlias(uMsr, 0x00000401, NULL); /** @todo not 101% correct on Fam15h and later, 0xc0010015[McstatusWrEn] effect differs. */
    42124212        else if (uMsr == 0x0000001b)
     
    42794279        else if (uMsr >= 0xc0000408 && uMsr <= 0xc000040f)
    42804280            rc = reportMsr_AmdFam10hMc4MiscN(&paMsrs[i], cMsrs - i, &i);
    4281         else if (uMsr == 0xc0010000 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4281        else if (uMsr == 0xc0010000 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42824282            rc = reportMsr_AmdK8PerfCtlN(&paMsrs[i], cMsrs - i, &i);
    4283         else if (uMsr == 0xc0010004 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4283        else if (uMsr == 0xc0010004 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42844284            rc = reportMsr_AmdK8PerfCtrN(&paMsrs[i], cMsrs - i, &i);
    4285         else if (uMsr == 0xc0010010 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4285        else if (uMsr == 0xc0010010 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42864286            rc = reportMsr_AmdK8SysCfg(uMsr, uValue);
    4287         else if (uMsr == 0xc0010015 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4287        else if (uMsr == 0xc0010015 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42884288            rc = reportMsr_AmdK8HwCr(uMsr, uValue);
    4289         else if ((uMsr == 0xc0010016 || uMsr == 0xc0010018) && g_enmVendor == CPUMCPUVENDOR_AMD)
     4289        else if ((uMsr == 0xc0010016 || uMsr == 0xc0010018) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42904290            rc = reportMsr_AmdK8IorrBaseN(uMsr, uValue);
    4291         else if ((uMsr == 0xc0010017 || uMsr == 0xc0010019) && g_enmVendor == CPUMCPUVENDOR_AMD)
     4291        else if ((uMsr == 0xc0010017 || uMsr == 0xc0010019) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42924292            rc = reportMsr_AmdK8IorrMaskN(uMsr, uValue);
    4293         else if ((uMsr == 0xc001001a || uMsr == 0xc001001d) && g_enmVendor == CPUMCPUVENDOR_AMD)
     4293        else if ((uMsr == 0xc001001a || uMsr == 0xc001001d) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42944294            rc = reportMsr_AmdK8TopMemN(uMsr, uValue);
    4295         else if (uMsr == 0xc0010030 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4295        else if (uMsr == 0xc0010030 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42964296            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 6, "AmdK8CpuNameN", &i);
    4297         else if (uMsr >= 0xc0010044 && uMsr <= 0xc001004a && g_enmVendor == CPUMCPUVENDOR_AMD)
     4297        else if (uMsr >= 0xc0010044 && uMsr <= 0xc001004a && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    42984298            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 7, "AmdK8McCtlMaskN", 0xc0010044, true /*fEarlyEndOk*/, false, 0, &i);
    4299         else if (uMsr == 0xc0010050 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4299        else if (uMsr == 0xc0010050 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43004300            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 4, "AmdK8SmiOnIoTrapN", &i);
    4301         else if (uMsr == 0xc0010064 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4301        else if (uMsr == 0xc0010064 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43024302            rc = reportMsr_AmdFam10hPStateN(&paMsrs[i], cMsrs - i, &i);
    4303         else if (uMsr == 0xc0010070 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4303        else if (uMsr == 0xc0010070 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43044304            rc = reportMsr_AmdFam10hCofVidControl(uMsr, uValue);
    4305         else if ((uMsr == 0xc0010118 || uMsr == 0xc0010119) && getMsrFnName(uMsr, NULL) && g_enmVendor == CPUMCPUVENDOR_AMD)
     4305        else if ((uMsr == 0xc0010118 || uMsr == 0xc0010119) && getMsrFnName(uMsr, NULL) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43064306            rc = printMsrFunction(uMsr, NULL, NULL, annotateValue(uValue)); /* RAZ, write key. */
    4307         else if (uMsr == 0xc0010200 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4307        else if (uMsr == 0xc0010200 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43084308            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 12, &i);
    4309         else if (uMsr == 0xc0010230 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4309        else if (uMsr == 0xc0010230 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43104310            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 8, &i);
    4311         else if (uMsr == 0xc0010240 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4311        else if (uMsr == 0xc0010240 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43124312            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 8, &i);
    4313         else if (uMsr == 0xc0011019 && g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver && g_enmVendor == CPUMCPUVENDOR_AMD)
     4313        else if (uMsr == 0xc0011019 && g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43144314            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 3, "AmdK7DrXAddrMaskN", 0xc0011019 - 1,
    43154315                                              false /*fEarlyEndOk*/, false /*fNoIgnMask*/, 0, &i);
    4316         else if (uMsr == 0xc0011021 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4316        else if (uMsr == 0xc0011021 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43174317            rc = reportMsr_AmdK7InstrCacheCfg(uMsr, uValue);
    43184318        else if (uMsr == 0xc0011023 && CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
    43194319            rc = reportMsr_AmdFam15hCombUnitCfg(uMsr, uValue);
    4320         else if (uMsr == 0xc0011027 && g_enmVendor == CPUMCPUVENDOR_AMD)
     4320        else if (uMsr == 0xc0011027 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
    43214321            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 1, "AmdK7DrXAddrMaskN", 0xc0011027,
    43224322                                              false /*fEarlyEndOk*/, false /*fNoIgnMask*/, 0, &i);
     
    44734473                       " * MSR ranges for %s.\n"
    44744474                       " */\n"
    4475                        "static CPUMMSRRANGE const g_aMsrRanges_%s[] = \n{\n",
     4475                       "static CPUMMSRRANGE const g_aMsrRanges_%s[] =\n{\n",
    44764476                       pszCpuDesc,
    44774477                       pszNameC);
     
    45694569        case CPUMCPUVENDOR_CYRIX:       return "Cyrix";
    45704570        case CPUMCPUVENDOR_SHANGHAI:    return "Shanghai";
     4571        case CPUMCPUVENDOR_HYGON:       return "Hygon";
    45714572        case CPUMCPUVENDOR_INVALID:
    45724573        case CPUMCPUVENDOR_UNKNOWN:
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-decoding-1.c32

    r76553 r81605  
    882882    bool fIsAmd = false;
    883883    if (g_uBs3CpuDetected & BS3CPU_F_CPUID)
    884         fIsAmd = ASMIsAmdCpu();
     884        fIsAmd = ASMIsAmdCpu() || ASMIsHygonCpu();
    885885    Bs3TestPrintf("fIsAmd=%d\n", fIsAmd);
    886886
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r76886 r81605  
    47484748            CASE_PRED(BS3CG1PRED_VENDOR_VIA,   pThis->bCpuVendor == BS3CPUVENDOR_VIA);
    47494749            CASE_PRED(BS3CG1PRED_VENDOR_SHANGHAI, pThis->bCpuVendor == BS3CPUVENDOR_SHANGHAI);
     4750            CASE_PRED(BS3CG1PRED_VENDOR_HYGON, pThis->bCpuVendor == BS3CPUVENDOR_HYGON);
    47504751
    47514752#undef CASE_PRED
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r76886 r81605  
    776776    BS3CG1PRED_VENDOR_VIA,
    777777    BS3CG1PRED_VENDOR_SHANGHAI,
     778    BS3CG1PRED_VENDOR_HYGON,
    778779
    779780    BS3CG1PRED_END
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-weird-1-x0.c

    r76553 r81605  
    324324        Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx);
    325325        Bs3RegSetDr7(0);
    326         if (g_enmCpuVendor == BS3CPUVENDOR_AMD)
     326        if (g_enmCpuVendor == BS3CPUVENDOR_AMD || g_enmCpuVendor == BS3CPUVENDOR_HYGON)
    327327            bs3CpuWeird1_CompareDbgInhibitRingXfer(&TrapCtx, &Ctx, X86_XCPT_DB, offTestLabel, cbSpAdjust,
    328328                                                   X86_DR6_INIT_VAL | X86_DR6_B0, cbIretFrameInt, uHandlerRspInt);
     
    341341
    342342        Bs3TrapSetJmpAndRestore(&Ctx, &TrapCtx);
    343         if (g_enmCpuVendor == BS3CPUVENDOR_AMD)
     343        if (g_enmCpuVendor == BS3CPUVENDOR_AMD || g_enmCpuVendor ==  BS3CPUVENDOR_HYGON)
    344344            bs3CpuWeird1_CompareDbgInhibitRingXfer(&TrapCtx, &Ctx, X86_XCPT_DB, offTestLabel, cbSpAdjust,
    345345                                                   X86_DR6_INIT_VAL | X86_DR6_B0, cbIretFrameInt, uHandlerRspInt);
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-GetCpuVendor.c

    r76886 r81605  
    4545        if (ASMIsShanghaiCpuEx(uEbx, uEcx, uEdx))
    4646            return BS3CPUVENDOR_SHANGHAI;
     47        if (ASMIsHygonCpuEx(uEbx, uEcx, uEdx))
     48            return BS3CPUVENDOR_HYGON;
    4749        return BS3CPUVENDOR_UNKNOWN;
    4850    }
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r76886 r81605  
    15381538    BS3CPUVENDOR_CYRIX,
    15391539    BS3CPUVENDOR_SHANGHAI,
     1540    BS3CPUVENDOR_HYGON,
    15401541    BS3CPUVENDOR_UNKNOWN,
    15411542    BS3CPUVENDOR_END
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