VirtualBox

Changeset 56558 in vbox


Ignore:
Timestamp:
Jun 19, 2015 12:05:26 PM (9 years ago)
Author:
vboxsync
Message:

SUPDrv-darwin.cpp: CR4.VMXE fix after host_vmxon issue.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp

    r56493 r56558  
    39283928 *          (centaur) CPU.
    39293929 *
    3930  * @param   pSession        The session handle.
    39313930 * @param   pfCaps          Where to store the capabilities.
    39323931 */
    3933 SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps)
     3932int VBOXCALL supdrvQueryVTCapsInternal(uint32_t *pfCaps)
    39343933{
    39353934    int  rc = VERR_UNSUPPORTED_CPU;
     
    39403939     * Input validation.
    39413940     */
    3942     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    39433941    AssertPtrReturn(pfCaps, VERR_INVALID_POINTER);
    39443942
     
    40214019        SUPR0Printf(("WARNING! CR4 hints SMX mode but your CPU is too secretive. Proceeding anyway... We wish you good luck!\n"));
    40224020    return rc;
     4021}
     4022
     4023/**
     4024 * Queries the AMD-V and VT-x capabilities of the calling CPU.
     4025 *
     4026 * @returns VBox status code.
     4027 * @retval  VERR_VMX_NO_VMX
     4028 * @retval  VERR_VMX_MSR_ALL_VMXON_DISABLED
     4029 * @retval  VERR_VMX_MSR_VMXON_DISABLED
     4030 * @retval  VERR_VMX_MSR_LOCKING_FAILED
     4031 * @retval  VERR_SVM_NO_SVM
     4032 * @retval  VERR_SVM_DISABLED
     4033 * @retval  VERR_UNSUPPORTED_CPU if not identifiable as an AMD, Intel or VIA
     4034 *          (centaur) CPU.
     4035 *
     4036 * @param   pSession        The session handle.
     4037 * @param   pfCaps          Where to store the capabilities.
     4038 */
     4039SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps)
     4040{
     4041    /*
     4042     * Input validation.
     4043     */
     4044    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     4045    AssertPtrReturn(pfCaps, VERR_INVALID_POINTER);
     4046
     4047    /*
     4048     * Call common worker.
     4049     */
     4050    return supdrvQueryVTCapsInternal(pfCaps);
    40234051}
    40244052
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r56293 r56558  
    942942uint32_t VBOXCALL supdrvSessionRetain(PSUPDRVSESSION pSession);
    943943uint32_t VBOXCALL supdrvSessionRelease(PSUPDRVSESSION pSession);
     944int VBOXCALL    supdrvQueryVTCapsInternal(uint32_t *pfCaps);
    944945
    945946/* SUPDrvGip.cpp */
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r56375 r56558  
    902902
    903903
     904#ifdef VBOX_WITH_HOST_VMX
     905/**
     906 * For cleaning up the mess we left behind on Yosemite with 4.3.28 and earlier.
     907 *
     908 * We ASSUME VT-x is supported by the CPU.
     909 *
     910 * @param   idCpu       Unused.
     911 * @param   pvUser1     Unused.
     912 * @param   pvUser2     Unused.
     913 */
     914static DECLCALLBACK(void) vboxdrvDarwinVmxEnableFix(RTCPUID idCpu, void *pvUser1, void *pvUser2)
     915{
     916    RTCCUINTREG uCr4 = ASMGetCR4();
     917    if (!(uCr4 & X86_CR4_VMXE))
     918    {
     919        uCr4 |= X86_CR4_VMXE;
     920        ASMSetCR4(uCr4);
     921    }
     922}
     923#endif
     924
     925
    904926/**
    905927 * @copydoc SUPR0EnableVTx
     
    919941        if (fEnable)
    920942        {
     943            /*
     944             * We screwed up on Yosemite and didn't notice that we weren't
     945             * calling host_vmxon.  CR4.VMXE may therefor have been disabled
     946             * by us.  So, first time around we make sure it's set so we won't
     947             * crash in the pre-4.3.28/5.0RC1 upgrade scenario.
     948             */
     949            static bool volatile g_fDoneCleanup = false;
     950            if (!g_fDoneCleanup)
     951            {
     952                if (version_major == 14 /* 14 = 10.10 = yosemite */)
     953                {
     954                    uint32_t fCaps;
     955                    int rc = supdrvQueryVTCapsInternal(&fCaps);
     956                    if (RT_SUCCESS(rc))
     957                    {
     958                        if (fCaps & SUPVTCAPS_VT_X)
     959                            rc = RTMpOnAll(vboxdrvDarwinVmxEnableFix, NULL, NULL);
     960                        else
     961                            rc = VERR_VMX_NO_VMX;
     962                    }
     963                    if (RT_FAILURE(rc))
     964                        return rc;
     965                }
     966                g_fDoneCleanup = true;
     967            }
     968
     969            /*
     970             * Call the kernel.
     971             */
    921972            rc = host_vmxon(false /* exclusive */);
    922973            if (rc == VMX_OK)
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