- Timestamp:
- Sep 21, 2007 10:19:12 PM (17 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDRV.h
r4833 r4971 516 516 /** Pointer to the next in the global list. */ 517 517 struct SUPDRVOBJ * volatile pNext; 518 /** Pointer to the object destructor. */ 518 /** Pointer to the object destructor. 519 * This may be set to NULL if the image containing the destructor get unloaded. */ 519 520 PFNSUPDRVDESTRUCTOR pfnDestructor; 520 521 /** User argument 1. */ … … 612 613 { 613 614 /** Spinlock to serialize the initialization, 614 * usage counting and destruction of the IDT entry override . */615 * usage counting and destruction of the IDT entry override and objects. */ 615 616 RTSPINLOCK Spinlock; 616 617 … … 622 623 #endif 623 624 624 /** List of registered objects. */625 /** List of registered objects. Protected by the spinlock. */ 625 626 PSUPDRVOBJ volatile pObjs; 626 627 /** List of free object usage records. */ -
trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c
r4965 r4971 88 88 { "SUPR0ContAlloc", (void *)SUPR0ContAlloc }, 89 89 { "SUPR0ContFree", (void *)SUPR0ContFree }, 90 { "SUPR0LowAlloc", (void *)SUPR0LowAlloc }, 91 { "SUPR0LowFree", (void *)SUPR0LowFree }, 90 92 { "SUPR0MemAlloc", (void *)SUPR0MemAlloc }, 91 93 { "SUPR0MemGetPhys", (void *)SUPR0MemGetPhys }, … … 429 431 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); 430 432 431 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 433 if (pObj->pfnDestructor) 434 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 432 435 RTMemFree(pObj); 433 436 } … … 1315 1318 { 1316 1319 pObj->u32Magic++; 1317 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 1320 if (pObj->pfnDestructor) 1321 pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2); 1318 1322 RTMemFree(pObj); 1319 1323 } … … 3127 3131 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq) 3128 3132 { 3133 int rc; 3129 3134 PSUPDRVLDRUSAGE pUsagePrev; 3130 3135 PSUPDRVLDRUSAGE pUsage; … … 3153 3158 * Check if we can remove anything. 3154 3159 */ 3160 rc = VINF_SUCCESS; 3155 3161 pImage = pUsage->pImage; 3156 3162 if (pImage->cUsage <= 1 || pUsage->cUsage <= 1) 3157 3163 { 3158 /* unlink it */ 3159 if (pUsagePrev) 3160 pUsagePrev->pNext = pUsage->pNext; 3164 /* 3165 * Check if there are any objects with destructors in the image, if 3166 * so leave it for the session cleanup routine so we get a chance to 3167 * clean things up in the right order and not leave them all dangling. 3168 */ 3169 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 3170 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); 3171 if (pImage->cUsage <= 1) 3172 { 3173 PSUPDRVOBJ pObj; 3174 for (pObj = pDevExt->pObjs; pObj; pObj = pObj->pNext) 3175 if (RT_UNLIKELY((uintptr_t)pObj->pfnDestructor - (uintptr_t)pImage->pvImage < pImage->cbImage)) 3176 { 3177 rc = VERR_SHARING_VIOLATION; /** @todo VERR_DANGLING_OBJECTS */ 3178 break; 3179 } 3180 } 3161 3181 else 3162 pSession->pLdrUsage = pUsage->pNext; 3163 /* free it */ 3164 pUsage->pImage = NULL; 3165 pUsage->pNext = NULL; 3166 RTMemFree(pUsage); 3167 3168 /* 3169 * Derefrence the image. 3170 */ 3171 if (pImage->cUsage <= 1) 3172 supdrvLdrFree(pDevExt, pImage); 3173 else 3174 pImage->cUsage--; 3182 { 3183 PSUPDRVUSAGE pGenUsage; 3184 for (pGenUsage = pSession->pUsage; pGenUsage; pGenUsage = pGenUsage->pNext) 3185 if (RT_UNLIKELY((uintptr_t)pGenUsage->pObj->pfnDestructor - (uintptr_t)pImage->pvImage < pImage->cbImage)) 3186 { 3187 rc = VERR_SHARING_VIOLATION; /** @todo VERR_DANGLING_OBJECTS */ 3188 break; 3189 } 3190 } 3191 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); 3192 if (rc == VINF_SUCCESS) 3193 { 3194 /* unlink it */ 3195 if (pUsagePrev) 3196 pUsagePrev->pNext = pUsage->pNext; 3197 else 3198 pSession->pLdrUsage = pUsage->pNext; 3199 3200 /* free it */ 3201 pUsage->pImage = NULL; 3202 pUsage->pNext = NULL; 3203 RTMemFree(pUsage); 3204 3205 /* 3206 * Derefrence the image. 3207 */ 3208 if (pImage->cUsage <= 1) 3209 supdrvLdrFree(pDevExt, pImage); 3210 else 3211 pImage->cUsage--; 3212 } 3175 3213 } 3176 3214 else … … 3423 3461 if (pDevExt->pvVMMR0 == pImage->pvImage) 3424 3462 supdrvLdrUnsetR0EP(pDevExt); 3463 3464 /* check for objects with destructors in this image. (Shouldn't happen.) */ 3465 if (pDevExt->pObjs) 3466 { 3467 unsigned cObjs = 0; 3468 PSUPDRVOBJ pObj; 3469 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 3470 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); 3471 for (pObj = pDevExt->pObjs; pObj; pObj = pObj->pNext) 3472 if (RT_UNLIKELY((uintptr_t)pObj->pfnDestructor - (uintptr_t)pImage->pvImage < pImage->cbImage)) 3473 { 3474 pObj->pfnDestructor = NULL; 3475 cObjs++; 3476 } 3477 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); 3478 if (cObjs) 3479 OSDBGPRINT(("supdrvLdrFree: Image '%s' has %d dangling objects!\n", pImage->szName, cObjs)); 3480 } 3425 3481 3426 3482 /* call termination function if fully loaded. */ -
trunk/src/VBox/VMM/Makefile.kmk
r4918 r4971 325 325 VMMR0_SYSSUFF = .r0 326 326 VMMR0_SOURCES = \ 327 VMMR0/CPUMR0.cpp \ 328 VMMR0/DBGFR0.cpp \ 329 VMMR0/GVMR0.cpp \ 330 VMMR0/HWACCMR0.cpp \ 331 VMMR0/HWACCMR0A.asm \ 332 VMMR0/HWSVMR0.cpp \ 333 VMMR0/HWVMXR0.cpp \ 334 VMMR0/PDMR0Device.cpp \ 335 VMMR0/PGMR0.cpp \ 336 VMMR0/TRPMR0.cpp \ 337 VMMR0/TRPMR0A.asm \ 327 338 VMMR0/VMMR0.cpp \ 328 VMMR0/DBGFR0.cpp \ 339 VMMR0/VMMR0A.asm \ 340 VMMAll/CPUMAllA.asm \ 341 VMMAll/CPUMAllRegs.cpp \ 329 342 VMMAll/DBGFAll.cpp \ 330 VMMAll/TRPMAll.cpp \ 331 VMMAll/CPUMAllRegs.cpp \ 332 VMMAll/CPUMAllA.asm \ 343 VMMAll/EMAll.cpp \ 344 VMMAll/EMAllA.asm \ 345 VMMAll/IOMAll.cpp \ 346 VMMAll/IOMAllMMIO.cpp \ 333 347 VMMAll/MMAll.cpp \ 334 348 VMMAll/MMAllHyper.cpp \ 335 349 VMMAll/MMAllPagePool.cpp \ 336 350 VMMAll/MMAllPhys.cpp \ 337 VMMR0/VMMR0A.asm \338 VMMR0/HWACCMR0.cpp \339 VMMR0/HWACCMR0A.asm \340 VMMR0/HWVMXR0.cpp \341 VMMR0/HWSVMR0.cpp \342 VMMR0/CPUMR0.cpp \343 VMMR0/TRPMR0.cpp \344 VMMR0/TRPMR0A.asm \345 VMMR0/PDMR0Device.cpp \346 VMMR0/PGMR0.cpp \347 VMMAll/EMAll.cpp \348 VMMAll/EMAllA.asm \349 351 VMMAll/PDMAll.cpp \ 350 352 VMMAll/PDMAllCritSect.cpp \ … … 356 358 VMMAll/PGMAllPool.cpp \ 357 359 VMMAll/REMAll.cpp \ 358 VMMAll/IOMAll.cpp \359 VMMAll/IOMAllMMIO.cpp \360 360 VMMAll/SELMAll.cpp \ 361 361 VMMAll/TMAll.cpp \ … … 363 363 VMMAll/TMAllReal.cpp \ 364 364 VMMAll/TMAllVirtual.cpp \ 365 VMMAll/VMAll.cpp 365 VMMAll/TRPMAll.cpp \ 366 VMMAll/VMAll.cpp \ 366 367 367 368 ifeq ($(VBOX_LDR_FMT),pe) -
trunk/src/VBox/VMM/VMM.cpp
r4932 r4971 631 631 rc = VINF_SUCCESS; 632 632 #else 633 rc = SUPCallVMMR0 (pVM->pVMR0, VMMR0_DO_VMMR0_INIT, (void *)VBOX_VERSION);633 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_VMMR0_INIT, VBOX_VERSION, NULL); 634 634 #endif 635 635 if ( pVM->vmm.s.pR0Logger … … 738 738 VMMR3DECL(int) VMMR3Term(PVM pVM) 739 739 { 740 /** @todo must call ring-0 so the logger thread instance can be properly removed. */ 740 /* 741 * Call Ring-0 entry with termination code. 742 */ 743 int rc; 744 for (;;) 745 { 746 #ifdef NO_SUPCALLR0VMM 747 //rc = VERR_GENERAL_FAILURE; 748 rc = VINF_SUCCESS; 749 #else 750 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_VMMR0_TERM, VBOX_VERSION, NULL); 751 #endif 752 if ( pVM->vmm.s.pR0Logger 753 && pVM->vmm.s.pR0Logger->Logger.offScratch > 0) 754 RTLogFlushToLogger(&pVM->vmm.s.pR0Logger->Logger, NULL); 755 if (rc != VINF_VMM_CALL_HOST) 756 break; 757 rc = vmmR3ServiceCallHostRequest(pVM); 758 if (VBOX_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST)) 759 break; 760 break; // remove this when we do setjmp for all ring-0 stuff. 761 } 762 if (VBOX_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST)) 763 { 764 LogRel(("VMMR3Term: R0 term failed, rc=%Vra. (warning)\n", rc)); 765 if (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST) 766 rc = VERR_INTERNAL_ERROR; 767 } 741 768 742 769 #ifdef VBOX_STRICT_VMM_STACK … … 747 774 RTMemProtect(pVM->vmm.s.pbHCStack + VMM_STACK_SIZE, PAGE_SIZE, RTMEM_PROT_READ | RTMEM_PROT_WRITE); 748 775 #endif 749 return VINF_SUCCESS;776 return rc; 750 777 } 751 778 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r4970 r4971 29 29 #include "VMMInternal.h" 30 30 #include <VBox/vm.h> 31 #include <VBox/gvm.h> 31 32 #include <VBox/intnet.h> 32 33 #include <VBox/hwaccm.h> … … 85 86 VMMR0DECL(int) ModuleInit(void) 86 87 { 88 LogFlow(("ModuleInit:\n")); 89 90 /* 91 * Initialize GVM. 92 */ 93 int rc = GVMR0Init(); 94 if (RT_SUCCESS(rc)) 95 { 87 96 #ifdef VBOX_WITH_INTERNAL_NETWORKING 88 LogFlow(("ModuleInit: g_pIntNet=%p\n", g_pIntNet)); 89 g_pIntNet = NULL; 90 LogFlow(("ModuleInit: g_pIntNet=%p should be NULL now...\n", g_pIntNet)); 91 int rc = INTNETR0Create(&g_pIntNet); 92 if (VBOX_SUCCESS(rc)) 93 { 94 LogFlow(("ModuleInit: returns success. g_pIntNet=%p\n", g_pIntNet)); 95 return 0; 96 } 97 g_pIntNet = NULL; 98 LogFlow(("ModuleTerm: returns %Vrc\n", rc)); 97 LogFlow(("ModuleInit: g_pIntNet=%p\n", g_pIntNet)); 98 g_pIntNet = NULL; 99 LogFlow(("ModuleInit: g_pIntNet=%p should be NULL now...\n", g_pIntNet)); 100 rc = INTNETR0Create(&g_pIntNet); 101 if (VBOX_SUCCESS(rc)) 102 { 103 LogFlow(("ModuleInit: returns success. g_pIntNet=%p\n", g_pIntNet)); 104 return VINF_SUCCESS; 105 } 106 g_pIntNet = NULL; 107 LogFlow(("ModuleTerm: returns %Vrc\n", rc)); 108 #else 109 LogFlow(("ModuleInit: returns success.\n")); 110 return VINF_SUCCESS; 111 #endif 112 } 113 114 LogFlow(("ModuleInit: failed %Vrc\n", rc)); 99 115 return rc; 100 #else101 return 0;102 #endif103 116 } 104 117 … … 110 123 VMMR0DECL(void) ModuleTerm(void) 111 124 { 125 LogFlow(("ModuleTerm:\n")); 126 112 127 #ifdef VBOX_WITH_INTERNAL_NETWORKING 113 LogFlow(("ModuleTerm:\n")); 128 /* 129 * Destroy the internal networking instance. 130 */ 114 131 if (g_pIntNet) 115 132 { … … 117 134 g_pIntNet = NULL; 118 135 } 136 #endif 137 138 /* 139 * Destroy the GVM instance. 140 */ 141 GVMR0Term(); 142 119 143 LogFlow(("ModuleTerm: returns\n")); 120 #endif121 144 } 122 145 … … 182 205 } 183 206 184 185 207 /* 186 * Init VMXM.208 * Try register the VM with GVM. 187 209 */ 188 int rc = HWACCMR0Init(pVM); 189 if (VBOX_FAILURE(rc)) 190 { 191 RTLogSetDefaultInstanceThread(NULL, 0); 192 return rc; 193 } 194 195 /* 196 * Init CPUM. 197 */ 198 rc = CPUMR0Init(pVM); 199 200 if (RT_FAILURE(rc)) 201 RTLogSetDefaultInstanceThread(NULL, 0); 210 int rc = GVMR0RegisterVM(pVM); 211 if (RT_SUCCESS(rc)) 212 { 213 /* 214 * Init HWACCM. 215 */ 216 RTCCUINTREG fFlags = ASMIntDisableFlags(); 217 rc = HWACCMR0Init(pVM); 218 ASMSetFlags(fFlags); 219 if (RT_SUCCESS(rc)) 220 { 221 /* 222 * Init CPUM. 223 */ 224 rc = CPUMR0Init(pVM); 225 if (RT_SUCCESS(rc)) 226 return rc; 227 } 228 229 GVMR0DeregisterVM(pVM); 230 } 231 232 /* failed */ 233 RTLogSetDefaultInstanceThread(NULL, 0); 202 234 return rc; 203 235 } … … 216 248 * Deregister the logger. 217 249 */ 250 GVMR0DeregisterVM(pVM); 218 251 RTLogSetDefaultInstanceThread(NULL, 0); 219 252 return VINF_SUCCESS; … … 489 522 490 523 /* 491 * Initialize the R0 part of a VM instance.492 */493 case VMMR0_DO_VMMR0_INIT:494 {495 RTCCUINTREG fFlags = ASMIntDisableFlags();496 int rc = VMMR0Init(pVM, (unsigned)(uintptr_t)pvArg);497 ASMSetFlags(fFlags);498 return rc;499 }500 501 /*502 * Terminate the R0 part of a VM instance.503 */504 case VMMR0_DO_VMMR0_TERM:505 {506 RTCCUINTREG fFlags = ASMIntDisableFlags();507 int rc = VMMR0Term(pVM);508 ASMSetFlags(fFlags);509 return rc;510 }511 512 /*513 524 * Switch to GC to execute Hypervisor function. 514 525 */ … … 522 533 RTCCUINTREG fFlags = ASMIntDisableFlags(); 523 534 int rc = pVM->vmm.s.pfnR0HostToGuest(pVM); 535 /** @todo dispatch interrupts? */ 524 536 ASMSetFlags(fFlags); 525 537 return rc; … … 661 673 case VMMR0_DO_VMMR0_INIT: 662 674 { 663 RTCCUINTREG fFlags = ASMIntDisableFlags();664 675 int rc = VMMR0Init(pVM, (unsigned)u64Arg); 665 ASMSetFlags(fFlags);666 676 return rc; 667 677 } … … 672 682 case VMMR0_DO_VMMR0_TERM: 673 683 { 674 RTCCUINTREG fFlags = ASMIntDisableFlags();675 684 int rc = VMMR0Term(pVM); 676 ASMSetFlags(fFlags);677 685 return rc; 678 686 } … … 701 709 RTCCUINTREG fFlags = ASMIntDisableFlags(); 702 710 int rc = pVM->vmm.s.pfnR0HostToGuest(pVM); 711 /** @todo dispatch interrupts? */ 703 712 ASMSetFlags(fFlags); 704 713 return rc; … … 907 916 } 908 917 909 /** Runtime assert implementation for Native Win32 Ring-0. */ 918 910 919 DECLEXPORT(void) RTCALL AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 911 920 { 921 SUPR0Printf("\n!!R0-Assertion Failed!!\n" 922 "Expression: %s\n" 923 "Location : %s(%d) %s\n", 924 pszExpr, pszFile, uLine, pszFunction); 925 912 926 LogRel(("\n!!R0-Assertion Failed!!\n" 913 "Expression: %s\n" 914 "Location : %s(%d) %s\n", 915 pszExpr, pszFile, uLine, pszFunction)); 916 } 927 "Expression: %s\n" 928 "Location : %s(%d) %s\n", 929 pszExpr, pszFile, uLine, pszFunction)); 930 } 931 917 932 918 933 /** … … 922 937 static DECLCALLBACK(size_t) rtLogOutput(void *pv, const char *pachChars, size_t cbChars) 923 938 { 924 for (size_t i=0;i<cbChars;i++) 939 for (size_t i = 0; i < cbChars; i++) 940 { 925 941 LogRel(("%c", pachChars[i])); 942 SUPR0Printf("%c", pachChars[i]); 943 } 926 944 927 945 return cbChars; 928 946 } 947 929 948 930 949 DECLEXPORT(void) RTCALL AssertMsg2(const char *pszFormat, ...)
Note:
See TracChangeset
for help on using the changeset viewer.