Changeset 43469 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Sep 28, 2012 3:40:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r43468 r43469 294 294 if (pVM->hm.s.vmx.msr.vmx_proc_ctls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_USE_MSR_BITMAPS) 295 295 { 296 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjM SRBitmap, PAGE_SIZE, false /* fExecutable */);296 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjMsrBitmap, PAGE_SIZE, false /* fExecutable */); 297 297 AssertRC(rc); 298 298 if (RT_FAILURE(rc)) 299 299 return rc; 300 300 301 pVCpu->hm.s.vmx.pvM SRBitmap = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjMSRBitmap);302 pVCpu->hm.s.vmx.HCPhysM SRBitmap = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjMSRBitmap, 0);303 memset(pVCpu->hm.s.vmx.pvM SRBitmap, 0xff, PAGE_SIZE);301 pVCpu->hm.s.vmx.pvMsrBitmap = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjMsrBitmap); 302 pVCpu->hm.s.vmx.HCPhysMsrBitmap = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjMsrBitmap, 0); 303 memset(pVCpu->hm.s.vmx.pvMsrBitmap, 0xff, PAGE_SIZE); 304 304 } 305 305 306 306 #ifdef VBOX_WITH_AUTO_MSR_LOAD_RESTORE 307 307 /* Allocate one page for the guest MSR load area (for preloading guest MSRs during the world switch). */ 308 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjGuestM SR, PAGE_SIZE, false /* fExecutable */);308 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjGuestMsr, PAGE_SIZE, false /* fExecutable */); 309 309 AssertRC(rc); 310 310 if (RT_FAILURE(rc)) 311 311 return rc; 312 312 313 pVCpu->hm.s.vmx.pvGuestM SR = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjGuestMSR);314 pVCpu->hm.s.vmx.HCPhysGuestM SR = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjGuestMSR, 0);315 Assert(!(pVCpu->hm.s.vmx.HCPhysGuestM SR& 0xf));316 memset(pVCpu->hm.s.vmx.pvGuestM SR, 0, PAGE_SIZE);313 pVCpu->hm.s.vmx.pvGuestMsr = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjGuestMsr); 314 pVCpu->hm.s.vmx.HCPhysGuestMsr = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjGuestMsr, 0); 315 Assert(!(pVCpu->hm.s.vmx.HCPhysGuestMsr & 0xf)); 316 memset(pVCpu->hm.s.vmx.pvGuestMsr, 0, PAGE_SIZE); 317 317 318 318 /* Allocate one page for the host MSR load area (for restoring host MSRs after the world switch back). */ 319 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjHostM SR, PAGE_SIZE, false /* fExecutable */);319 rc = RTR0MemObjAllocCont(&pVCpu->hm.s.vmx.hMemObjHostMsr, PAGE_SIZE, false /* fExecutable */); 320 320 AssertRC(rc); 321 321 if (RT_FAILURE(rc)) 322 322 return rc; 323 323 324 pVCpu->hm.s.vmx.pvHostM SR = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjHostMSR);325 pVCpu->hm.s.vmx.HCPhysHostM SR = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjHostMSR, 0);326 Assert(!(pVCpu->hm.s.vmx.HCPhysHostM SR& 0xf));327 memset(pVCpu->hm.s.vmx.pvHostM SR, 0, PAGE_SIZE);324 pVCpu->hm.s.vmx.pvHostMsr = (uint8_t *)RTR0MemObjAddress(pVCpu->hm.s.vmx.hMemObjHostMsr); 325 pVCpu->hm.s.vmx.HCPhysHostMsr = RTR0MemObjGetPagePhysAddr(pVCpu->hm.s.vmx.hMemObjHostMsr, 0); 326 Assert(!(pVCpu->hm.s.vmx.HCPhysHostMsr & 0xf)); 327 memset(pVCpu->hm.s.vmx.pvHostMsr, 0, PAGE_SIZE); 328 328 #endif /* VBOX_WITH_AUTO_MSR_LOAD_RESTORE */ 329 329 … … 366 366 pVCpu->hm.s.vmx.HCPhysVAPIC = 0; 367 367 } 368 if (pVCpu->hm.s.vmx.hMemObjM SRBitmap != NIL_RTR0MEMOBJ)369 { 370 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjM SRBitmap, false);371 pVCpu->hm.s.vmx.hMemObjM SRBitmap = NIL_RTR0MEMOBJ;372 pVCpu->hm.s.vmx.pvM SRBitmap = 0;373 pVCpu->hm.s.vmx.HCPhysM SRBitmap = 0;368 if (pVCpu->hm.s.vmx.hMemObjMsrBitmap != NIL_RTR0MEMOBJ) 369 { 370 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjMsrBitmap, false); 371 pVCpu->hm.s.vmx.hMemObjMsrBitmap = NIL_RTR0MEMOBJ; 372 pVCpu->hm.s.vmx.pvMsrBitmap = 0; 373 pVCpu->hm.s.vmx.HCPhysMsrBitmap = 0; 374 374 } 375 375 #ifdef VBOX_WITH_AUTO_MSR_LOAD_RESTORE 376 if (pVCpu->hm.s.vmx.hMemObjHostM SR!= NIL_RTR0MEMOBJ)377 { 378 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjHostM SR, false);379 pVCpu->hm.s.vmx.hMemObjHostM SR= NIL_RTR0MEMOBJ;380 pVCpu->hm.s.vmx.pvHostM SR= 0;381 pVCpu->hm.s.vmx.HCPhysHostM SR= 0;382 } 383 if (pVCpu->hm.s.vmx.hMemObjGuestM SR!= NIL_RTR0MEMOBJ)384 { 385 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjGuestM SR, false);386 pVCpu->hm.s.vmx.hMemObjGuestM SR= NIL_RTR0MEMOBJ;387 pVCpu->hm.s.vmx.pvGuestM SR= 0;388 pVCpu->hm.s.vmx.HCPhysGuestM SR= 0;376 if (pVCpu->hm.s.vmx.hMemObjHostMsr != NIL_RTR0MEMOBJ) 377 { 378 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjHostMsr, false); 379 pVCpu->hm.s.vmx.hMemObjHostMsr = NIL_RTR0MEMOBJ; 380 pVCpu->hm.s.vmx.pvHostMsr = 0; 381 pVCpu->hm.s.vmx.HCPhysHostMsr = 0; 382 } 383 if (pVCpu->hm.s.vmx.hMemObjGuestMsr != NIL_RTR0MEMOBJ) 384 { 385 RTR0MemObjFree(pVCpu->hm.s.vmx.hMemObjGuestMsr, false); 386 pVCpu->hm.s.vmx.hMemObjGuestMsr = NIL_RTR0MEMOBJ; 387 pVCpu->hm.s.vmx.pvGuestMsr = 0; 388 pVCpu->hm.s.vmx.HCPhysGuestMsr = 0; 389 389 } 390 390 #endif /* VBOX_WITH_AUTO_MSR_LOAD_RESTORE */ … … 570 570 if (pVM->hm.s.vmx.msr.vmx_proc_ctls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_USE_MSR_BITMAPS) 571 571 { 572 Assert(pVCpu->hm.s.vmx.HCPhysM SRBitmap);572 Assert(pVCpu->hm.s.vmx.HCPhysMsrBitmap); 573 573 val |= VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_USE_MSR_BITMAPS; 574 574 } … … 658 658 if (pVM->hm.s.vmx.msr.vmx_proc_ctls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_USE_MSR_BITMAPS) 659 659 { 660 Assert(pVCpu->hm.s.vmx.HCPhysM SRBitmap);661 662 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_MSR_BITMAP_FULL, pVCpu->hm.s.vmx.HCPhysM SRBitmap);660 Assert(pVCpu->hm.s.vmx.HCPhysMsrBitmap); 661 662 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_MSR_BITMAP_FULL, pVCpu->hm.s.vmx.HCPhysMsrBitmap); 663 663 AssertRC(rc); 664 664 … … 684 684 * Set the guest & host MSR load/store physical addresses. 685 685 */ 686 Assert(pVCpu->hm.s.vmx.HCPhysGuestM SR);687 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMENTRY_MSR_LOAD_FULL, pVCpu->hm.s.vmx.HCPhysGuestM SR);686 Assert(pVCpu->hm.s.vmx.HCPhysGuestMsr); 687 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMENTRY_MSR_LOAD_FULL, pVCpu->hm.s.vmx.HCPhysGuestMsr); 688 688 AssertRC(rc); 689 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMEXIT_MSR_STORE_FULL, pVCpu->hm.s.vmx.HCPhysGuestM SR);689 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMEXIT_MSR_STORE_FULL, pVCpu->hm.s.vmx.HCPhysGuestMsr); 690 690 AssertRC(rc); 691 Assert(pVCpu->hm.s.vmx.HCPhysHostM SR);692 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMEXIT_MSR_LOAD_FULL, pVCpu->hm.s.vmx.HCPhysHostM SR);691 Assert(pVCpu->hm.s.vmx.HCPhysHostMsr); 692 rc = VMXWriteVMCS64(VMX_VMCS_CTRL_VMEXIT_MSR_LOAD_FULL, pVCpu->hm.s.vmx.HCPhysHostMsr); 693 693 AssertRC(rc); 694 694 #endif /* VBOX_WITH_AUTO_MSR_LOAD_RESTORE */ … … 808 808 { 809 809 unsigned ulBit; 810 uint8_t *pvM SRBitmap = (uint8_t *)pVCpu->hm.s.vmx.pvMSRBitmap;810 uint8_t *pvMsrBitmap = (uint8_t *)pVCpu->hm.s.vmx.pvMsrBitmap; 811 811 812 812 /* … … 827 827 /* AMD Sixth Generation x86 Processor MSRs */ 828 828 ulBit = (ulMSR - 0xC0000000); 829 pvM SRBitmap += 0x400;829 pvMsrBitmap += 0x400; 830 830 } 831 831 else … … 837 837 Assert(ulBit <= 0x1fff); 838 838 if (fRead) 839 ASMBitClear(pvM SRBitmap, ulBit);839 ASMBitClear(pvMsrBitmap, ulBit); 840 840 else 841 ASMBitSet(pvM SRBitmap, ulBit);841 ASMBitSet(pvMsrBitmap, ulBit); 842 842 843 843 if (fWrite) 844 ASMBitClear(pvM SRBitmap + 0x800, ulBit);844 ASMBitClear(pvMsrBitmap + 0x800, ulBit); 845 845 else 846 ASMBitSet(pvM SRBitmap + 0x800, ulBit);846 ASMBitSet(pvMsrBitmap + 0x800, ulBit); 847 847 } 848 848 … … 1356 1356 * the world switch back to the host. 1357 1357 */ 1358 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvHostM SR;1358 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvHostMsr; 1359 1359 unsigned idxMsr = 0; 1360 1360 … … 2152 2152 * during VM-entry and restored into the VM-exit store area during VM-exit. 2153 2153 */ 2154 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvGuestM SR;2154 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvGuestMsr; 2155 2155 unsigned idxMsr = 0; 2156 2156 … … 2206 2206 } 2207 2207 2208 pVCpu->hm.s.vmx.cCachedM SRs = idxMsr;2208 pVCpu->hm.s.vmx.cCachedMsrs = idxMsr; 2209 2209 2210 2210 rc = VMXWriteVMCS(VMX_VMCS_CTRL_ENTRY_MSR_LOAD_COUNT, idxMsr); … … 2405 2405 * Save the possibly changed MSRs that we automatically restore and save during a world switch. 2406 2406 */ 2407 for (unsigned i = 0; i < pVCpu->hm.s.vmx.cCachedM SRs; i++)2408 { 2409 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvGuestM SR;2407 for (unsigned i = 0; i < pVCpu->hm.s.vmx.cCachedMsrs; i++) 2408 { 2409 PVMXMSR pMsr = (PVMXMSR)pVCpu->hm.s.vmx.pvGuestMsr; 2410 2410 pMsr += i; 2411 2411
Note:
See TracChangeset
for help on using the changeset viewer.