VirtualBox

Changeset 79830 in vbox


Ignore:
Timestamp:
Jul 17, 2019 8:41:41 AM (5 years ago)
Author:
vboxsync
Message:

VMM/CPUM: Nested SVM: bugref:7243: Better sanitization of CPUID leaf 0x8000000a like we do others when SVM is not exposed to the guest. Also sanitize on Intel like we do for other invalid leafs.

File:
1 edited

Legend:

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

    r79806 r79830  
    37413741     *        EDX - SVM Feature identification.
    37423742     */
    3743     pExtFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, UINT32_C(0x80000001), 0);
    3744     if (   pExtFeatureLeaf
    3745         && (pExtFeatureLeaf->uEcx & X86_CPUID_AMD_FEATURE_ECX_SVM)
    3746         && pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
    3747     {
    3748         PCPUMCPUIDLEAF pSvmFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, 0x8000000a, 0);
    3749         if (pSvmFeatureLeaf)
    3750         {
    3751             pSvmFeatureLeaf->uEax  = 0x1;
    3752             pSvmFeatureLeaf->uEbx  = 0x8000;                                        /** @todo figure out virtual NASID. */
    3753             pSvmFeatureLeaf->uEcx  = 0;
    3754             pSvmFeatureLeaf->uEdx &= (  X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE         /** @todo Support other SVM features */
    3755                                       | X86_CPUID_SVM_FEATURE_EDX_FLUSH_BY_ASID
    3756                                       | X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSISTS);
     3743    if (pCpum->GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD)
     3744    {
     3745        pExtFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, UINT32_C(0x80000001), 0);
     3746        if (   pExtFeatureLeaf
     3747            && (pExtFeatureLeaf->uEcx & X86_CPUID_AMD_FEATURE_ECX_SVM))
     3748        {
     3749            PCPUMCPUIDLEAF pSvmFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, 0x8000000a, 0);
     3750            if (pSvmFeatureLeaf)
     3751            {
     3752                pSvmFeatureLeaf->uEax  = 0x1;
     3753                pSvmFeatureLeaf->uEbx  = 0x8000;                                        /** @todo figure out virtual NASID. */
     3754                pSvmFeatureLeaf->uEcx  = 0;
     3755                pSvmFeatureLeaf->uEdx &= (  X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE         /** @todo Support other SVM features */
     3756                                          | X86_CPUID_SVM_FEATURE_EDX_FLUSH_BY_ASID
     3757                                          | X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSISTS);
     3758            }
     3759            else
     3760            {
     3761                /* Should never happen. */
     3762                LogRel(("CPUM: Warning! Expected CPUID leaf 0x8000000a not present! SVM features not exposed to the guest\n"));
     3763                cpumR3CpuIdZeroLeaf(pCpum, UINT32_C(0x8000000a));
     3764            }
    37573765        }
    37583766        else
    37593767        {
    3760             LogRel(("CPUM: Warning! Expected CPUID leaf 0x8000000a not present! SVM features not exposed to the guest\n"));
     3768            /* If SVM is not supported, this is reserved, zero out. */
    37613769            cpumR3CpuIdZeroLeaf(pCpum, UINT32_C(0x8000000a));
    37623770        }
     3771    }
     3772    else
     3773    {
     3774        /* Cpuid 0x8000000a: Reserved on Intel.
     3775         * We zero this since we don't know what it may have been used for.
     3776         */
     3777        cpumR3CpuIdZeroLeaf(pCpum, UINT32_C(0x8000000a));
    37633778    }
    37643779
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