Changeset 38955 in vbox for trunk/src/VBox
- Timestamp:
- Oct 6, 2011 12:23:39 PM (13 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r38953 r38955 1063 1063 STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,ChunkR3MapTlbHits)); 1064 1064 pMap = pTlbe->pChunk; 1065 AssertPtr(pMap->pv); 1065 1066 } 1066 1067 else … … 1072 1073 */ 1073 1074 pMap = (PPGMCHUNKR3MAP)RTAvlU32Get(&pVM->pgm.s.ChunkR3Map.pTree, idChunk); 1074 if (!pMap) 1075 if (pMap) 1076 AssertPtr(pMap->pv); 1077 else 1075 1078 { 1076 1079 #ifdef IN_RING0 … … 1084 1087 return rc; 1085 1088 #endif 1089 AssertPtr(pMap->pv); 1086 1090 } 1087 1091 -
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r38953 r38955 3769 3769 static DECLCALLBACK(int) pgmR3PhysChunkUnmapCandidateCallback(PAVLU32NODECORE pNode, void *pvUser) 3770 3770 { 3771 PPGMCHUNKR3MAP pChunk = (PPGMCHUNKR3MAP)pNode; 3772 PPGMR3PHYSCHUNKUNMAPCB pArg = (PPGMR3PHYSCHUNKUNMAPCB)pvUser; 3773 3774 if ( pChunk->iAge 3775 && !pChunk->cRefs 3776 && pArg->iLastAge < pChunk->iAge) 3777 { 3778 /* 3779 * Check that it's not in any of the TLBs. 3780 */ 3781 PVM pVM = pArg->pVM; 3782 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.ChunkR3Map.Tlb.aEntries); i++) 3783 if (pVM->pgm.s.ChunkR3Map.Tlb.aEntries[i].pChunk == pChunk) 3784 { 3785 pChunk = NULL; 3786 break; 3787 } 3788 if (pChunk) 3789 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.PhysTlbHC.aEntries); i++) 3790 if (pVM->pgm.s.PhysTlbHC.aEntries[i].pMap == pChunk) 3791 { 3792 pChunk = NULL; 3793 break; 3794 } 3795 if (pChunk) 3796 { 3797 pArg->pChunk = pChunk; 3798 pArg->iLastAge = pChunk->iAge; 3799 } 3800 } 3771 PPGMCHUNKR3MAP pChunk = (PPGMCHUNKR3MAP)pNode; 3772 PPGMR3PHYSCHUNKUNMAPCB pArg = (PPGMR3PHYSCHUNKUNMAPCB)pvUser; 3773 3774 /* 3775 * Check for locks and age. 3776 */ 3777 if (pChunk->cRefs) 3778 return 0; 3779 if (!pChunk->iAge) 3780 return 0; 3781 if (pArg->iLastAge >= pChunk->iAge) 3782 return 0; 3783 3784 /* 3785 * Check that it's not in any of the TLBs. 3786 */ 3787 PVM pVM = pArg->pVM; 3788 if ( pVM->pgm.s.ChunkR3Map.Tlb.aEntries[PGM_CHUNKR3MAPTLB_IDX(pChunk->Core.Key)].idChunk 3789 == pChunk->Core.Key) 3790 { 3791 pChunk = NULL; 3792 return 0; 3793 } 3794 #ifdef VBOX_STRICT 3795 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.ChunkR3Map.Tlb.aEntries); i++) 3796 { 3797 Assert(pVM->pgm.s.ChunkR3Map.Tlb.aEntries[i].pChunk != pChunk); 3798 Assert(pVM->pgm.s.ChunkR3Map.Tlb.aEntries[i].idChunk != pChunk->Core.Key); 3799 } 3800 #endif 3801 3802 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.PhysTlbHC.aEntries); i++) 3803 if (pVM->pgm.s.PhysTlbHC.aEntries[i].pMap == pChunk) 3804 return 0; 3805 3806 pArg->pChunk = pChunk; 3807 pArg->iLastAge = pChunk->iAge; 3801 3808 return 0; 3802 3809 } … … 3838 3845 if (Args.pChunk) 3839 3846 { 3847 Assert(Args.pChunk->cRefs == 0); 3848 Assert(Args.pChunk->cPermRefs == 0); 3840 3849 STAM_PROFILE_STOP(&pVM->pgm.s.CTX_SUFF(pStats)->StatChunkFindCandidate, a); 3841 3850 return Args.pChunk->Core.Key; … … 3845 3854 return INT32_MAX; 3846 3855 } 3856 3847 3857 3848 3858 /** … … 3866 3876 { 3867 3877 /* Flush the pgm pool cache; call the internal rendezvous handler as we're already in a rendezvous handler here. */ 3868 /* todo: also not really efficient to unmap a chunk that contains PD or PT pages. */ 3878 /** @todo also not really efficient to unmap a chunk that contains PD 3879 * or PT pages. */ 3869 3880 pgmR3PoolClearAllRendezvous(pVM, &pVM->aCpus[0], NULL /* no need to flush the REM TLB as we already did that above */); 3870 3881 … … 3874 3885 GMMMAPUNMAPCHUNKREQ Req; 3875 3886 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 3876 Req.Hdr.cbReq = sizeof(Req);3877 Req.pvR3 = NULL;3878 Req.idChunkMap = NIL_GMM_CHUNKID;3887 Req.Hdr.cbReq = sizeof(Req); 3888 Req.pvR3 = NULL; 3889 Req.idChunkMap = NIL_GMM_CHUNKID; 3879 3890 Req.idChunkUnmap = pgmR3PhysChunkFindUnmapCandidate(pVM); 3880 3881 3891 if (Req.idChunkUnmap != INT32_MAX) 3882 3892 { … … 3886 3896 if (RT_SUCCESS(rc)) 3887 3897 { 3888 /* remove the unmapped one. */ 3898 /* 3899 * Remove the unmapped one. 3900 */ 3889 3901 PPGMCHUNKR3MAP pUnmappedChunk = (PPGMCHUNKR3MAP)RTAvlU32Remove(&pVM->pgm.s.ChunkR3Map.pTree, Req.idChunkUnmap); 3890 3902 AssertRelease(pUnmappedChunk); 3891 pUnmappedChunk->pv = NULL; 3903 AssertRelease(!pUnmappedChunk->cRefs); 3904 AssertRelease(!pUnmappedChunk->cPermRefs); 3905 pUnmappedChunk->pv = NULL; 3892 3906 pUnmappedChunk->Core.Key = UINT32_MAX; 3893 3907 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE … … 3899 3913 pVM->pgm.s.cUnmappedChunks++; 3900 3914 3901 /* Flush dangling PGM pointers (R3 & R0 ptrs to GC physical addresses) */ 3902 /* todo: we should not flush chunks which include cr3 mappings. */ 3915 /* 3916 * Flush dangling PGM pointers (R3 & R0 ptrs to GC physical addresses). 3917 */ 3918 /** todo: we should not flush chunks which include cr3 mappings. */ 3903 3919 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 3904 3920 { … … 3993 4009 if (RT_SUCCESS(rc)) 3994 4010 { 3995 /*3996 * Update the tree.3997 */3998 /* insert the new one. */3999 AssertPtr(Req.pvR3);4000 pChunk->pv = Req.pvR3;4001 bool fRc = RTAvlU32Insert(&pVM->pgm.s.ChunkR3Map.pTree, &pChunk->Core);4002 AssertRelease(fRc);4003 pVM->pgm.s.ChunkR3Map.c++;4004 pVM->pgm.s.cMappedChunks++;4005 4006 4011 /* 4007 4012 * If we're running out of virtual address space, then we should … … 4021 4026 * map+unmap as one kernel call without any rendezvous or 4022 4027 * other precautions. */ 4023 if (pVM->pgm.s.ChunkR3Map.c >= pVM->pgm.s.ChunkR3Map.cMax)4028 if (pVM->pgm.s.ChunkR3Map.c + 1 >= pVM->pgm.s.ChunkR3Map.cMax) 4024 4029 { 4025 4030 switch (VMR3GetState(pVM)) … … 4043 4048 } 4044 4049 } 4050 4051 /* 4052 * Update the tree. We must do this after any unmapping to make sure 4053 * the chunk we're going to return isn't unmapped by accident. 4054 */ 4055 /* insert the new one. */ 4056 AssertPtr(Req.pvR3); 4057 pChunk->pv = Req.pvR3; 4058 bool fRc = RTAvlU32Insert(&pVM->pgm.s.ChunkR3Map.pTree, &pChunk->Core); 4059 AssertRelease(fRc); 4060 pVM->pgm.s.ChunkR3Map.c++; 4061 pVM->pgm.s.cMappedChunks++; 4045 4062 } 4046 4063 else -
trunk/src/VBox/VMM/include/PGMInline.h
r37354 r38955 491 491 STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbHits)); 492 492 rc = VINF_SUCCESS; 493 AssertPtr(pTlbe->pv); 494 Assert(!pTlbe->pMap || RT_VALID_PTR(pTlbe->pMap->pv)); 493 495 } 494 496 else
Note:
See TracChangeset
for help on using the changeset viewer.