VirtualBox

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


Ignore:
Timestamp:
Jun 2, 2022 9:24:47 PM (3 years ago)
Author:
vboxsync
Message:

VMM/CPUMR3CpuId: Ignore x86 host capabilities in CPUMR3SetGuestCpuIdFeature. bugref:9898

File:
1 edited

Legend:

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

    r95174 r95179  
    32623262    PCPUMMSRRANGE  pMsrRange;
    32633263
     3264#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
     3265# define CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) \
     3266    if (!pVM->cpum.s.HostFeatures. a_fFeature) \
     3267    { \
     3268        LogRel(("CPUM: WARNING! Can't turn on " a_szFeature " when the host doesn't support it!\n")); \
     3269        return; \
     3270    } else do { } while (0)
     3271#else
     3272# define CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) do { } while (0)
     3273#endif
     3274
     3275#define GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) \
     3276    do \
     3277    { \
     3278        pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); \
     3279        if (!pLeaf) \
     3280        { \
     3281            LogRel(("CPUM: WARNING! Can't turn on " a_szFeature " when no 0x80000001 CPUID leaf!\n")); \
     3282            return; \
     3283        } \
     3284        CHECK_X86_HOST_FEATURE_RET(a_fFeature,a_szFeature); \
     3285    } while (0)
     3286
    32643287    switch (enmFeature)
    32653288    {
     
    33223345         */
    33233346        case CPUMCPUIDFEATURE_SEP:
    3324             if (!pVM->cpum.s.HostFeatures.fSysEnter)
    3325             {
    3326                 AssertMsgFailed(("ERROR: Can't turn on SEP when the host doesn't support it!!\n"));
    3327                 return;
    3328             }
    3329 
     3347            CHECK_X86_HOST_FEATURE_RET(fSysEnter, "SEP");
    33303348            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001));
    33313349            if (pLeaf)
     
    33403358         */
    33413359        case CPUMCPUIDFEATURE_SYSCALL:
    3342             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    3343             if (   !pLeaf
    3344                 || !pVM->cpum.s.HostFeatures.fSysCall)
    3345             {
    3346                 LogRel(("CPUM: WARNING! Can't turn on SYSCALL/SYSRET when the host doesn't support it!\n"));
    3347                 return;
    3348             }
     3360            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fSysCall, "SYSCALL/SYSRET");
    33493361
    33503362            /* Valid for both Intel and AMD CPUs, although only in 64 bits mode for Intel. */
     
    33593371         */
    33603372        case CPUMCPUIDFEATURE_PAE:
    3361             if (!pVM->cpum.s.HostFeatures.fPae)
    3362             {
    3363                 LogRel(("CPUM: WARNING! Can't turn on PAE when the host doesn't support it!\n"));
    3364                 return;
    3365             }
    3366 
    33673373            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001));
    33683374            if (pLeaf)
     
    33843390         */
    33853391        case CPUMCPUIDFEATURE_LONG_MODE:
    3386             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    3387             if (   !pLeaf
    3388                 || !pVM->cpum.s.HostFeatures.fLongMode)
    3389             {
    3390                 LogRel(("CPUM: WARNING! Can't turn on LONG MODE when the host doesn't support it!\n"));
    3391                 return;
    3392             }
     3392            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fLongMode, "LONG MODE");
    33933393
    33943394            /* Valid for both Intel and AMD. */
     
    34103410         */
    34113411        case CPUMCPUIDFEATURE_NX:
    3412             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    3413             if (   !pLeaf
    3414                 || !pVM->cpum.s.HostFeatures.fNoExecute)
    3415             {
    3416                 LogRel(("CPUM: WARNING! Can't turn on NX/XD when the host doesn't support it!\n"));
    3417                 return;
    3418             }
     3412            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fNoExecute, "NX/XD");
    34193413
    34203414            /* Valid for both Intel and AMD. */
     
    34303424         */
    34313425        case CPUMCPUIDFEATURE_LAHF:
    3432             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    3433             if (   !pLeaf
    3434                 || !pVM->cpum.s.HostFeatures.fLahfSahf)
    3435             {
    3436                 LogRel(("CPUM: WARNING! Can't turn on LAHF/SAHF when the host doesn't support it!\n"));
    3437                 return;
    3438             }
     3426            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fLahfSahf, "LAHF/SAHF");
    34393427
    34403428            /* Valid for both Intel and AMD. */
     
    34493437         */
    34503438        case CPUMCPUIDFEATURE_RDTSCP:
     3439            if (pVM->cpum.s.u8PortableCpuIdLevel > 0)
     3440                return;
     3441            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fRdTscP, "RDTSCP");
    34513442            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
    3452             if (   !pLeaf
    3453                 || !pVM->cpum.s.HostFeatures.fRdTscP
    3454                 || pVM->cpum.s.u8PortableCpuIdLevel > 0)
    3455             {
    3456                 if (!pVM->cpum.s.u8PortableCpuIdLevel)
    3457                     LogRel(("CPUM: WARNING! Can't turn on RDTSCP when the host doesn't support it!\n"));
    3458                 return;
    3459             }
    34603443
    34613444            /* Valid for both Intel and AMD. */
     
    35803563        pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID;
    35813564    }
     3565
     3566#undef GET_8000_0001_CHECK_X86_HOST_FEATURE_RET
     3567#undef CHECK_X86_HOST_FEATURE_RET
    35823568}
    35833569
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