VirtualBox

Ignore:
Timestamp:
Sep 8, 2008 9:52:30 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
36191
Message:

Grey out the VT-x/AMD-V checkbox if the CPU is not capable of either.
Disabled by default for the Mac version (pending VT-x work).

Same goes for PAE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsGeneral.cpp

    r11497 r12213  
    2424#include "VBoxGlobal.h"
    2525#include "VBoxProblemReporter.h"
     26#include <iprt/asm.h>
     27#include <VBox/x86.h>
    2628
    2729#include <QDir>
     
    203205    mCbApic->setChecked (biosSettings.GetIOAPICEnabled());
    204206
     207    /*
     208     * Check for VT-x and AMD-V capabilities.
     209     * This is a best effort check. A full check requires ring-0 access (msrs).
     210     */
     211    bool fVTxAMDVSupported = false;
     212    bool fPAESupported = false;
     213
     214    if (ASMHasCpuId())
     215    {
     216        uint32_t u32FeaturesECX;
     217        uint32_t u32Dummy;
     218        uint32_t u32FeaturesEDX;
     219        uint32_t u32VendorEBX, u32VendorECX, u32VendorEDX, u32AMDFeatureEDX, u32AMDFeatureECX;
     220
     221        ASMCpuId(0, &u32Dummy, &u32VendorEBX, &u32VendorECX, &u32VendorEDX);
     222        ASMCpuId(1, &u32Dummy, &u32Dummy, &u32FeaturesECX, &u32FeaturesEDX);
     223        /* Query AMD features. */
     224        ASMCpuId(0x80000001, &u32Dummy, &u32Dummy, &u32AMDFeatureECX, &u32AMDFeatureEDX);
     225
     226        fPAESupported = !!(u32FeaturesEDX & X86_CPUID_FEATURE_EDX_PAE);
     227
     228        if (    u32VendorEBX == X86_CPUID_VENDOR_INTEL_EBX
     229            &&  u32VendorECX == X86_CPUID_VENDOR_INTEL_ECX
     230            &&  u32VendorEDX == X86_CPUID_VENDOR_INTEL_EDX
     231           )
     232        {
     233            if (    (u32FeaturesECX & X86_CPUID_FEATURE_ECX_VMX)
     234                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     235                 && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     236               )
     237            {
     238                fVTxAMDVSupported = true;
     239            }
     240        }
     241        else
     242        if (    u32VendorEBX == X86_CPUID_VENDOR_AMD_EBX
     243            &&  u32VendorECX == X86_CPUID_VENDOR_AMD_ECX
     244            &&  u32VendorEDX == X86_CPUID_VENDOR_AMD_EDX
     245           )
     246        {
     247            if (   (u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
     248                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
     249                && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     250               )
     251            {
     252                fVTxAMDVSupported = true;
     253            }
     254        }
     255    }
     256#ifdef Q_WS_MAC
     257    /* Not currently available on the Mac. */
     258    fVTxAMDVSupported = false;
     259#endif
     260    mCbVirt->setEnabled(fVTxAMDVSupported);
     261   
    205262    /* VT-x/AMD-V */
    206263    aMachine.GetHWVirtExEnabled() == KTSBool_True ?
     
    209266
    210267    /* PAE/NX */
     268    mCbPae->setEnabled(fPAESupported);
    211269    mCbPae->setChecked (aMachine.GetPAEEnabled());
    212270
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