- Timestamp:
- Mar 26, 2012 12:14:18 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv-dtrace.cpp
r40617 r40636 41 41 #include <iprt/mem.h> 42 42 #include <iprt/semaphore.h> 43 #include <iprt/thread.h> 43 44 44 45 #ifdef RT_OS_DARWIN /** @todo figure this! */ … … 126 127 /* .dtps_destroy = */ supdrvDTracePOps_Destroy 127 128 }; 128 129 130 #define VERR_SUPDRV_VTG_MAGIC (-3704)131 #define VERR_SUPDRV_VTG_BITS (-3705)132 //#define VERR_SUPDRV_VTG_RESERVED (-3705)133 #define VERR_SUPDRV_VTG_BAD_HDR (-3706)134 #define VERR_SUPDRV_VTG_BAD_HDR_PTR (-3707)135 #define VERR_SUPDRV_VTG_BAD_HDR_TOO_FEW (-3708)136 #define VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH (-3709)137 #define VERR_SUPDRV_VTG_BAD_HDR_NOT_MULTIPLE (-3710)138 #define VERR_SUPDRV_VTG_STRTAB_OFF (-3711)139 #define VERR_SUPDRV_VTG_BAD_STRING (-3712)140 #define VERR_SUPDRV_VTG_STRING_TOO_LONG (-3713)141 #define VERR_SUPDRV_VTG_BAD_ATTR (-3714)142 #define VERR_SUPDRV_VTG_BAD_PROVIDER (-3715)143 #define VERR_SUPDRV_VTG_BAD_PROBE (-3716)144 #define VERR_SUPDRV_VTG_BAD_ARGLIST (-3717)145 #define VERR_SUPDRV_VTG_BAD_PROBE_ENABLED (-3718)146 #define VERR_SUPDRV_VTG_BAD_PROBE_LOC (-3719)147 #define VERR_SUPDRV_VTG_ALREADY_REGISTERED (-3720)148 #define VERR_SUPDRV_VTG_ONLY_ONCE_PER_SESSION (-3721)149 129 150 130 … … 437 417 return VERR_SUPDRV_VTG_ALREADY_REGISTERED; 438 418 } 439 if (pProv->pSession == pSession && !pProv->pImage) 419 if ( pProv->pSession == pSession 420 && pProv->pImage == pImage) 440 421 { 441 422 RTSemFastMutexRelease(pDevExt->mtxDTrace); … … 521 502 522 503 523 524 504 /** 525 505 * Registers the VTG tracepoint providers of a driver. … … 540 520 541 521 542 543 522 /** 544 523 * Deregister the VTG tracepoint providers of a driver. … … 572 551 573 552 553 /** 554 * Registers the VTG tracepoint providers of a module loaded by 555 * the support driver. 556 * 557 * This should be called from the ModuleInit code. 558 * 559 * @returns VBox status code. 560 * @param hMod The module handle. 561 * @param pVtgHdr The VTG header. 562 */ 563 SUPR0DECL(int) SUPR0VtgRegisterModule(void *hMod, PVTGOBJHDR pVtgHdr) 564 { 565 PSUPDRVLDRIMAGE pImage = (PSUPDRVLDRIMAGE)hMod; 566 PSUPDRVDEVEXT pDevExt; 567 uintptr_t cbVtgObj; 568 569 /* 570 * Validate input and context. 571 */ 572 AssertPtrReturn(pImage, VERR_INVALID_HANDLE); 573 AssertPtrReturn(pVtgHdr, VERR_INVALID_POINTER); 574 575 pDevExt = pImage->pDevExt; 576 AssertPtrReturn(pDevExt, VERR_INVALID_POINTER); 577 AssertReturn(pDevExt->pLdrInitImage == pImage, VERR_WRONG_ORDER); 578 AssertReturn(pDevExt->hLdrInitThread == RTThreadNativeSelf(), VERR_WRONG_ORDER); 579 580 /* 581 * Calculate the max VTG object size and hand it over to the common code. 582 */ 583 cbVtgObj = (uintptr_t)pVtgHdr - (uintptr_t)pImage->pvImage; 584 AssertMsgReturn(cbVtgObj /*off*/ < pImage->cbImageBits, 585 ("pVtgHdr=%p offVtgObj=%p cbImageBits=%p\n", pVtgHdr, cbVtgObj, pImage->cbImageBits), 586 VERR_INVALID_PARAMETER); 587 cbVtgObj = pImage->cbImageBits - cbVtgObj; 588 589 return supdrvVtgRegister(pDevExt, pVtgHdr, cbVtgObj, pImage, NULL, pImage->szName); 590 } 591 592 593 /** 594 * Module unloading hook, called after execution in the module have ceased. 595 * 596 * @param pDevExt The device extension structure. 597 * @param pImage The image being unloaded. 598 */ 599 void VBOXCALL supdrvVtgModuleUnloading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 600 { 601 PSUPDRVDTPROVIDER pProv, pProvNext; 602 603 /* 604 * Unregister all providers belonging to this image. 605 */ 606 RTSemFastMutexRequest(pDevExt->mtxDTrace); 607 RTListForEachSafe(&pDevExt->DtProviderList, pProv, pProvNext, SUPDRVDTPROVIDER, ListEntry) 608 { 609 if (pProv->pImage == pImage) 610 { 611 RTListNodeRemove(&pProv->ListEntry); 612 RTSemFastMutexRelease(pDevExt->mtxDTrace); 613 614 dtrace_unregister(pProv->idDtProv); 615 RTMemFree(pProv); 616 617 RTSemFastMutexRequest(pDevExt->mtxDTrace); 618 } 619 } 620 RTSemFastMutexRelease(pDevExt->mtxDTrace); 621 } 622 574 623 575 624 /** … … 577 626 * 578 627 * @returns VBox status code. 579 * @param pDevExt The device extension structure. 580 */ 581 int VBOXCALL supdrvDTraceInit(PSUPDRVDEVEXT pDevExt) 582 { 628 * @param pDevExt The device extension structure. 629 * @param pVtgFireProbe Pointer to the SUPR0VtgFireProbe entry. 630 */ 631 int VBOXCALL supdrvVtgInit(PSUPDRVDEVEXT pDevExt, PSUPFUNC pVtgFireProbe) 632 { 633 Assert(!strcmp(pVtgFireProbe->szName, "SUPR0VtgFireProbe")); 634 583 635 /* 584 636 * Register a provider for this module. … … 587 639 if (RT_SUCCESS(rc)) 588 640 { 641 #ifdef RT_OS_SOLARIS 642 pVtgFireProbe->pfn = (void *)(uintptr_t)dtrace_probe; 643 #endif 589 644 RTListInit(&pDevExt->DtProviderList); 590 645 rc = supdrvVtgRegister(pDevExt, &g_VTGObjHeader, _1M, NULL /*pImage*/, NULL /*pSession*/, "vboxdrv"); … … 604 659 * @param pDevExt The device extension structure. 605 660 */ 606 int VBOXCALL supdrv DTraceTerm(PSUPDRVDEVEXT pDevExt)661 int VBOXCALL supdrvVtgTerm(PSUPDRVDEVEXT pDevExt) 607 662 { 608 663 PSUPDRVDTPROVIDER pProv, pProvNext; … … 625 680 RTSemFastMutexDestroy(pDevExt->mtxDTrace); 626 681 pDevExt->mtxDTrace = NIL_RTSEMFASTMUTEX; 627 return VINF_SUCCESS;628 }629 630 631 /**632 * Module loading hook, called before calling into the module.633 *634 * @returns VBox status code.635 * @param pDevExt The device extension structure.636 */637 int supdrvDTraceModuleLoading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)638 {639 /*640 * Check for DTrace probes in the module, register a new provider for them641 * if found.642 */643 644 return VINF_SUCCESS;645 }646 647 648 /**649 * Module unloading hook, called after execution in the module650 * have ceased.651 *652 * @returns VBox status code.653 * @param pDevExt The device extension structure.654 */655 int supdrvDTraceModuleUnloading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)656 {657 /*658 * Undo what we did in supdrvDTraceModuleLoading.659 */660 682 return VINF_SUCCESS; 661 683 } -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r40611 r40636 163 163 { "SUPR0AbsKernelFS", (void *)0 }, 164 164 { "SUPR0AbsKernelGS", (void *)0 }, 165 { "SUPR0VtgFireProbe", (void *)SUPR0VtgFireProbe }, 165 166 /* Normal function pointers: */ 166 167 { "SUPR0ComponentRegisterFactory", (void *)SUPR0ComponentRegisterFactory }, … … 203 204 { "SUPR0GetPagingMode", (void *)SUPR0GetPagingMode }, 204 205 { "SUPR0EnableVTx", (void *)SUPR0EnableVTx }, 206 { "SUPR0VtgRegisterModule", (void *)SUPR0VtgRegisterModule }, 205 207 { "SUPGetGIP", (void *)SUPGetGIP }, 206 208 { "g_pSUPGlobalInfoPage", (void *)&g_pSUPGlobalInfoPage }, … … 465 467 { 466 468 #ifdef VBOX_WITH_DTRACE_R0DRV 467 rc = supdrv DTraceInit(pDevExt);469 rc = supdrvVtgInit(pDevExt, &g_aFunctions[10]); 468 470 if (RT_SUCCESS(rc)) 469 471 #endif 470 472 { 471 472 pDevExt->u32Cookie = BIRD; /** @todo make this random? */ 473 pDevExt->cbSession = (uint32_t)cbSession; 473 pDevExt->pLdrInitImage = NULL; 474 pDevExt->hLdrInitThread = NIL_RTNATIVETHREAD; 475 pDevExt->u32Cookie = BIRD; /** @todo make this random? */ 476 pDevExt->cbSession = (uint32_t)cbSession; 474 477 475 478 /* … … 624 627 625 628 #ifdef VBOX_WITH_DTRACE_R0DRV 626 supdrv DTraceTerm(pDevExt);629 supdrvVtgTerm(pDevExt); 627 630 #endif 628 631 … … 3664 3667 3665 3668 3669 #if defined(VBOX_WITH_DTRACE_R0DRV) || defined(RT_OS_SOLARIS) 3670 /** 3671 * Stub function. 3672 */ 3673 SUPR0DECL(void) SUPR0VtgFireProbe(uint32_t idProbe, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2, 3674 uintptr_t uArg3, uintptr_t uArg4) 3675 { 3676 NOREF(idProbe); NOREF(uArg0); NOREF(uArg1); NOREF(uArg2); NOREF(uArg3); NOREF(uArg4); 3677 } 3678 #endif 3679 3680 #ifndef VBOX_WITH_DTRACE_R0DRV 3681 /** 3682 * Stub function. 3683 */ 3684 SUPR0DECL(int) SUPR0VtgRegisterModule(void *hMod, PVTGOBJHDR pVtgHdr) 3685 { 3686 NOREF(hMod); NOREF(pVtgHdr); 3687 return VINF_SUCCESS; 3688 } 3689 #endif 3690 3691 3666 3692 /** 3667 3693 * Adds a memory object to the session. … … 3859 3885 pImage->uState = SUP_IOCTL_LDR_OPEN; 3860 3886 pImage->cUsage = 1; 3887 pImage->pDevExt = pDevExt; 3861 3888 memcpy(pImage->szName, pReq->u.In.szName, cchName + 1); 3862 3889 … … 4113 4140 { 4114 4141 Log(("supdrvIOCtl_LdrLoad: calling pfnModuleInit=%p\n", pImage->pfnModuleInit)); 4115 rc = pImage->pfnModuleInit(); 4116 if (rc && pDevExt->pvVMMR0 == pImage->pvImage) 4142 pDevExt->pLdrInitImage = pImage; 4143 pDevExt->hLdrInitThread = RTThreadNativeSelf(); 4144 rc = pImage->pfnModuleInit(pImage); 4145 pDevExt->pLdrInitImage = NULL; 4146 pDevExt->hLdrInitThread = NIL_RTNATIVETHREAD; 4147 if (RT_FAILURE(rc) && pDevExt->pvVMMR0 == pImage->pvImage) 4117 4148 supdrvLdrUnsetVMMR0EPs(pDevExt); 4118 4149 } … … 4120 4151 if (RT_FAILURE(rc)) 4121 4152 { 4153 #ifdef VBOX_WITH_DTRACE_R0DRV 4154 /* Inform the tracing component in case ModuleInit registered TPs. */ 4155 supdrvVtgModuleUnloading(pDevExt, pImage); 4156 #endif 4157 4122 4158 pImage->uState = SUP_IOCTL_LDR_OPEN; 4123 4159 pImage->pfnModuleInit = NULL; … … 4561 4597 { 4562 4598 LogFlow(("supdrvIOCtl_LdrLoad: calling pfnModuleTerm=%p\n", pImage->pfnModuleTerm)); 4563 pImage->pfnModuleTerm(); 4564 } 4599 pImage->pfnModuleTerm(pImage); 4600 } 4601 4602 #ifdef VBOX_WITH_DTRACE_R0DRV 4603 /* Inform the tracing component. */ 4604 supdrvVtgModuleUnloading(pDevExt, pImage); 4605 #endif 4565 4606 4566 4607 /* do native unload if appropriate. */ … … 4569 4610 4570 4611 /* free the image */ 4571 pImage->cUsage = 0; 4572 pImage->pNext = 0; 4573 pImage->uState = SUP_IOCTL_LDR_FREE; 4612 pImage->cUsage = 0; 4613 pImage->pDevExt = NULL; 4614 pImage->pNext = NULL; 4615 pImage->uState = SUP_IOCTL_LDR_FREE; 4574 4616 RTMemExecFree(pImage->pvImageAlloc, pImage->cbImageBits + 31); 4575 4617 pImage->pvImageAlloc = NULL; -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r37591 r40636 193 193 * - None. 194 194 */ 195 #define SUPDRV_IOC_VERSION 0x0019000 0195 #define SUPDRV_IOC_VERSION 0x00190001 196 196 197 197 /** SUP_IOCTL_COOKIE. */ … … 325 325 * 326 326 * @returns 0 on success. 327 * @returns Appropriate error code on failure. 328 */ 329 typedef DECLCALLBACK(int) FNR0MODULEINIT(void); 327 * @returns Appropriate error code on failure. 328 * @param hMod Image handle for use in APIs. 329 */ 330 typedef DECLCALLBACK(int) FNR0MODULEINIT(void *hMod); 330 331 /** Pointer to a FNR0MODULEINIT(). */ 331 332 typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT; … … 333 334 /** 334 335 * Module termination callback function. 335 * This is called once right before the module is being unloaded. 336 */ 337 typedef DECLCALLBACK(void) FNR0MODULETERM(void); 336 * This is called once right before the module is being unloaded. 337 * 338 * @param hMod Image handle for use in APIs. 339 */ 340 typedef DECLCALLBACK(void) FNR0MODULETERM(void *hMod); 338 341 /** Pointer to a FNR0MODULETERM(). */ 339 342 typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM; -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r40611 r40636 295 295 /** Usage count. */ 296 296 uint32_t volatile cUsage; 297 /** Pointer to the device extension. */ 298 struct SUPDRVDEVEXT *pDevExt; 297 299 #ifdef RT_OS_WINDOWS 298 300 /** The section object for the loaded image (fNative=true). */ … … 493 495 PSUPDRVLDRIMAGE volatile pLdrImages; 494 496 497 /** @name These members for detecting whether an API caller is in ModuleInit. 498 * Certain APIs are only permitted from ModuleInit, like for instance tracepoint 499 * registration. 500 * @{ */ 501 /** The image currently executing its ModuleInit. */ 502 PSUPDRVLDRIMAGE volatile pLdrInitImage; 503 /** The thread currently executing a ModuleInit function. */ 504 RTNATIVETHREAD volatile hLdrInitThread; 505 /** @} */ 506 507 495 508 /** GIP mutex. 496 509 * Any changes to any of the GIP members requires ownership of this mutex, … … 621 634 622 635 #ifdef VBOX_WITH_DTRACE_R0DRV 623 int VBOXCALL supdrv DTraceTerm(PSUPDRVDEVEXT pDevExt);624 int VBOXCALL supdrv DTraceInit(PSUPDRVDEVEXT pDevExt);625 #endif 626 636 int VBOXCALL supdrvVtgInit(PSUPDRVDEVEXT pDevExt, PSUPFUNC pVtgFireProbe); 637 int VBOXCALL supdrvVtgTerm(PSUPDRVDEVEXT pDevExt); 638 void VBOXCALL supdrvVtgModuleUnloading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 639 #endif 627 640 628 641 -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r39086 r40636 267 267 strcpy(CookieReq.u.In.szMagic, SUPCOOKIE_MAGIC); 268 268 CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION; 269 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x001 70000270 ? 0x001 70002269 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00190000 270 ? 0x00190001 271 271 : SUPDRV_IOC_VERSION & 0xffff0000; 272 272 CookieReq.u.In.u32MinVersion = uMinVersion; -
trunk/src/VBox/VMM/Makefile.kmk
r40595 r40636 466 466 467 467 VMMR0_SOURCES = \ 468 VBoxVMM.d \ 468 469 VMMR0/CPUMR0.cpp \ 469 VBoxVMM.d \470 470 VMMR0/CPUMR0A.asm \ 471 471 VMMR0/GMMR0.cpp \ -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r40424 r40636 53 53 #include <iprt/timer.h> 54 54 55 #include "dtrace/VBoxVMM.h" 56 57 55 58 #if defined(_MSC_VER) && defined(RT_ARCH_AMD64) /** @todo check this with with VC7! */ 56 59 # pragma intrinsic(_AddressOfReturnAddress) … … 62 65 *******************************************************************************/ 63 66 RT_C_DECLS_BEGIN 64 VMMR0DECL(int) ModuleInit(void);65 VMMR0DECL(void) ModuleTerm(void );67 VMMR0DECL(int) ModuleInit(void *hMod); 68 VMMR0DECL(void) ModuleTerm(void *hMod); 66 69 67 70 #if defined(RT_ARCH_X86) && (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)) … … 101 104 * @returns 0 on success. 102 105 * @returns VBox status on failure. 103 */ 104 VMMR0DECL(int) ModuleInit(void) 105 { 106 * @param hMod Image handle for use in APIs. 107 */ 108 VMMR0DECL(int) ModuleInit(void *hMod) 109 { 110 #ifdef VBOX_WITH_DTRACE_R0 111 /* 112 * The first thing to do is register the static tracepoints. 113 * (Deregistration is automatic.) 114 */ 115 int rc2 = SUPR0VtgRegisterModule(hMod, &g_VTGObjHeader); 116 if (RT_FAILURE(rc2)) 117 return rc2; 118 #endif 106 119 LogFlow(("ModuleInit:\n")); 107 120 … … 184 197 /** 185 198 * Terminate the module. 186 * This is called when we're finally unloaded. 187 */ 188 VMMR0DECL(void) ModuleTerm(void) 199 * This is called when we're finally unloaded. 200 * 201 * @param hMod Image handle for use in APIs. 202 */ 203 VMMR0DECL(void) ModuleTerm(void *hMod) 189 204 { 190 205 LogFlow(("ModuleTerm:\n")); -
trunk/src/bldprogs/VBoxTpG.cpp
r40619 r40636 160 160 static unsigned g_cAssemblerOptions = 0; 161 161 static const char *g_apszAssemblerOptions[32]; 162 static const char *g_pszProbeFnName = "SUPR0 FireProbe";162 static const char *g_pszProbeFnName = "SUPR0VtgFireProbe"; 163 163 static bool g_fProbeFnImported = true; 164 164 /** @} */ … … 930 930 ScmStreamPrintf(pStrm, 931 931 "); \\\n" 932 " } \\\n"); 932 " } \\\n" 933 " { \\\n" ); 933 934 RTListForEach(&pProbe->ArgHead, pArg, VTGARG, ListEntry) 934 935 { … … 940 941 } 941 942 ScmStreamPrintf(pStrm, 943 " } \\\n" 942 944 " } while (0)\n" 943 945 "\n");
Note:
See TracChangeset
for help on using the changeset viewer.