Changeset 28986 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- May 3, 2010 3:55:30 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r28974 r28986 484 484 485 485 /** Shared module tree (global). */ 486 PAVLGCPTRNODECORE p SharedModuleTree;486 PAVLGCPTRNODECORE pGlobalSharedModuleTree; 487 487 488 488 /** The maximum number of pages we're allowed to allocate. … … 3398 3398 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 3399 3399 { 3400 /* Check if this module was already globally registered. */ 3401 PGMMSHAREDMODULE pRec = (PGMMSHAREDMODULE)RTAvlGCPtrGet(&pGMM->pSharedModuleTree, GCBaseAddr); 3402 if (!pRec) 3403 { 3404 pRec = (PGMMSHAREDMODULE)RTMemAllocZ(RT_OFFSETOF(GMMSHAREDMODULE, aRegions[cRegions])); 3405 pRec->Core.Key = GCBaseAddr; 3406 pRec->cbModule = cbModule; 3407 /* Input limit already safe; no need to check again. */ 3408 strcpy(pRec->szName, pszModuleName); 3409 strcpy(pRec->szVersion, pszVersion); 3410 3411 pRec->cRegions = cRegions; 3412 3413 for (unsigned i = 0; i < cRegions; i++) 3414 pRec->aRegions[i] = pRegions[i]; 3415 3416 /** @todo references to pages */ 3400 /* Check if this module is already locally registered. */ 3401 PGMMSHAREDMODULEPERVM pRecVM = (PGMMSHAREDMODULEPERVM)RTAvlGCPtrGet(&pGVM->gmm.s.pSharedModuleTree, GCBaseAddr); 3402 if (!pRecVM) 3403 { 3404 pRecVM = (PGMMSHAREDMODULEPERVM)RTMemAllocZ(sizeof(*pRecVM)); 3405 if (!pRecVM) 3406 { 3407 AssertFailed(); 3408 rc = VERR_NO_MEMORY; 3409 goto end; 3410 } 3411 3412 pRecVM->Core.Key = GCBaseAddr; 3413 3414 bool ret = RTAvlGCPtrInsert(&pGVM->gmm.s.pSharedModuleTree, &pRecVM->Core); 3415 Assert(ret); 3416 3417 /* Check if this module is already globally registered. */ 3418 PGMMSHAREDMODULE pRec = (PGMMSHAREDMODULE)RTAvlGCPtrGet(&pGMM->pGlobalSharedModuleTree, GCBaseAddr); 3419 if (!pRec) 3420 { 3421 pRec = (PGMMSHAREDMODULE)RTMemAllocZ(RT_OFFSETOF(GMMSHAREDMODULE, aRegions[cRegions])); 3422 if (!pRec) 3423 { 3424 AssertFailed(); 3425 rc = VERR_NO_MEMORY; 3426 goto end; 3427 } 3428 3429 pRec->Core.Key = GCBaseAddr; 3430 pRec->cbModule = cbModule; 3431 /* Input limit already safe; no need to check again. */ 3432 strcpy(pRec->szName, pszModuleName); 3433 strcpy(pRec->szVersion, pszVersion); 3434 3435 pRec->cRegions = cRegions; 3436 3437 for (unsigned i = 0; i < cRegions; i++) 3438 pRec->aRegions[i] = pRegions[i]; 3439 3440 /* Save reference. */ 3441 pRecVM->pSharedModule = pRec; 3442 } 3443 else 3444 { 3445 Assert(pRecVM->pSharedModule == pRec); 3446 Assert(pRec->cUsers > 0); 3447 } 3448 pRec->cUsers++; 3417 3449 } 3418 3450 else 3419 { 3420 } 3451 rc = VINF_PGM_SHARED_MODULE_ALREADY_REGISTERED; 3421 3452 3422 3453 GMM_CHECK_SANITY_UPON_LEAVING(pGMM); … … 3425 3456 rc = VERR_INTERNAL_ERROR_5; 3426 3457 3458 end: 3427 3459 RTSemFastMutexRelease(pGMM->Mtx); 3428 3460 return rc; … … 3467 3499 { 3468 3500 #ifdef VBOX_WITH_PAGE_SHARING 3469 return VERR_NOT_IMPLEMENTED; 3501 /* 3502 * Validate input and get the basics. 3503 */ 3504 PGMM pGMM; 3505 GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR); 3506 PGVM pGVM; 3507 int rc = GVMMR0ByVMAndEMT(pVM, idCpu, &pGVM); 3508 if (RT_FAILURE(rc)) 3509 return rc; 3510 3511 /* 3512 * Take the sempahore and do some more validations. 3513 */ 3514 rc = RTSemFastMutexRequest(pGMM->Mtx); 3515 AssertRC(rc); 3516 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 3517 { 3518 PGMMSHAREDMODULEPERVM pRecVM = (PGMMSHAREDMODULEPERVM)RTAvlGCPtrGet(&pGVM->gmm.s.pSharedModuleTree, GCBaseAddr); 3519 if (!pRecVM) 3520 { 3521 rc = VERR_PGM_SHARED_MODULE_NOT_FOUND; 3522 goto end; 3523 } 3524 PGMMSHAREDMODULE pRec = pRecVM->pSharedModule; 3525 Assert(pRec); 3526 Assert(pRec->cUsers); 3527 3528 pRec->cUsers--; 3529 if (pRec->cUsers == 0) 3530 { 3531 /* @todo free shared pages. */ 3532 RTMemFree(pRec); 3533 } 3534 RTMemFree(pRecVM); 3535 3536 GMM_CHECK_SANITY_UPON_LEAVING(pGMM); 3537 } 3538 else 3539 rc = VERR_INTERNAL_ERROR_5; 3540 3541 end: 3542 RTSemFastMutexRelease(pGMM->Mtx); 3543 return rc; 3470 3544 #else 3471 3545 return VERR_NOT_IMPLEMENTED; -
trunk/src/VBox/VMM/VMMR0/GMMR0Internal.h
r28806 r28986 39 39 40 40 /** 41 * Shared module registration info 41 * Shared module registration info (global) 42 42 */ 43 43 typedef struct GMMSHAREDMODULE … … 49 49 /** Number of included region descriptors */ 50 50 uint32_t cRegions; 51 /** Number of users (VMs). */ 52 uint32_t cUsers; 53 /** Align. */ 54 uint32_t u32Align; 51 55 /** Module name */ 52 56 char szName[GMM_SHARED_MODULE_MAX_NAME_STRING]; … … 56 60 VMMDEVSHAREDREGIONDESC aRegions[1]; 57 61 } GMMSHAREDMODULE; 58 /** Pointer to a GMM MODULE. */62 /** Pointer to a GMMSHAREDMODULE. */ 59 63 typedef GMMSHAREDMODULE *PGMMSHAREDMODULE; 64 65 /** 66 * Shared module registration info (per VM) 67 */ 68 typedef struct GMMSHAREDMODULEPERVM 69 { 70 /* Tree node. */ 71 AVLGCPTRNODECORE Core; 72 73 /* Pointer to global shared module info. */ 74 PGMMSHAREDMODULE pSharedModule; 75 76 } GMMSHAREDMODULEPERVM; 77 /** Pointer to a GMMSHAREDMODULEPERVM. */ 78 typedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM; 60 79 61 80 /** … … 93 112 uint64_t cReqDeflatePages; 94 113 114 /** Shared module tree (per-vm). */ 115 PAVLGCPTRNODECORE pSharedModuleTree; 116 95 117 /** Whether ballooning is enabled or not. */ 96 118 bool fBallooningEnabled;
Note:
See TracChangeset
for help on using the changeset viewer.