Changeset 20135 in vbox
- Timestamp:
- May 29, 2009 7:44:12 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMInternal.h
r20129 r20135 1581 1581 1582 1582 1583 typedef enum 1584 { 1585 PGMPOOLACCESS_DONTCARE = 0, 1586 PGMPOOLACCESS_USER_RW, 1587 PGMPOOLACCESS_USER_R, 1588 PGMPOOLACCESS_SUPERVISOR_RW, 1589 PGMPOOLACCESS_SUPERVISOR_R 1590 } PGMPOOLACCESS; 1591 1583 1592 /** 1584 1593 * The tracking data for a page in the pool. … … 1601 1610 /** The kind of page we're shadowing. (This is really a PGMPOOLKIND enum.) */ 1602 1611 uint8_t enmKind; 1603 uint8_t bPadding; 1612 /** The subkind of page we're shadowing. (This is really a PGMPOOLACCESS enum.) */ 1613 uint8_t enmAccess; 1604 1614 /** The index of this page. */ 1605 1615 uint16_t idx; … … 2959 2969 int pgmR0DynMapHCPageCommon(PVM pVM, PPGMMAPSET pSet, RTHCPHYS HCPhys, void **ppv); 2960 2970 #endif 2961 int pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage); 2971 int pgmPoolAllocEx(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage); 2972 2973 DECLINLINE(int) pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage) 2974 { 2975 return pgmPoolAllocEx(pVM, GCPhys, enmKind, PGMPOOLACCESS_DONTCARE, iUser, iUserTable, ppPage); 2976 } 2977 2962 2978 void pgmPoolFree(PVM pVM, RTHCPHYS HCPhys, uint16_t iUser, uint32_t iUserTable); 2963 2979 void pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable); -
trunk/src/VBox/VMM/PGMPhys.cpp
r20129 r20135 3233 3233 else 3234 3234 { 3235 /* Temporaril iy disabled phycial handler(s), since the recompiler3236 doesn't get notified when it's reset we'll have to pretend it s3235 /* Temporarily disabled physical handler(s), since the recompiler 3236 doesn't get notified when it's reset we'll have to pretend it's 3237 3237 operating normally. */ 3238 3238 if (pgmHandlerPhysicalIsAll(pVM, GCPhys)) … … 3266 3266 *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK)); 3267 3267 /** @todo mapping/locking hell; this isn't horribly efficient since 3268 * pgmPhysPageLoadIntoTlb will repeat ethe lookup we've done here. */3268 * pgmPhysPageLoadIntoTlb will repeat the lookup we've done here. */ 3269 3269 3270 3270 Log6(("PGMR3PhysTlbGCPhys2Ptr: GCPhys=%RGp rc=%Rrc pPage=%R[pgmpage] *ppv=%p\n", GCPhys, rc, pPage, *ppv)); -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r20129 r20135 1188 1188 if (PdeSrc.n.u1Present) 1189 1189 { 1190 # ifndef PGM_WITHOUT_MAPPING 1190 1191 if (PdeDst.u & PGM_PDFLAGS_MAPPING) 1191 1192 { … … 1199 1200 pgmUnlock(pVM); 1200 1201 } 1201 else if ( PdeSrc.n.u1User != PdeDst.n.u1User 1202 || (!PdeSrc.n.u1Write && PdeDst.n.u1Write)) 1202 else 1203 # endif /* !PGM_WITHOUT_MAPPING */ 1204 if ( PdeSrc.n.u1User != PdeDst.n.u1User 1205 || (!PdeSrc.n.u1Write && PdeDst.n.u1Write)) 1203 1206 { 1204 1207 /* … … 2589 2592 else 2590 2593 { 2594 PGMPOOLACCESS enmAccess; 2595 2591 2596 GCPhys = GST_GET_PDE_BIG_PG_GCPHYS(PdeSrc); 2592 2597 # if PGM_SHW_TYPE == PGM_TYPE_PAE && PGM_GST_TYPE == PGM_TYPE_32BIT … … 2594 2599 GCPhys |= GCPtrPage & (1 << X86_PD_PAE_SHIFT); 2595 2600 # endif 2596 rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_BIG, pShwPde->idx, iPDDst, &pShwPage); 2601 /* Determine the right kind of large page to avoid incorrect cached entry reuse. */ 2602 if (PdeSrc.n.u1User) 2603 { 2604 if (PdeSrc.n.u1Write) 2605 enmAccess = PGMPOOLACCESS_USER_RW; 2606 else 2607 enmAccess = PGMPOOLACCESS_USER_R; 2608 } 2609 else 2610 { 2611 if (PdeSrc.n.u1Write) 2612 enmAccess = PGMPOOLACCESS_SUPERVISOR_RW; 2613 else 2614 enmAccess = PGMPOOLACCESS_SUPERVISOR_R; 2615 } 2616 rc = pgmPoolAllocEx(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_BIG, enmAccess, pShwPde->idx, iPDDst, &pShwPage); 2597 2617 } 2598 2618 if (rc == VINF_SUCCESS) … … 3331 3351 #endif /* PGM_GST_TYPE != PGM_TYPE_32BIT */ 3332 3352 } 3333 3334 3335 #if PGM_GST_TYPE == PGM_TYPE_32BIT || PGM_GST_TYPE == PGM_TYPE_PAE || PGM_GST_TYPE == PGM_TYPE_AMD643336 # if PGM_SHW_TYPE == PGM_TYPE_32BIT || PGM_SHW_TYPE == PGM_TYPE_PAE || PGM_SHW_TYPE == PGM_TYPE_AMD643337 /**3338 * Figures out which kind of shadow page this guest PDE warrants.3339 *3340 * @returns Shadow page kind.3341 * @param pPdeSrc The guest PDE in question.3342 * @param cr4 The current guest cr4 value.3343 */3344 DECLINLINE(PGMPOOLKIND) PGM_BTH_NAME(CalcPageKind)(const GSTPDE *pPdeSrc, uint32_t cr4)3345 {3346 # if PMG_GST_TYPE == PGM_TYPE_AMD643347 if (!pPdeSrc->n.u1Size)3348 # else3349 if (!pPdeSrc->n.u1Size || !(cr4 & X86_CR4_PSE))3350 # endif3351 return BTH_PGMPOOLKIND_PT_FOR_PT;3352 //switch (pPdeSrc->u & (X86_PDE4M_RW | X86_PDE4M_US /*| X86_PDE4M_PAE_NX*/))3353 //{3354 // case 0:3355 // return BTH_PGMPOOLKIND_PT_FOR_BIG_RO;3356 // case X86_PDE4M_RW:3357 // return BTH_PGMPOOLKIND_PT_FOR_BIG_RW;3358 // case X86_PDE4M_US:3359 // return BTH_PGMPOOLKIND_PT_FOR_BIG_US;3360 // case X86_PDE4M_RW | X86_PDE4M_US:3361 // return BTH_PGMPOOLKIND_PT_FOR_BIG_RW_US;3362 # if 03363 // case X86_PDE4M_PAE_NX:3364 // return BTH_PGMPOOLKIND_PT_FOR_BIG_NX;3365 // case X86_PDE4M_RW | X86_PDE4M_PAE_NX:3366 // return BTH_PGMPOOLKIND_PT_FOR_BIG_RW_NX;3367 // case X86_PDE4M_US | X86_PDE4M_PAE_NX:3368 // return BTH_PGMPOOLKIND_PT_FOR_BIG_US_NX;3369 // case X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PAE_NX:3370 // return BTH_PGMPOOLKIND_PT_FOR_BIG_RW_US_NX;3371 # endif3372 return BTH_PGMPOOLKIND_PT_FOR_BIG;3373 //}3374 }3375 # endif3376 #endif3377 3353 3378 3354 #undef MY_STAM_COUNTER_INC -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r20058 r20135 1429 1429 * @param ppPage Where to store the pointer to the page. 1430 1430 */ 1431 static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage)1431 static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage) 1432 1432 { 1433 1433 #ifndef IN_RC … … 1447 1447 if (pPage->GCPhys == GCPhys) 1448 1448 { 1449 if ((PGMPOOLKIND)pPage->enmKind == enmKind) 1449 if ( (PGMPOOLKIND)pPage->enmKind == enmKind 1450 && (PGMPOOLACCESS)pPage->enmAccess == enmAccess) 1450 1451 { 1451 1452 /* Put it at the start of the use list to make sure pgmPoolTrackAddUser … … 1465 1466 } 1466 1467 1467 /* 1468 * The kind is different. In some cases we should now flush the page 1469 * as it has been reused, but in most cases this is normal remapping 1470 * of PDs as PT or big pages using the GCPhys field in a slightly 1471 * different way than the other kinds. 1472 */ 1473 if (pgmPoolCacheReusedByKind((PGMPOOLKIND)pPage->enmKind, enmKind)) 1468 if ((PGMPOOLKIND)pPage->enmKind != enmKind) 1474 1469 { 1475 STAM_COUNTER_INC(&pPool->StatCacheKindMismatches); 1476 pgmPoolFlushPage(pPool, pPage); 1477 PGM_INVL_VCPU_TLBS(VMMGetCpu(pVM)); /* see PT handler. */ 1478 break; 1470 /* 1471 * The kind is different. In some cases we should now flush the page 1472 * as it has been reused, but in most cases this is normal remapping 1473 * of PDs as PT or big pages using the GCPhys field in a slightly 1474 * different way than the other kinds. 1475 */ 1476 if (pgmPoolCacheReusedByKind((PGMPOOLKIND)pPage->enmKind, enmKind)) 1477 { 1478 STAM_COUNTER_INC(&pPool->StatCacheKindMismatches); 1479 pgmPoolFlushPage(pPool, pPage); 1480 PGM_INVL_VCPU_TLBS(VMMGetCpu(pVM)); /* see PT handler. */ 1481 break; 1482 } 1479 1483 } 1480 1484 } … … 3916 3920 pPool->iFreeHead = pPage->idx; 3917 3921 pPage->enmKind = PGMPOOLKIND_FREE; 3922 pPage->enmAccess = PGMPOOLACCESS_DONTCARE; 3918 3923 pPage->GCPhys = NIL_RTGCPHYS; 3919 3924 pPage->fReusedFlushPending = false; … … 4018 4023 #endif 4019 4024 } 4020 4021 4025 4022 4026 /** … … 4035 4039 * shadow PT is covering. 4036 4040 * @param enmKind The kind of mapping. 4041 * @param enmAccess Access type for the mapping (only relevant for big pages) 4037 4042 * @param iUser The shadow page pool index of the user table. 4038 4043 * @param iUserTable The index into the user table (shadowed). 4039 4044 * @param ppPage Where to store the pointer to the page. NULL is stored here on failure. 4040 4045 */ 4041 int pgmPoolAlloc (PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage)4046 int pgmPoolAllocEx(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage) 4042 4047 { 4043 4048 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); … … 4054 4059 if (pPool->fCacheEnabled) 4055 4060 { 4056 int rc2 = pgmPoolCacheAlloc(pPool, GCPhys, enmKind, iUser, iUserTable, ppPage);4061 int rc2 = pgmPoolCacheAlloc(pPool, GCPhys, enmKind, enmAccess, iUser, iUserTable, ppPage); 4057 4062 if (RT_SUCCESS(rc2)) 4058 4063 { … … 4094 4099 pPool->cUsedPages++; /* physical handler registration / pgmPoolTrackFlushGCPhysPTsSlow requirement. */ 4095 4100 pPage->enmKind = enmKind; 4101 pPage->enmAccess = enmAccess; 4096 4102 pPage->GCPhys = GCPhys; 4097 4103 pPage->fSeenNonGlobal = false; /* Set this to 'true' to disable this feature. */ … … 4117 4123 { 4118 4124 pPool->cUsedPages--; 4119 pPage->enmKind = PGMPOOLKIND_FREE; 4120 pPage->GCPhys = NIL_RTGCPHYS; 4121 pPage->iNext = pPool->iFreeHead; 4122 pPool->iFreeHead = pPage->idx; 4125 pPage->enmKind = PGMPOOLKIND_FREE; 4126 pPage->enmAccess = PGMPOOLACCESS_DONTCARE; 4127 pPage->GCPhys = NIL_RTGCPHYS; 4128 pPage->iNext = pPool->iFreeHead; 4129 pPool->iFreeHead = pPage->idx; 4123 4130 pgmUnlock(pVM); 4124 4131 STAM_PROFILE_ADV_STOP(&pPool->StatAlloc, a); … … 4244 4251 pPage->cModifications = 0; 4245 4252 #endif 4246 pPage->GCPhys = NIL_RTGCPHYS; 4247 pPage->enmKind = PGMPOOLKIND_FREE; 4253 pPage->GCPhys = NIL_RTGCPHYS; 4254 pPage->enmKind = PGMPOOLKIND_FREE; 4255 pPage->enmAccess = PGMPOOLACCESS_DONTCARE; 4248 4256 Assert(pPage->idx == i); 4249 pPage->iNext = i + 1;4250 pPage->fZeroed = false; /* This could probably be optimized, but better safe than sorry. */4257 pPage->iNext = i + 1; 4258 pPage->fZeroed = false; /* This could probably be optimized, but better safe than sorry. */ 4251 4259 pPage->fSeenNonGlobal = false; 4252 pPage->fMonitored = false;4253 pPage->fCached = false;4260 pPage->fMonitored = false; 4261 pPage->fCached = false; 4254 4262 pPage->fReusedFlushPending = false; 4255 4263 #ifdef PGMPOOL_WITH_USER_TRACKING 4256 pPage->iUserHead = NIL_PGMPOOL_USER_INDEX;4264 pPage->iUserHead = NIL_PGMPOOL_USER_INDEX; 4257 4265 #else 4258 pPage->fCR3Mix = false;4266 pPage->fCR3Mix = false; 4259 4267 #endif 4260 4268 #ifdef PGMPOOL_WITH_CACHE 4261 pPage->iAgeNext = NIL_PGMPOOL_IDX;4262 pPage->iAgePrev = NIL_PGMPOOL_IDX;4263 #endif 4264 pPage->cLocked = 0;4269 pPage->iAgeNext = NIL_PGMPOOL_IDX; 4270 pPage->iAgePrev = NIL_PGMPOOL_IDX; 4271 #endif 4272 pPage->cLocked = 0; 4265 4273 } 4266 4274 pPool->aPages[pPool->cCurPages - 1].iNext = NIL_PGMPOOL_IDX; -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r20087 r20135 649 649 GEN_CHECK_OFF(PGMPOOLPAGE, pvPageR3); 650 650 GEN_CHECK_OFF(PGMPOOLPAGE, enmKind); 651 GEN_CHECK_OFF(PGMPOOLPAGE, bPadding);651 GEN_CHECK_OFF(PGMPOOLPAGE, enmAccess); 652 652 GEN_CHECK_OFF(PGMPOOLPAGE, idx); 653 653 GEN_CHECK_OFF(PGMPOOLPAGE, iNext);
Note:
See TracChangeset
for help on using the changeset viewer.