Changeset 37153 in vbox for trunk/src/VBox
- Timestamp:
- May 19, 2011 12:54:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r36984 r37153 4457 4457 { 4458 4458 PGMMCHUNK pChunk = (PGMMCHUNK)pNode; 4459 PGMMFINDDUPPAGEINFO pInfo = (PGMMFINDDUPPAGEINFO)pvInfo;4460 PGVM pGVM = pInfo->pGVM;4461 PGMM pGMM = pInfo->pGMM;4459 PGMMFINDDUPPAGEINFO pInfo = (PGMMFINDDUPPAGEINFO)pvInfo; 4460 PGVM pGVM = pInfo->pGVM; 4461 PGMM pGMM = pInfo->pGMM; 4462 4462 uint8_t *pbChunk; 4463 4463 … … 4466 4466 { 4467 4467 int rc = gmmR0MapChunk(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk); 4468 if (rc != VINF_SUCCESS) 4469 goto end; 4470 4471 /* 4472 * Look for duplicate pages 4473 */ 4474 unsigned iPage = (GMM_CHUNK_SIZE >> PAGE_SHIFT); 4475 while (iPage-- > 0) 4476 { 4477 if (GMM_PAGE_IS_PRIVATE(&pChunk->aPages[iPage])) 4478 { 4479 uint8_t *pbDestPage = pbChunk + (iPage << PAGE_SHIFT); 4480 4481 if (!memcmp(pInfo->pSourcePage, pbDestPage, PAGE_SIZE)) 4468 if (RT_SUCCESS(rc)) 4469 { 4470 /* 4471 * Look for duplicate pages 4472 */ 4473 unsigned iPage = (GMM_CHUNK_SIZE >> PAGE_SHIFT); 4474 while (iPage-- > 0) 4475 { 4476 if (GMM_PAGE_IS_PRIVATE(&pChunk->aPages[iPage])) 4482 4477 { 4483 pInfo->fFoundDuplicate = true; 4484 break; 4478 uint8_t *pbDestPage = pbChunk + (iPage << PAGE_SHIFT); 4479 4480 if (!memcmp(pInfo->pSourcePage, pbDestPage, PAGE_SIZE)) 4481 { 4482 pInfo->fFoundDuplicate = true; 4483 break; 4484 } 4485 4485 } 4486 4486 } 4487 } 4488 gmmR0UnmapChunk(pGMM, pGVM, pChunk); 4489 } 4490 end: 4491 if (pInfo->fFoundDuplicate) 4492 return 1; /* stop search */ 4493 else 4494 return 0; 4487 gmmR0UnmapChunk(pGMM, pGVM, pChunk); 4488 } 4489 } 4490 return pInfo->fFoundDuplicate; /* (stops search if true) */ 4495 4491 } 4496 4492 … … 4515 4511 GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR); 4516 4512 4513 PGVM pGVM; 4514 int rc = GVMMR0ByVM(pVM, &pGVM); 4515 if (RT_FAILURE(rc)) 4516 return rc; 4517 4517 4518 /* 4518 4519 * Take the semaphore and do some more validations. 4519 4520 */ 4520 intrc = gmmR0MutexAcquire(pGMM);4521 rc = gmmR0MutexAcquire(pGMM); 4521 4522 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 4522 4523 { 4523 PGVM pGVM;4524 rc = GVMMR0ByVM(pVM, &pGVM);4525 if (RT_FAILURE(rc))4526 goto end;4527 4528 4524 uint8_t *pbChunk; 4529 4525 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, pReq->idPage >> GMM_CHUNKID_SHIFT); 4530 if (!pChunk) 4531 { 4526 if (pChunk) 4527 { 4528 if (gmmR0IsChunkMapped(pGVM, pChunk, (PRTR3PTR)&pbChunk)) 4529 { 4530 uint8_t *pbSourcePage = pbChunk + ((pReq->idPage & GMM_PAGEID_IDX_MASK) << PAGE_SHIFT); 4531 PGMMPAGE pPage = gmmR0GetPage(pGMM, pReq->idPage); 4532 if (pPage) 4533 { 4534 GMMFINDDUPPAGEINFO Info; 4535 Info.pGVM = pGVM; 4536 Info.pGMM = pGMM; 4537 Info.pSourcePage = pbSourcePage; 4538 Info.fFoundDuplicate = false; 4539 RTAvlU32DoWithAll(&pGMM->pChunks, true /* fFromLeft */, gmmR0FindDupPageInChunk, &Info); 4540 4541 pReq->fDuplicate = Info.fFoundDuplicate; 4542 } 4543 else 4544 { 4545 AssertFailed(); 4546 rc = VERR_PGM_PHYS_INVALID_PAGE_ID; 4547 } 4548 } 4549 else 4550 AssertFailed(); 4551 } 4552 else 4532 4553 AssertFailed(); 4533 goto end;4534 }4535 4536 if (!gmmR0IsChunkMapped(pGVM, pChunk, (PRTR3PTR)&pbChunk))4537 {4538 AssertFailed();4539 goto end;4540 }4541 4542 uint8_t *pbSourcePage = pbChunk + ((pReq->idPage & GMM_PAGEID_IDX_MASK) << PAGE_SHIFT);4543 4544 PGMMPAGE pPage = gmmR0GetPage(pGMM, pReq->idPage);4545 if (!pPage)4546 {4547 AssertFailed();4548 rc = VERR_PGM_PHYS_INVALID_PAGE_ID;4549 goto end;4550 }4551 GMMFINDDUPPAGEINFO Info;4552 4553 Info.pGVM = pGVM;4554 Info.pGMM = pGMM;4555 Info.pSourcePage = pbSourcePage;4556 Info.fFoundDuplicate = false;4557 RTAvlU32DoWithAll(&pGMM->pChunks, true /* fFromLeft */, gmmR0FindDupPageInChunk, &Info);4558 4559 pReq->fDuplicate = Info.fFoundDuplicate;4560 4554 } 4561 4555 else 4562 4556 rc = VERR_INTERNAL_ERROR_5; 4563 4557 4564 end:4565 4558 gmmR0MutexRelease(pGMM); 4566 4559 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.