Changeset 6801 in vbox
- Timestamp:
- Feb 4, 2008 7:36:58 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gvmm.h
r5999 r6801 119 119 120 120 GVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, PVM *ppVM); 121 GVMMR0DECL(int) GVMMR0DisassociateEMTFromVM(PVM pVM);122 121 GVMMR0DECL(int) GVMMR0InitVM(PVM pVM); 123 GVMMR0DECL(int) GVMMR0AssociateEMTWithVM(PVM pVM);124 122 GVMMR0DECL(int) GVMMR0DestroyVM(PVM pVM); 125 123 GVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM); -
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r6635 r6801 486 486 * Allocates the VM structure and registers it with GVM. 487 487 * 488 * The caller will become the VM owner and there by the EMT. 489 * 488 490 * @returns VBox status code. 489 491 * @param pSession The support driver session. 490 492 * @param ppVM Where to store the pointer to the VM structure. 491 493 * 492 * @thread Any thread.494 * @thread EMT. 493 495 */ 494 496 GVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, PVM *ppVM) … … 501 503 *ppVM = NULL; 502 504 503 AssertReturn(RTThreadNativeSelf() != NIL_RTNATIVETHREAD, VERR_INTERNAL_ERROR); 505 RTNATIVETHREAD hEMT = RTThreadNativeSelf(); 506 AssertReturn(hEMT != NIL_RTNATIVETHREAD, VERR_INTERNAL_ERROR); 504 507 505 508 /* … … 609 612 pHandle->pVM = pVM; 610 613 pHandle->pGVM = pGVM; 614 pHandle->hEMT = hEMT; 611 615 pGVM->pVM = pVM; 612 616 pGVM->hEMT = hEMT; 613 617 614 618 gvmmR0UsedUnlock(pGVMM); … … 678 682 679 683 /** 680 * Associates an EMT thread with a VM.681 *682 * This is called early during the ring-0 VM initialization so assertions later in683 * the process can be handled gracefully.684 *685 * @returns VBox status code.686 *687 * @param pVM The VM instance data (aka handle), ring-0 mapping of course.688 * @thread EMT.689 */690 GVMMR0DECL(int) GVMMR0AssociateEMTWithVM(PVM pVM)691 {692 LogFlow(("GVMMR0AssociateEMTWithVM: pVM=%p\n", pVM));693 PGVMM pGVMM;694 GVMM_GET_VALID_INSTANCE(pGVMM, VERR_INTERNAL_ERROR);695 696 /*697 * Validate the VM structure, state and handle.698 */699 AssertPtrReturn(pVM, VERR_INVALID_POINTER);700 AssertReturn(!((uintptr_t)pVM & PAGE_OFFSET_MASK), VERR_INVALID_POINTER);701 AssertMsgReturn(pVM->enmVMState == VMSTATE_CREATING, ("%d\n", pVM->enmVMState), VERR_WRONG_ORDER);702 703 RTNATIVETHREAD hEMT = RTThreadNativeSelf();704 AssertReturn(hEMT != NIL_RTNATIVETHREAD, VERR_NOT_SUPPORTED);705 706 const uint16_t hGVM = pVM->hSelf;707 AssertReturn(hGVM != NIL_GVM_HANDLE, VERR_INVALID_HANDLE);708 AssertReturn(hGVM < RT_ELEMENTS(pGVMM->aHandles), VERR_INVALID_HANDLE);709 710 PGVMHANDLE pHandle = &pGVMM->aHandles[hGVM];711 AssertReturn(pHandle->pVM == pVM, VERR_NOT_OWNER);712 713 /*714 * Take the lock, validate the handle and update the structure members.715 */716 int rc = gvmmR0CreateDestroyLock(pGVMM);717 AssertRCReturn(rc, rc);718 rc = gvmmR0UsedLock(pGVMM);719 AssertRC(rc);720 721 if ( pHandle->pVM == pVM722 && VALID_PTR(pHandle->pvObj)723 && VALID_PTR(pHandle->pSession)724 && VALID_PTR(pHandle->pGVM)725 && pHandle->pGVM->u32Magic == GVM_MAGIC)726 {727 pHandle->hEMT = hEMT;728 pHandle->pGVM->hEMT = hEMT;729 }730 else731 rc = VERR_INTERNAL_ERROR;732 733 gvmmR0UsedUnlock(pGVMM);734 gvmmR0CreateDestroyUnlock(pGVMM);735 LogFlow(("GVMMR0AssociateEMTWithVM: returns %Vrc (hEMT=%RTnthrd)\n", rc, hEMT));736 return rc;737 }738 739 740 /**741 684 * Does the VM initialization. 742 685 * … … 767 710 768 711 LogFlow(("GVMMR0InitVM: returns %Rrc\n", rc)); 769 return rc;770 }771 772 773 /**774 * Disassociates the EMT thread from a VM.775 *776 * This is called last in the ring-0 VM termination. After this point anyone is777 * allowed to destroy the VM. Ideally, we should associate the VM with the thread778 * that's going to call GVMMR0DestroyVM for optimal security, but that's impractical779 * at present.780 *781 * @returns VBox status code.782 *783 * @param pVM The VM instance data (aka handle), ring-0 mapping of course.784 * @thread EMT.785 */786 GVMMR0DECL(int) GVMMR0DisassociateEMTFromVM(PVM pVM)787 {788 LogFlow(("GVMMR0DisassociateEMTFromVM: pVM=%p\n", pVM));789 PGVMM pGVMM;790 GVMM_GET_VALID_INSTANCE(pGVMM, VERR_INTERNAL_ERROR);791 792 /*793 * Validate the VM structure, state and handle.794 */795 AssertPtrReturn(pVM, VERR_INVALID_POINTER);796 AssertReturn(!((uintptr_t)pVM & PAGE_OFFSET_MASK), VERR_INVALID_POINTER);797 AssertMsgReturn(pVM->enmVMState >= VMSTATE_CREATING && pVM->enmVMState <= VMSTATE_DESTROYING, ("%d\n", pVM->enmVMState), VERR_WRONG_ORDER);798 799 RTNATIVETHREAD hEMT = RTThreadNativeSelf();800 AssertReturn(hEMT != NIL_RTNATIVETHREAD, VERR_NOT_SUPPORTED);801 802 const uint16_t hGVM = pVM->hSelf;803 AssertReturn(hGVM != NIL_GVM_HANDLE, VERR_INVALID_HANDLE);804 AssertReturn(hGVM < RT_ELEMENTS(pGVMM->aHandles), VERR_INVALID_HANDLE);805 806 PGVMHANDLE pHandle = &pGVMM->aHandles[hGVM];807 AssertReturn(pHandle->pVM == pVM, VERR_NOT_OWNER);808 809 /*810 * Take the lock, validate the handle and update the structure members.811 */812 int rc = gvmmR0CreateDestroyLock(pGVMM);813 AssertRCReturn(rc, rc);814 rc = gvmmR0UsedLock(pGVMM);815 AssertRC(rc);816 817 if ( VALID_PTR(pHandle->pvObj)818 && VALID_PTR(pHandle->pSession)819 && VALID_PTR(pHandle->pGVM)820 && pHandle->pGVM->u32Magic == GVM_MAGIC)821 {822 if ( pHandle->pVM == pVM823 && pHandle->hEMT == hEMT)824 {825 pHandle->hEMT = NIL_RTNATIVETHREAD;826 pHandle->pGVM->hEMT = NIL_RTNATIVETHREAD;827 }828 else829 rc = VERR_NOT_OWNER;830 }831 else832 rc = VERR_INVALID_HANDLE;833 834 gvmmR0UsedUnlock(pGVMM);835 gvmmR0CreateDestroyUnlock(pGVMM);836 LogFlow(("GVMMR0DisassociateEMTFromVM: returns %Vrc (hEMT=%RTnthrd)\n", rc, hEMT));837 712 return rc; 838 713 } -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r6796 r6801 83 83 if (RT_SUCCESS(rc)) 84 84 { 85 //#ifdef VBOX_WITH_NEW_PHYS_CODE /* need to test on windows, solaris and darwin. */86 85 rc = GMMR0Init(); 87 //#endif88 86 if (RT_SUCCESS(rc)) 89 87 { … … 134 132 * Destroy the GMM and GVMM instances. 135 133 */ 136 //#ifdef VBOX_WITH_NEW_PHYS_CODE137 134 GMMR0Term(); 138 //#endif139 135 GVMMR0Term(); 140 136 … … 206 202 207 203 /* 208 * Associate the ring-0 EMT thread with the GVM 209 * and initalize the GVMM and GMM per VM data. 204 * nitalize the per VM data for GVMM and GMM. 210 205 */ 211 int rc = GVMMR0AssociateEMTWithVM(pVM); 206 int rc = GVMMR0InitVM(pVM); 207 // if (RT_SUCCESS(rc)) 208 // rc = GMMR0InitPerVMData(pVM); 212 209 if (RT_SUCCESS(rc)) 213 210 { 214 rc = GVMMR0InitVM(pVM); 215 //if (RT_SUCCESS(rc)) 216 // rc = GMMR0InitVM(pVM); 211 /* 212 * Init HWACCM. 213 */ 214 RTCCUINTREG fFlags = ASMIntDisableFlags(); 215 rc = HWACCMR0Init(pVM); 216 ASMSetFlags(fFlags); 217 217 if (RT_SUCCESS(rc)) 218 218 { 219 219 /* 220 * Init HWACCM.220 * Init CPUM. 221 221 */ 222 RTCCUINTREG fFlags = ASMIntDisableFlags(); 223 rc = HWACCMR0Init(pVM); 224 ASMSetFlags(fFlags); 222 rc = CPUMR0Init(pVM); 225 223 if (RT_SUCCESS(rc)) 226 { 227 /* 228 * Init CPUM. 229 */ 230 rc = CPUMR0Init(pVM); 231 if (RT_SUCCESS(rc)) 232 return rc; 233 } 224 return rc; 234 225 } 235 226 } … … 254 245 * Deregister the logger. 255 246 */ 256 GVMMR0DisassociateEMTFromVM(pVM);257 247 RTLogSetDefaultInstanceThread(NULL, 0); 258 248 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.