Changeset 2896 in vbox
- Timestamp:
- May 28, 2007 1:35:58 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/HWACCM.cpp
r2811 r2896 115 115 memset(pVM->hwaccm.s.vmx.pVMCS, 0, PAGE_SIZE); 116 116 117 /* Reuse those two pages for AMD SVM. (one is active; never both) */ 118 pVM->hwaccm.s.svm.pHState = pVM->hwaccm.s.vmx.pVMXON; 119 pVM->hwaccm.s.svm.pHStatePhys = pVM->hwaccm.s.vmx.pVMXONPhys; 120 pVM->hwaccm.s.svm.pVMCB = pVM->hwaccm.s.vmx.pVMCS; 121 pVM->hwaccm.s.svm.pVMCBPhys = pVM->hwaccm.s.vmx.pVMCSPhys; 122 123 /* Allocate one page for the SVM host control structure (used for vmsave/vmload). */ 124 pVM->hwaccm.s.svm.pVMCBHost = SUPContAlloc(1, &pVM->hwaccm.s.svm.pVMCBHostPhys); 125 if (pVM->hwaccm.s.svm.pVMCBHost == 0) 117 /* Allocate one page for the TSS we need for real mode emulation. */ 118 pVM->hwaccm.s.vmx.pRealModeTSS = (PVBOXTSS)SUPContAlloc(1, &pVM->hwaccm.s.vmx.pRealModeTSSPhys); 119 if (pVM->hwaccm.s.vmx.pRealModeTSS == 0) 126 120 { 127 121 AssertMsgFailed(("SUPContAlloc failed!!\n")); 128 122 return VERR_NO_MEMORY; 129 123 } 130 memset(pVM->hwaccm.s.svm.pVMCBHost, 0, PAGE_SIZE); 124 /* We initialize it properly later as we can reuse it for SVM */ 125 memset(pVM->hwaccm.s.vmx.pRealModeTSS, 0, PAGE_SIZE); 126 127 /* Reuse those three pages for AMD SVM. (one is active; never both) */ 128 pVM->hwaccm.s.svm.pHState = pVM->hwaccm.s.vmx.pVMXON; 129 pVM->hwaccm.s.svm.pHStatePhys = pVM->hwaccm.s.vmx.pVMXONPhys; 130 pVM->hwaccm.s.svm.pVMCB = pVM->hwaccm.s.vmx.pVMCS; 131 pVM->hwaccm.s.svm.pVMCBPhys = pVM->hwaccm.s.vmx.pVMCSPhys; 132 pVM->hwaccm.s.svm.pVMCBHost = pVM->hwaccm.s.vmx.pRealModeTSS; 133 pVM->hwaccm.s.svm.pVMCBHostPhys = pVM->hwaccm.s.vmx.pRealModeTSSPhys; 131 134 132 135 /* Allocate 12 KB for the IO bitmap (doesn't seem to be a way to convince SVM not to use it) */ … … 419 422 pVM->hwaccm.s.fInitialized = true; 420 423 424 /* The I/O bitmap starts right after the virtual interrupt redirection bitmap. Outside the TSS on purpose; the CPU will not check it 425 * for I/O operations. */ 426 pVM->hwaccm.s.vmx.pRealModeTSS->offIoBitmap = sizeof(*pVM->hwaccm.s.vmx.pRealModeTSS); 427 /* Bit set to 0 means redirection enabled. */ 428 memset(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap, 0x0, sizeof(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap)); 429 421 430 int rc = SUPCallVMMR0(pVM->pVMR0, VMMR0_DO_HWACC_SETUP_VM, NULL); 422 431 AssertRC(rc); … … 524 533 pVM->hwaccm.s.vmx.pVMCS = 0; 525 534 } 526 if (pVM->hwaccm.s. svm.pVMCBHost)527 { 528 SUPContFree(pVM->hwaccm.s. svm.pVMCBHost, 1);529 pVM->hwaccm.s. svm.pVMCBHost= 0;535 if (pVM->hwaccm.s.vmx.pRealModeTSS) 536 { 537 SUPContFree(pVM->hwaccm.s.vmx.pRealModeTSS, 1); 538 pVM->hwaccm.s.vmx.pRealModeTSS = 0; 530 539 } 531 540 if (pVM->hwaccm.s.svm.pIOBitmap) … … 595 604 /** @note The context supplied by REM is partial. If we add more checks here, be sure to verify that REM provides this info! */ 596 605 606 #ifndef HWACCM_VMX_EMULATE_ALL 597 607 /* Too early for VMX. */ 598 608 if (pCtx->idtr.pIdt == 0 || pCtx->idtr.cbIdt == 0 || pCtx->tr == 0) … … 608 618 if (!(pCtx->cr0 & X86_CR0_WRITE_PROTECT)) 609 619 return false; 620 #endif 610 621 611 622 if (pVM->hwaccm.s.vmx.fEnabled) … … 613 624 /* if bit N is set in cr0_fixed0, then it must be set in the guest's cr0. */ 614 625 mask = (uint32_t)pVM->hwaccm.s.vmx.msr.vmx_cr0_fixed0; 615 /* * @noteWe ignore the NE bit here on purpose; see vmmr0\hwaccmr0.cpp for details. */626 /* Note: We ignore the NE bit here on purpose; see vmmr0\hwaccmr0.cpp for details. */ 616 627 mask &= ~X86_CR0_NE; 617 628 #ifdef HWACCM_VMX_EMULATE_ALL 629 /* Note: We ignore the PE & PG bits here on purpose; we emulate real and protected mode without paging. */ 630 mask &= ~(X86_CR0_PG|X86_CR0_PE); 631 #endif 618 632 if ((pCtx->cr0 & mask) != mask) 619 633 return false; … … 638 652 return true; 639 653 } 640 #if 0641 else642 if (pVM->hwaccm.s.svm.fEnabled)643 {644 pVM->hwaccm.s.fActive = true;645 return true;646 }647 #endif648 654 649 655 return false; -
trunk/src/VBox/VMM/HWACCMInternal.h
r2811 r2896 113 113 /** @name HWACCM SSM version 114 114 */ 115 #define HWACCM_SSM_VERSION 2115 #define HWACCM_SSM_VERSION 3 116 116 117 117 /** … … 159 159 /** Virtual address of the VMXON page. */ 160 160 void *pVMXON; 161 162 /** Physical address of the TSS page used for real mode emulation. */ 163 RTHCPHYS pRealModeTSSPhys; 164 /** Virtual address of the TSS page used for real mode emulation. */ 165 PVBOXTSS pRealModeTSS; 161 166 162 167 /** Host CR4 value (set by ring-0 VMX init) */
Note:
See TracChangeset
for help on using the changeset viewer.