Changeset 19663 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- May 13, 2009 3:06:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/MMAllHyper.cpp
r18287 r19663 152 152 #endif 153 153 154 /** 155 * Locks the hypervisor heap. 156 * This might call back to Ring-3 in order to deal with lock contention in GC and R3. 157 * 158 * @param pVM The VM handle. 159 */ 160 VMMDECL(int) MMHyperLock(PVM pVM) 161 { 162 PMMHYPERHEAP pHeap = pVM->mm.s.CTX_SUFF(pHyperHeap); 163 164 #ifdef IN_RING3 165 if (!PDMCritSectIsInitialized(&pHeap->Lock)) 166 return VINF_SUCCESS; /* early init */ 167 168 int rc = PDMCritSectEnter(&pHeap->Lock, VERR_INTERNAL_ERROR); 169 #else 170 Assert(PDMCritSectIsInitialized(&pHeap->Lock)); 171 int rc = PDMCritSectEnter(&pHeap->Lock, VERR_GENERAL_FAILURE); 172 if (rc == VERR_GENERAL_FAILURE) 173 { 174 # ifdef IN_RC 175 rc = VMMGCCallHost(pVM, VMMCALLHOST_MMHYPER_LOCK, 0); 176 # else 177 rc = VMMR0CallHost(pVM, VMMCALLHOST_MMHYPER_LOCK, 0); 178 # endif 179 } 180 #endif 181 AssertRC(rc); 182 return rc; 183 } 184 185 186 /** 187 * Unlocks the hypervisor heap. 188 * 189 * @param pVM The VM handle. 190 */ 191 VMMDECL(void) MMHyperUnlock(PVM pVM) 192 { 193 PMMHYPERHEAP pHeap = pVM->mm.s.CTX_SUFF(pHyperHeap); 194 195 #ifdef IN_RING3 196 if (!PDMCritSectIsInitialized(&pHeap->Lock)) 197 return; /* early init */ 198 #endif 199 Assert(PDMCritSectIsInitialized(&pHeap->Lock)); 200 PDMCritSectLeave(&pHeap->Lock); 201 } 154 202 155 203 /** … … 166 214 * @param ppv Where to store the address to the allocated 167 215 * memory. 168 * @remark This is assumed not to be used at times when serialization is required. 169 */ 170 VMMDECL(int) MMHyperAlloc(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv) 216 */ 217 static int mmHyperAllocInternal(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv) 171 218 { 172 219 AssertMsg(cb >= 8, ("Hey! Do you really mean to allocate less than 8 bytes?! cb=%d\n", cb)); … … 282 329 } 283 330 284 331 /** 332 * Wrapper for mmHyperAllocInternal 333 */ 334 VMMDECL(int) MMHyperAlloc(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv) 335 { 336 int rc; 337 338 rc = MMHyperLock(pVM); 339 AssertRCReturn(rc, rc); 340 341 rc = mmHyperAllocInternal(pVM, cb, uAlignment, enmTag, ppv); 342 343 MMHyperUnlock(pVM); 344 return rc; 345 } 285 346 286 347 /** … … 705 766 * @remark Try avoid free hyper memory. 706 767 */ 707 VMMDECL(int) MMHyperFree(PVM pVM, void *pv)768 static int mmHyperFreeInternal(PVM pVM, void *pv) 708 769 { 709 770 Log2(("MMHyperFree: pv=%p\n", pv)); … … 758 819 ("%p: u32Magic=%#x\n", pv, pHeap->u32Magic), 759 820 VERR_INVALID_POINTER); 760 Assert(pHeap == pVM->mm.s.CTX_SUFF(pHyperHeap));821 Assert(pHeap == pVM->mm.s.CTX_SUFF(pHyperHeap)); 761 822 762 823 /* Some more verifications using additional info from pHeap. */ … … 844 905 #endif 845 906 907 return rc; 908 } 909 910 911 /** 912 * Wrapper for mmHyperFreeInternal 913 */ 914 VMMDECL(int) MMHyperFree(PVM pVM, void *pv) 915 { 916 int rc; 917 918 rc = MMHyperLock(pVM); 919 AssertRCReturn(rc, rc); 920 921 rc = mmHyperFreeInternal(pVM, pv); 922 923 MMHyperUnlock(pVM); 846 924 return rc; 847 925 }
Note:
See TracChangeset
for help on using the changeset viewer.