VirtualBox

Changeset 14523 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 24, 2008 2:57:18 PM (16 years ago)
Author:
vboxsync
Message:

Cache the features reported by GetProcessorFeature.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostImpl.cpp

    r14521 r14523  
    193193    mHostPowerService = new HostPowerService (mParent);
    194194#endif
     195
     196    /* Cache the features reported by GetProcessorFeature. */
     197    fVTxAMDVSupported = false;
     198    fLongModeSupported = false;
     199    fPAESupported = false;
     200
     201    if (ASMHasCpuId())
     202    {
     203        uint32_t u32FeaturesECX;
     204        uint32_t u32Dummy;
     205        uint32_t u32FeaturesEDX;
     206        uint32_t u32VendorEBX, u32VendorECX, u32VendorEDX, u32AMDFeatureEDX, u32AMDFeatureECX;
     207
     208        ASMCpuId (0, &u32Dummy, &u32VendorEBX, &u32VendorECX, &u32VendorEDX);
     209        ASMCpuId (1, &u32Dummy, &u32Dummy, &u32FeaturesECX, &u32FeaturesEDX);
     210        /* Query AMD features. */
     211        ASMCpuId (0x80000001, &u32Dummy, &u32Dummy, &u32AMDFeatureECX, &u32AMDFeatureEDX);
     212
     213        fLongModeSupported = !!(u32AMDFeatureEDX & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE);
     214        fPAESupported      = !!(u32FeaturesEDX & X86_CPUID_FEATURE_EDX_PAE);
     215
     216        if (    u32VendorEBX == X86_CPUID_VENDOR_INTEL_EBX
     217            &&  u32VendorECX == X86_CPUID_VENDOR_INTEL_ECX
     218            &&  u32VendorEDX == X86_CPUID_VENDOR_INTEL_EDX
     219           )
     220        {
     221            if (    (u32FeaturesECX & X86_CPUID_FEATURE_ECX_VMX)
     222                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     223                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     224               )
     225                fVTxAMDVSupported = true;
     226        }
     227        else
     228        if (    u32VendorEBX == X86_CPUID_VENDOR_AMD_EBX
     229            &&  u32VendorECX == X86_CPUID_VENDOR_AMD_ECX
     230            &&  u32VendorEDX == X86_CPUID_VENDOR_AMD_EDX
     231           )
     232        {
     233            if (   (u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
     234                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     235                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     236               )
     237                fVTxAMDVSupported = true;
     238        }
     239    }
     240
    195241    setReady(true);
    196242    return S_OK;
     
    11891235    AutoWriteLock alock (this);
    11901236    CHECK_READY();
    1191 
    1192     bool fVTxAMDVSupported = false;
    1193     bool fLongModeSupported = false;
    1194     bool fPAESupported = false;
    1195 
    1196     if (ASMHasCpuId())
    1197     {
    1198         uint32_t u32FeaturesECX;
    1199         uint32_t u32Dummy;
    1200         uint32_t u32FeaturesEDX;
    1201         uint32_t u32VendorEBX, u32VendorECX, u32VendorEDX, u32AMDFeatureEDX, u32AMDFeatureECX;
    1202 
    1203         ASMCpuId (0, &u32Dummy, &u32VendorEBX, &u32VendorECX, &u32VendorEDX);
    1204         ASMCpuId (1, &u32Dummy, &u32Dummy, &u32FeaturesECX, &u32FeaturesEDX);
    1205         /* Query AMD features. */
    1206         ASMCpuId (0x80000001, &u32Dummy, &u32Dummy, &u32AMDFeatureECX, &u32AMDFeatureEDX);
    1207 
    1208         fLongModeSupported = !!(u32AMDFeatureEDX & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE);
    1209         fPAESupported      = !!(u32FeaturesEDX & X86_CPUID_FEATURE_EDX_PAE);
    1210 
    1211         if (    u32VendorEBX == X86_CPUID_VENDOR_INTEL_EBX
    1212             &&  u32VendorECX == X86_CPUID_VENDOR_INTEL_ECX
    1213             &&  u32VendorEDX == X86_CPUID_VENDOR_INTEL_EDX
    1214            )
    1215         {
    1216             if (    (u32FeaturesECX & X86_CPUID_FEATURE_ECX_VMX)
    1217                  && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
    1218                  && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
    1219                )
    1220                 fVTxAMDVSupported = true;
    1221         }
    1222         else
    1223         if (    u32VendorEBX == X86_CPUID_VENDOR_AMD_EBX
    1224             &&  u32VendorECX == X86_CPUID_VENDOR_AMD_ECX
    1225             &&  u32VendorEDX == X86_CPUID_VENDOR_AMD_EDX
    1226            )
    1227         {
    1228             if (   (u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
    1229                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
    1230                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
    1231                )
    1232                 fVTxAMDVSupported = true;
    1233         }
    1234     }
    12351237
    12361238    switch (feature)
  • trunk/src/VBox/Main/include/HostImpl.h

    r14521 r14523  
    178178#endif /* VBOX_WITH_USB */
    179179
     180    /* Features that can be queried with GetProcessorFeature */
     181    bool fVTxAMDVSupported, fLongModeSupported, fPAESupported;
     182
    180183    HostPowerService *mHostPowerService;
    181184};
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