VirtualBox

Changeset 54650 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Mar 5, 2015 1:42:10 PM (10 years ago)
Author:
vboxsync
Message:

SUPDrv/VMMR0: properly handle the CR4 shadow register on Linux >= 4.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r54384 r54650  
    773773
    774774    /* Enable the VMX bit in CR4 if necessary. */
    775     RTCCUINTREG uCr4 = ASMGetCR4();
    776     if (!(uCr4 & X86_CR4_VMXE))
    777         ASMSetCR4(uCr4 | X86_CR4_VMXE);
     775    RTCCUINTREG uOldCr4 = SUPR0ChangeCR4(X86_CR4_VMXE, ~0);
    778776
    779777    /* Enter VMX root mode. */
    780778    int rc = VMXEnable(HCPhysCpuPage);
    781     if (RT_FAILURE(rc))
    782         ASMSetCR4(uCr4);
     779    if (   RT_FAILURE(rc)
     780        && !(uOldCr4 & X86_CR4_VMXE))
     781        SUPR0ChangeCR4(0, ~X86_CR4_VMXE);
    783782
    784783    /* Restore interrupts. */
     
    808807        /* Exit VMX root mode and clear the VMX bit in CR4. */
    809808        VMXDisable();
    810         ASMSetCR4(uHostCR4 & ~X86_CR4_VMXE);
     809        SUPR0ChangeCR4(0, ~X86_CR4_VMXE);
    811810        rc = VINF_SUCCESS;
    812811    }
     
    52165215    VMXDisable();
    52175216
    5218     ASMSetCR4(ASMGetCR4() & ~X86_CR4_VMXE);
     5217    SUPR0ChangeCR4(0, ~X86_CR4_VMXE);
    52195218
    52205219    CPUMSetHyperESP(pVCpu, VMMGetStackRC(pVCpu));
     
    52315230    /** @todo replace with hmR0VmxEnterRootMode() and hmR0VmxLeaveRootMode(). */
    52325231    /* Make sure the VMX instructions don't cause #UD faults. */
    5233     ASMSetCR4(ASMGetCR4() | X86_CR4_VMXE);
     5232    SUPR0ChangeCR4(X86_CR4_VMXE, ~0);
    52345233
    52355234    /* Re-enter VMX Root Mode */
     
    52375236    if (RT_FAILURE(rc2))
    52385237    {
    5239         ASMSetCR4(ASMGetCR4() & ~X86_CR4_VMXE);
     5238        SUPR0ChangeCR4(0, ~X86_CR4_VMXE);
    52405239        ASMSetFlags(uOldEflags);
    52415240        return rc2;
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