VirtualBox

Changeset 17246 in vbox for trunk/src/VBox/VMM/HWACCM.cpp


Ignore:
Timestamp:
Mar 2, 2009 12:31:50 PM (16 years ago)
Author:
vboxsync
Message:

Allow mixing of VT-x and software virtualization. (untested so far)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCM.cpp

    r16422 r17246  
    227227        if (!pVM->hwaccm.s.fAllowed)
    228228# endif
    229             return VM_SET_ERROR(pVM, VERR_INVALID_PARAMETER, "64-bit guest support was requested without also enabling VT-x.");
     229            return VM_SET_ERROR(pVM, VERR_INVALID_PARAMETER, "64-bit guest support was requested without also enabling HWVirtEx (VT-x/AMD-V).");
    230230    }
    231231#else
     
    447447    }
    448448
    449     /*
    450      * Note that we have a global setting for VT-x/AMD-V usage. VMX root mode changes the way the CPU operates. Our 64 bits switcher will trap
    451      * because it turns off paging, which is not allowed in VMX root mode.
    452      *
    453      * To simplify matters we'll just force all running VMs to either use raw or VT-x mode. No mixing allowed in the VT-x case.
    454      * There's no such problem with AMD-V. (@todo)
    455      *
    456      */
    457     /* If we enabled or disabled hwaccm mode, then it can't be changed until all the VMs are shutdown. */
    458     rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_HWACC_ENABLE, (pVM->hwaccm.s.fAllowed) ? HWACCMSTATE_ENABLED : HWACCMSTATE_DISABLED, NULL);
     449    if (!pVM->hwaccm.s.fAllowed)
     450        return VINF_SUCCESS;    /* nothing to do */
     451
     452    /* Enable VT-x or AMD-V on all host CPUs. */
     453    rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_HWACC_ENABLE, 0, NULL);
    459454    if (RT_FAILURE(rc))
    460455    {
    461456        LogRel(("HWACCMR3InitFinalize: SUPCallVMMR0Ex VMMR0_DO_HWACC_ENABLE failed with %Rrc\n", rc));
    462         LogRel(("HWACCMR3InitFinalize: disallowed %s of HWACCM\n", pVM->hwaccm.s.fAllowed ? "enabling" : "disabling"));
    463 
    464 #ifdef RT_OS_DARWIN
    465         /*
    466          * This is 100% fatal if we didn't prepare for a HwVirtExt setup because of
    467          * missing ring-0 allocations. For VMs that require HwVirtExt it doesn't normally
    468          * make sense to try run them in software mode, so fail that too.
    469          */
    470         if (VMMIsHwVirtExtForced(pVM))
    471             VM_SET_ERROR(pVM, rc, "An active VM already uses software virtualization. It is not allowed to "
    472                          "simultaneously use VT-x.");
    473         else
    474             VM_SET_ERROR(pVM, rc, "An active VM already uses Intel VT-x hardware acceleration. It is not "
    475                          "allowed to simultaneously use software virtualization.");
    476457        return rc;
    477 
    478 #else  /* !RT_OS_DARWIN */
    479 
    480         /* Invert the selection */
    481         pVM->hwaccm.s.fAllowed ^= 1;
    482         if (pVM->hwaccm.s.fAllowed)
    483         {
    484             if (pVM->hwaccm.s.vmx.fSupported)
    485                 VM_SET_ERROR(pVM, rc, "An active VM already uses Intel VT-x hardware acceleration. It is not allowed "
    486                                       "to simultaneously use software virtualization.\n");
    487             else
    488                 VM_SET_ERROR(pVM, rc, "An active VM already uses AMD-V hardware acceleration. It is not allowed to "
    489                                       "simultaneously use software virtualization.\n");
    490         }
    491         else
    492             VM_SET_ERROR(pVM, rc, "An active VM already uses software virtualization. It is not allowed to simultaneously "
    493                                   "use VT-x or AMD-V.\n");
    494         return rc;
    495 #endif /* !RT_OS_DARWIN */
    496     }
    497 
    498     if (pVM->hwaccm.s.fAllowed == false)
    499         return VINF_SUCCESS;    /* disabled */
    500 
     458    }
    501459    Assert(!pVM->fHWACCMEnabled || VMMIsHwVirtExtForced(pVM));
    502460
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