Changeset 7494 in vbox for trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
- Timestamp:
- Mar 19, 2008 9:11:21 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
r7478 r7494 122 122 { 123 123 int rc; 124 RTR0MEMOBJ pScatchMemObj;125 void *pvScatchPage;126 RTHCPHYS pScatchPagePhys;127 124 128 125 memset(&HWACCMR0Globals, 0, sizeof(HWACCMR0Globals)); 129 126 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);138 127 139 128 #ifdef RT_OS_WINDOWS /* kernel panics on Linux; disabled for now */ … … 204 193 HWACCMR0Globals.vmx.msr.vmx_cr4_fixed1 = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED1); 205 194 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); 206 212 207 213 /* Make sure we don't get rescheduled to another cpu during this probe. */ … … 209 215 210 216 /* 211 * Check CR4.VMXE 212 */ 213 HWACCMR0Globals.vmx.hostCR4 = ASMGetCR4(); 217 * Check CR4.VMXE 218 */ 214 219 if (!(HWACCMR0Globals.vmx.hostCR4 & X86_CR4_VMXE)) 215 220 { … … 220 225 } 221 226 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 == 64226 227 /* Enter VMX Root Mode */ 227 228 rc = VMXEnable(pScatchPagePhys); … … 239 240 else 240 241 VMXDisable(); 241 #endif 242 242 243 /* 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) */ 243 244 ASMSetCR4(HWACCMR0Globals.vmx.hostCR4); 244 245 245 ASMSetFlags(fFlags); 246 247 RTR0MemObjFree(pScatchMemObj, false); 248 #endif 246 249 } 247 250 else … … 306 309 #endif /* RT_OS_WINDOWS */ 307 310 308 RTR0MemObjFree(pScatchMemObj, false);309 311 return VINF_SUCCESS; 310 312 }
Note:
See TracChangeset
for help on using the changeset viewer.