~ubuntu-branches/ubuntu/natty/virtualbox-ose/natty-updates

« back to all changes in this revision

Viewing changes to src/VBox/VMM/HWACCM.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-03-11 17:16:37 UTC
  • mfrom: (0.3.4 upstream) (0.4.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100311171637-43z64ia3ccpj8vqn
Tags: 3.1.4-dfsg-2ubuntu1
* Merge from Debian unstable (LP: #528561), remaining changes:
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
  - Replace *-source packages with transitional packages for *-dkms
* Fix crash in vboxvideo_drm with kernel 2.6.33 / backported drm code
  (LP: #535297)
* Add a list of linux-headers packages to the apport hook
* Update debian/patches/u02-lp-integration.dpatch with a
  DEP-3 compliant header
* Add ${misc:Depends} to virtualbox-ose-source and virtualbox-ose-guest-source
  Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <VBox/log.h>
46
46
#include <iprt/asm.h>
47
47
#include <iprt/string.h>
 
48
#include <iprt/env.h>
48
49
#include <iprt/thread.h>
49
50
 
50
51
/*******************************************************************************
652
653
{
653
654
    int rc;
654
655
 
 
656
    /* Hack to allow users to work around broken BIOSes that incorrectly set EFER.SVME, which makes us believe somebody else
 
657
     * is already using AMD-V. 
 
658
     */
 
659
    if (    !pVM->hwaccm.s.vmx.fSupported
 
660
        &&  !pVM->hwaccm.s.svm.fSupported
 
661
        &&  pVM->hwaccm.s.lLastError == VERR_SVM_IN_USE /* implies functional AMD-V */
 
662
        &&  RTEnvGet("VBOX_HWVIRTEX_IGNORE_SVM_IN_USE"))
 
663
    {
 
664
        LogRel(("HWACCM: VBOX_HWVIRTEX_IGNORE_SVM_IN_USE active!\n"));
 
665
        pVM->hwaccm.s.svm.fSupported        = true;
 
666
        pVM->hwaccm.s.svm.fIgnoreInUseError = true;
 
667
    }
 
668
    else
655
669
    if (    !pVM->hwaccm.s.vmx.fSupported
656
670
        &&  !pVM->hwaccm.s.svm.fSupported)
657
671
    {
658
672
        LogRel(("HWACCM: No VT-x or AMD-V CPU extension found. Reason %Rrc\n", pVM->hwaccm.s.lLastError));
659
673
        LogRel(("HWACCM: VMX MSR_IA32_FEATURE_CONTROL=%RX64\n", pVM->hwaccm.s.vmx.msr.feature_ctrl));
660
674
        if (VMMIsHwVirtExtForced(pVM))
661
 
            return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is not available.");
 
675
        {
 
676
            switch (pVM->hwaccm.s.lLastError)
 
677
            {
 
678
            case VERR_VMX_NO_VMX:
 
679
                return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is not available.");
 
680
            case VERR_VMX_IN_VMX_ROOT_MODE:
 
681
                return VM_SET_ERROR(pVM, VERR_VMX_IN_VMX_ROOT_MODE, "VT-x is being used by another hypervisor.");
 
682
            case VERR_SVM_IN_USE:
 
683
                return VM_SET_ERROR(pVM, VERR_SVM_IN_USE, "AMD-V is being used by another hypervisor.");
 
684
            case VERR_SVM_NO_SVM:
 
685
                return VM_SET_ERROR(pVM, VERR_SVM_NO_SVM, "AMD-V is not available.");
 
686
            case VERR_SVM_DISABLED:
 
687
                return VM_SET_ERROR(pVM, VERR_SVM_DISABLED, "AMD-V is disabled in the BIOS.");
 
688
            default:
 
689
                return pVM->hwaccm.s.lLastError;
 
690
            }
 
691
        }
662
692
        return VINF_SUCCESS;
663
693
    }
664
694
 
1097
1127
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
1098
1128
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NXE);
1099
1129
                }
 
1130
                else
 
1131
                /* Turn on NXE if PAE has been enabled *and* the host has turned on NXE (we reuse the host EFER in the switcher) */
 
1132
                /* Todo: this needs to be fixed properly!! */
 
1133
                if (    CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE)
 
1134
                    &&  (pVM->hwaccm.s.vmx.hostEFER & MSR_K6_EFER_NXE))
 
1135
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NXE);
 
1136
 
1100
1137
                LogRel((pVM->hwaccm.s.fAllow64BitGuests
1101
1138
                        ? "HWACCM: 32-bit and 64-bit guests supported.\n"
1102
1139
                        : "HWACCM: 32-bit guests supported.\n"));
1237
1274
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NXE);
1238
1275
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
1239
1276
                }
 
1277
                else
 
1278
                /* Turn on NXE if PAE has been enabled. */
 
1279
                if (CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
 
1280
                    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NXE);
1240
1281
#endif
1241
1282
                LogRel((pVM->hwaccm.s.fAllow64BitGuests
1242
1283
                        ? "HWACCM:    32-bit and 64-bit guest supported.\n"