Changeset 14811 in vbox for trunk/src/VBox
- Timestamp:
- Nov 29, 2008 11:48:26 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r13796 r14811 43 43 #include <VBox/gvm.h> 44 44 #include <VBox/vm.h> 45 #include <VBox/vmm.h> 45 46 #include <VBox/err.h> 46 47 #include <iprt/alloc.h> … … 698 699 pGVM->gvmm.s.VMPagesMapObj = NIL_RTR0MEMOBJ; 699 700 pGVM->gvmm.s.HaltEventMulti = NIL_RTSEMEVENTMULTI; 701 pGVM->gvmm.s.fDoneVMMR0Init = false; 702 pGVM->gvmm.s.fDoneVMMR0Term = false; 700 703 } 701 704 … … 719 722 if (RT_SUCCESS(rc)) 720 723 { 721 if (pGVM->gvmm.s.HaltEventMulti == NIL_RTSEMEVENTMULTI) 724 if ( !pGVM->gvmm.s.fDoneVMMR0Init 725 && pGVM->gvmm.s.HaltEventMulti == NIL_RTSEMEVENTMULTI) 722 726 { 723 727 rc = RTSemEventMultiCreate(&pGVM->gvmm.s.HaltEventMulti); … … 731 735 LogFlow(("GVMMR0InitVM: returns %Rrc\n", rc)); 732 736 return rc; 737 } 738 739 740 /** 741 * Indicates that we're done with the ring-0 initialization 742 * of the VM. 743 * 744 * @param pVM Pointer to the shared VM structure. 745 */ 746 GVMMR0DECL(void) GVMMR0DoneInitVM(PVM pVM) 747 { 748 /* Validate the VM structure, state and handle. */ 749 PGVM pGVM; 750 PGVMM pGVMM; 751 int rc = gvmmR0ByVMAndEMT(pVM, &pGVM, &pGVMM); 752 AssertRCReturnVoid(rc); 753 754 /* Set the indicator. */ 755 pGVM->gvmm.s.fDoneVMMR0Init = true; 756 } 757 758 759 /** 760 * Indicates that we're doing the ring-0 termination of the VM. 761 * 762 * @returns true if termination hasn't been done already, false if it has. 763 * @param pVM Pointer to the shared VM structure. 764 * @param pGVM Pointer to the global VM structure. Optional. 765 */ 766 GVMMR0DECL(bool) GVMMR0DoingTermVM(PVM pVM, PGVM pGVM) 767 { 768 /* Validate the VM structure, state and handle. */ 769 AssertPtrNullReturn(pGVM, false); 770 AssertPtrNullReturn(!pGVM || pGVM->u32Magic == GVM_MAGIC, false); 771 if (!pGVM) 772 { 773 PGVMM pGVMM; 774 int rc = gvmmR0ByVMAndEMT(pVM, &pGVM, &pGVMM); 775 AssertRCReturn(rc, false); 776 } 777 778 /* Set the indicator. */ 779 if (pGVM->gvmm.s.fDoneVMMR0Term) 780 return false; 781 pGVM->gvmm.s.fDoneVMMR0Term = true; 782 return true; 733 783 } 734 784 … … 807 857 808 858 /** 859 * Performs VM cleanup task as part of object destruction. 860 * 861 * @param pGVM The GVM pointer. 862 */ 863 static void gmmR0CleanupVM(PGVM pGVM) 864 { 865 if ( pGVM->gvmm.s.fDoneVMMR0Init 866 && !pGVM->gvmm.s.fDoneVMMR0Term) 867 { 868 if ( pGVM->gvmm.s.VMMemObj != NIL_RTR0MEMOBJ 869 && RTR0MemObjAddress(pGVM->gvmm.s.VMMemObj) == pGVM->pVM) 870 { 871 LogFlow(("gmmR0CleanupVM: Calling VMMR0TermVM\n")); 872 VMMR0TermVM(pGVM->pVM, pGVM); 873 } 874 else 875 AssertMsgFailed(("gmmR0CleanupVM: VMMemObj=%p pVM=%p\n", pGVM->gvmm.s.VMMemObj, pGVM->pVM)); 876 } 877 } 878 879 880 /** 809 881 * Handle destructor. 810 882 * 811 * @param pvGVMM 883 * @param pvGVMM The GVM instance pointer. 812 884 * @param pvHandle The handle pointer. 813 885 */ … … 896 968 && pGVM->u32Magic == GVM_MAGIC) 897 969 { 898 /// @todo GMMR0CleanupVM(pGVM);970 gmmR0CleanupVM(pGVM); 899 971 900 972 /* -
trunk/src/VBox/VMM/VMMR0/GVMMR0Internal.h
r8155 r14811 25 25 #include <iprt/mem.h> 26 26 27 27 28 /** 28 29 * The GVMM per VM data. … … 49 50 /** The scheduler statistics. */ 50 51 GVMMSTATSSCHED StatsSched; 52 53 /** Whether the per-VM ring-0 initialization has been performed. */ 54 bool fDoneVMMR0Init; 55 /** Whether the per-VM ring-0 termination is being or has been performed. */ 56 bool fDoneVMMR0Term; 51 57 } GVMMPERVM; 52 58 /** Pointer to the GVMM per VM data. */ -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r14719 r14811 239 239 #endif 240 240 if (RT_SUCCESS(rc)) 241 { 242 GVMMR0DoneInitVM(pVM); 241 243 return rc; 244 } 242 245 243 246 /* bail out */ … … 254 257 * Terminates the R0 driver for a particular VM instance. 255 258 * 259 * This is normally called by ring-3 as part of the VM termination process, but 260 * may alternatively be called during the support driver session cleanup when 261 * the VM object is destroyed (see GVMM). 262 * 256 263 * @returns VBox status code. 257 264 * 258 265 * @param pVM The VM instance in question. 259 * @thread EMT. 260 */ 261 static int vmmR0TermVM(PVM pVM) 262 { 263 /** @todo @bugref{1865,3202}: Make these tail onto the VM object destruction 264 * to make sure they are *always* executed and don't leave mess behind 265 * when the process is killed. */ 266 * @param pGVM Pointer to the global VM structure. Optional. 267 * @thread EMT or session clean up thread. 268 */ 269 VMMR0DECL(int) VMMR0TermVM(PVM pVM, PGVM pGVM) 270 { 271 /* 272 * Tell GVMM what we're up to and check that we only do this once. 273 */ 274 if (GVMMR0DoingTermVM(pVM, pGVM)) 275 { 266 276 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE 267 PGMR0DynMapTermVM(pVM); 268 #endif 269 HWACCMR0TermVM(pVM); 277 PGMR0DynMapTermVM(pVM); 278 #endif 279 HWACCMR0TermVM(pVM); 280 } 270 281 271 282 /* … … 727 738 */ 728 739 case VMMR0_DO_VMMR0_TERM: 729 return vmmR0TermVM(pVM);740 return VMMR0TermVM(pVM, NULL); 730 741 731 742 /*
Note:
See TracChangeset
for help on using the changeset viewer.