VirtualBox

Ignore:
Timestamp:
Mar 19, 2008 9:11:21 AM (17 years ago)
Author:
vboxsync
Message:

Cleaned up

File:
1 edited

Legend:

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

    r7478 r7494  
    122122{
    123123    int        rc;
    124     RTR0MEMOBJ pScatchMemObj;
    125     void      *pvScatchPage;
    126     RTHCPHYS   pScatchPagePhys;
    127124
    128125    memset(&HWACCMR0Globals, 0, sizeof(HWACCMR0Globals));
    129126    HWACCMR0Globals.enmHwAccmState = HWACCMSTATE_UNINITIALIZED;
    130 
    131     rc = RTR0MemObjAllocCont(&pScatchMemObj, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
    132     if (RT_FAILURE(rc))
    133         return rc;
    134 
    135     pvScatchPage    = RTR0MemObjAddress(pScatchMemObj);
    136     pScatchPagePhys = RTR0MemObjGetPagePhysAddr(pScatchMemObj, 0);
    137     memset(pvScatchPage, 0, PAGE_SIZE);
    138127
    139128#ifdef RT_OS_WINDOWS /* kernel panics on Linux; disabled for now */
     
    204193                        HWACCMR0Globals.vmx.msr.vmx_cr4_fixed1  = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED1);
    205194                        HWACCMR0Globals.vmx.msr.vmx_vmcs_enum   = ASMRdMsr(MSR_IA32_VMX_VMCS_ENUM);
     195                        HWACCMR0Globals.vmx.hostCR4             = ASMGetCR4();
     196
     197#if HC_ARCH_BITS == 64
     198                        RTR0MEMOBJ pScatchMemObj;
     199                        void      *pvScatchPage;
     200                        RTHCPHYS   pScatchPagePhys;
     201
     202                        rc = RTR0MemObjAllocCont(&pScatchMemObj, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
     203                        if (RT_FAILURE(rc))
     204                            return rc;
     205
     206                        pvScatchPage    = RTR0MemObjAddress(pScatchMemObj);
     207                        pScatchPagePhys = RTR0MemObjGetPagePhysAddr(pScatchMemObj, 0);
     208                        memset(pvScatchPage, 0, PAGE_SIZE);
     209
     210                        /* Set revision dword at the beginning of the structure. */
     211                        *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(HWACCMR0Globals.vmx.msr.vmx_basic_info);
    206212
    207213                        /* Make sure we don't get rescheduled to another cpu during this probe. */
     
    209215
    210216                        /*
    211                         * Check CR4.VMXE
    212                         */
    213                         HWACCMR0Globals.vmx.hostCR4 = ASMGetCR4();
     217                         * Check CR4.VMXE
     218                         */
    214219                        if (!(HWACCMR0Globals.vmx.hostCR4 & X86_CR4_VMXE))
    215220                        {
     
    220225                        }
    221226
    222                         /* Set revision dword at the beginning of the structure. */
    223                         *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(HWACCMR0Globals.vmx.msr.vmx_basic_info);
    224 
    225 #if HC_ARCH_BITS == 64
    226227                        /* Enter VMX Root Mode */
    227228                        rc = VMXEnable(pScatchPagePhys);
     
    239240                        else
    240241                            VMXDisable();
    241 #endif
     242
    242243                        /* Restore CR4 again; don't leave the X86_CR4_VMXE flag set if it wasn't so before (some software could incorrectly think it's in VMX mode) */
    243244                        ASMSetCR4(HWACCMR0Globals.vmx.hostCR4);
    244 
    245245                        ASMSetFlags(fFlags);
     246
     247                        RTR0MemObjFree(pScatchMemObj, false);
     248#endif
    246249                    }
    247250                    else
     
    306309#endif /* RT_OS_WINDOWS */
    307310
    308     RTR0MemObjFree(pScatchMemObj, false);
    309311    return VINF_SUCCESS;
    310312}
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