- Timestamp:
- Aug 7, 2010 9:13:53 PM (14 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMInternal.h
r31402 r31446 319 319 * is no longer used. 320 320 * 321 * For best effect only apply this to the page that was mapped most recently. 322 * 321 323 * @param pVCpu The current CPU. 322 324 * @param pPage The pool page. … … 335 337 * Hints to the dynamic mapping code in RC and R0/darwin that the specified page 336 338 * is no longer used. 339 * 340 * For best effect only apply this to the page that was mapped most recently. 337 341 * 338 342 * @param pVM The VM handle. -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r31402 r31446 1070 1070 int rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 1071 1071 pgmPoolTrackCheckPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst); 1072 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 1073 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw); 1072 1074 } 1073 1075 #endif … … 1344 1346 unsigned LastPTE = ~0U; /* initialized to shut up gcc */ 1345 1347 RTHCPHYS LastHCPhys = NIL_RTHCPHYS; /* initialized to shut up gcc */ 1348 PVM pVM = pPool->CTX_SUFF(pVM); 1346 1349 1347 1350 #ifdef VBOX_STRICT … … 1354 1357 { 1355 1358 RTHCPHYS HCPhys = NIL_RTHCPHYS; 1356 int rc = PGMPhysGCPhys2HCPhys(p Pool->CTX_SUFF(pVM), pGstPT->a[i].u & X86_PTE_PAE_PG_MASK, &HCPhys);1359 int rc = PGMPhysGCPhys2HCPhys(pVM, pGstPT->a[i].u & X86_PTE_PAE_PG_MASK, &HCPhys); 1357 1360 if ( rc != VINF_SUCCESS 1358 1361 || (pShwPT->a[i].u & X86_PTE_PAE_PG_MASK) != HCPhys) … … 1365 1368 1366 1369 RTHCPHYS HCPhysPT = NIL_RTHCPHYS; 1367 rc = PGMPhysGCPhys2HCPhys(p Pool->CTX_SUFF(pVM), pPage->GCPhys, &HCPhysPT);1370 rc = PGMPhysGCPhys2HCPhys(pVM, pPage->GCPhys, &HCPhysPT); 1368 1371 AssertRC(rc); 1369 1372 … … 1374 1377 if (pTempPage->enmKind == PGMPOOLKIND_PAE_PT_FOR_PAE_PT) 1375 1378 { 1376 PX86PTPAE pShwPT2 = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(p Pool->CTX_SUFF(pVM), pTempPage);1379 PX86PTPAE pShwPT2 = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pVM, pTempPage); 1377 1380 1378 1381 for (unsigned j = 0; j < RT_ELEMENTS(pShwPT->a); j++) … … 1385 1388 } 1386 1389 } 1390 1391 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pShwPT2); 1387 1392 } 1388 1393 } … … 1406 1411 * @param pfFlush Flush reused page table (out) 1407 1412 */ 1408 DECLINLINE(unsigned) pgmPoolTrackFlushPTPaePae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PTPAE pGstPT, PCX86PTPAE pOldGstPT, bool fAllowRemoval, bool *pfFlush) 1413 DECLINLINE(unsigned) pgmPoolTrackFlushPTPaePae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PTPAE pGstPT, 1414 PCX86PTPAE pOldGstPT, bool fAllowRemoval, bool *pfFlush) 1409 1415 { 1410 1416 unsigned cChanged = 0; … … 1511 1517 /* Flush those PTEs that have changed. */ 1512 1518 STAM_PROFILE_START(&pPool->StatTrackDeref,a); 1513 void *pvShw = PGMPOOL_PAGE_2_PTR(p Pool->CTX_SUFF(pVM), pPage);1519 void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage); 1514 1520 void *pvGst; 1521 rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 1515 1522 bool fFlush; 1516 rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 1517 unsigned cChanges = pgmPoolTrackFlushPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst, (PCX86PTPAE)&pPool->aDirtyPages[idxSlot][0], fAllowRemoval, &fFlush); 1523 unsigned cChanges = pgmPoolTrackFlushPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst, 1524 (PCX86PTPAE)&pPool->aDirtyPages[idxSlot][0], fAllowRemoval, &fFlush); 1525 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 1526 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw); 1518 1527 STAM_PROFILE_STOP(&pPool->StatTrackDeref,a); 1519 /* *Note: we might want to consider keeping the dirty page active in case there were many changes. */1528 /* Note: we might want to consider keeping the dirty page active in case there were many changes. */ 1520 1529 1521 1530 /* This page is likely to be modified again, so reduce the nr of modifications just a bit here. */ … … 1578 1587 Log(("Add dirty page %RGp (slot=%d)\n", pPage->GCPhys, idxFree)); 1579 1588 1580 /* Make a copy of the guest page table as we require valid GCPhys addresses when removing 1581 * references to physical pages. (the HCPhys linear lookup is *extremely* expensive!) 1582 */ 1583 void *pvShw = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 1589 /* 1590 * Make a copy of the guest page table as we require valid GCPhys addresses 1591 * when removing references to physical pages. 1592 * (The HCPhys linear lookup is *extremely* expensive!) 1593 */ 1584 1594 void *pvGst; 1585 int rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);1595 int rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 1586 1596 memcpy(&pPool->aDirtyPages[idxFree][0], pvGst, PAGE_SIZE); 1587 1597 #ifdef VBOX_STRICT 1598 void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage); 1588 1599 pgmPoolTrackCheckPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst); 1600 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw); 1589 1601 #endif 1602 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 1590 1603 1591 1604 STAM_COUNTER_INC(&pPool->StatDirtyPage); … … 2915 2928 LogFlow(("pgmPoolTrackFlushGCPhysPT: pPhysPage=%RHp iShw=%d iPte=%d cRefs=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw, iPte, cRefs)); 2916 2929 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); 2917 bool bRet= false;2930 bool fRet = false; 2918 2931 2919 2932 /* … … 2936 2949 const uint32_t u32 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P; 2937 2950 PX86PT pPT = (PX86PT)PGMPOOL_PAGE_2_PTR(pVM, pPage); 2938 uint32_t u32AndMask, u32OrMask; 2939 2940 u32AndMask = 0; 2941 u32OrMask = 0; 2951 uint32_t u32AndMask = 0; 2952 uint32_t u32OrMask = 0; 2942 2953 2943 2954 if (!fFlushPTEs) … … 2945 2956 switch (PGM_PAGE_GET_HNDL_PHYS_STATE(pPhysPage)) 2946 2957 { 2947 case PGM_PAGE_HNDL_PHYS_STATE_NONE: /** No handler installed. */2948 case PGM_PAGE_HNDL_PHYS_STATE_DISABLED: /** Monitoring is temporarily disabled. */2949 u32OrMask = X86_PTE_RW;2950 u32AndMask = UINT32_MAX;2951 bRet = true;2952 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep);2953 break;2954 2955 case PGM_PAGE_HNDL_PHYS_STATE_WRITE: /** Write access is monitored. */2956 u32OrMask = 0;2957 u32AndMask = ~X86_PTE_RW;2958 bRet = true;2959 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep);2960 break;2961 default:2962 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry);2963 break;2958 case PGM_PAGE_HNDL_PHYS_STATE_NONE: /** No handler installed. */ 2959 case PGM_PAGE_HNDL_PHYS_STATE_DISABLED: /** Monitoring is temporarily disabled. */ 2960 u32OrMask = X86_PTE_RW; 2961 u32AndMask = UINT32_MAX; 2962 fRet = true; 2963 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep); 2964 break; 2965 2966 case PGM_PAGE_HNDL_PHYS_STATE_WRITE: /** Write access is monitored. */ 2967 u32OrMask = 0; 2968 u32AndMask = ~X86_PTE_RW; 2969 fRet = true; 2970 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep); 2971 break; 2972 default: 2973 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 2974 break; 2964 2975 } 2965 2976 } … … 2986 2997 2987 2998 ASMAtomicWriteSize(&pPT->a[iPte].u, Pte.u); 2988 return bRet; 2999 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3000 return fRet; 2989 3001 } 2990 3002 #ifdef LOG_ENABLED … … 2997 3009 #endif 2998 3010 AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d u32=%RX32 poolkind=%x\n", cRefs, pPage->iFirstPresent, pPage->cPresent, u32, pPage->enmKind)); 3011 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 2999 3012 break; 3000 3013 } … … 3009 3022 const uint64_t u64 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P; 3010 3023 PX86PTPAE pPT = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pVM, pPage); 3011 uint64_t u64AndMask, u64OrMask; 3012 3013 u64OrMask = 0; 3014 u64AndMask = 0; 3024 uint64_t u64OrMask = 0; 3025 uint64_t u64AndMask = 0; 3026 3015 3027 if (!fFlushPTEs) 3016 3028 { 3017 3029 switch (PGM_PAGE_GET_HNDL_PHYS_STATE(pPhysPage)) 3018 3030 { 3019 case PGM_PAGE_HNDL_PHYS_STATE_NONE: /** No handler installed. */3020 case PGM_PAGE_HNDL_PHYS_STATE_DISABLED: /** Monitoring is temporarily disabled. */3021 u64OrMask = X86_PTE_RW;3022 u64AndMask = UINT64_MAX;3023 bRet = true;3024 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep);3025 break;3026 3027 case PGM_PAGE_HNDL_PHYS_STATE_WRITE: /** Write access is monitored. */3028 u64OrMask = 0;3029 u64AndMask = ~((uint64_t)X86_PTE_RW);3030 bRet = true;3031 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep);3032 break;3033 3034 default:3035 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry);3036 break;3031 case PGM_PAGE_HNDL_PHYS_STATE_NONE: /** No handler installed. */ 3032 case PGM_PAGE_HNDL_PHYS_STATE_DISABLED: /** Monitoring is temporarily disabled. */ 3033 u64OrMask = X86_PTE_RW; 3034 u64AndMask = UINT64_MAX; 3035 fRet = true; 3036 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep); 3037 break; 3038 3039 case PGM_PAGE_HNDL_PHYS_STATE_WRITE: /** Write access is monitored. */ 3040 u64OrMask = 0; 3041 u64AndMask = ~((uint64_t)X86_PTE_RW); 3042 fRet = true; 3043 STAM_COUNTER_INC(&pPool->StatTrackFlushEntryKeep); 3044 break; 3045 3046 default: 3047 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 3048 break; 3037 3049 } 3038 3050 } … … 3059 3071 3060 3072 ASMAtomicWriteSize(&pPT->a[iPte].u, Pte.u); 3061 return bRet; 3073 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3074 return fRet; 3062 3075 } 3063 3076 #ifdef LOG_ENABLED … … 3071 3084 #endif 3072 3085 AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d u64=%RX64 poolkind=%x\n", cRefs, pPage->iFirstPresent, pPage->cPresent, u64, pPage->enmKind)); 3086 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3073 3087 break; 3074 3088 } … … 3088 3102 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 3089 3103 pPD->a[iPte].u = 0; 3104 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3090 3105 3091 3106 /* Update the counter as we're removing references. */ … … 3095 3110 pPool->cPresent--; 3096 3111 3097 return bRet;3112 return fRet; 3098 3113 } 3099 3114 # ifdef LOG_ENABLED … … 3106 3121 # endif 3107 3122 AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent)); 3123 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3108 3124 break; 3109 3125 } … … 3122 3138 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 3123 3139 pPD->a[iPte].u = 0; 3140 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3124 3141 3125 3142 /* Update the counter as we're removing references. */ … … 3128 3145 pPage->cPresent--; 3129 3146 pPool->cPresent--; 3130 return bRet;3147 return fRet; 3131 3148 } 3132 3149 # ifdef LOG_ENABLED … … 3139 3156 # endif 3140 3157 AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent)); 3158 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3141 3159 break; 3142 3160 } … … 3146 3164 AssertFatalMsgFailed(("enmKind=%d iShw=%d\n", pPage->enmKind, iShw)); 3147 3165 } 3148 return bRet;3166 return fRet; 3149 3167 } 3150 3168 … … 3306 3324 else 3307 3325 { 3308 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(IN_RC) 3326 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(IN_RC) /** @todo we can drop this now. */ 3309 3327 /* Start a subset here because pgmPoolTrackFlushGCPhysPTsSlow and 3310 3328 pgmPoolTrackFlushGCPhysPTs will/may kill the pool otherwise. */ … … 3415 3433 break; 3416 3434 } 3435 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3417 3436 break; 3418 3437 } … … 3443 3462 break; 3444 3463 } 3464 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3445 3465 break; 3446 3466 } … … 3467 3487 break; 3468 3488 } 3489 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3469 3490 break; 3470 3491 } … … 3593 3614 case PGMPOOLKIND_PAE_PD_FOR_PAE_PD: 3594 3615 #if defined(IN_RC) 3595 /* In 32 bits PAE mode we *must* invalidate the TLB when changing a PDPT entry; the CPU fetches them only during cr3 load, so any 3616 /* 3617 * In 32 bits PAE mode we *must* invalidate the TLB when changing a 3618 * PDPT entry; the CPU fetches them only during cr3 load, so any 3596 3619 * non-present PDPT will continue to cause page faults. 3597 3620 */ 3598 3621 ASMReloadCR3(); 3622 /* no break */ 3599 3623 #endif 3600 /* no break */3601 3624 case PGMPOOLKIND_PAE_PD_PHYS: 3602 3625 case PGMPOOLKIND_PAE_PDPT_PHYS: … … 4390 4413 * Map the shadow page and take action according to the page kind. 4391 4414 */ 4392 void *pvShw = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 4415 PVM pVM = pPool->CTX_SUFF(pVM); 4416 void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage); 4393 4417 switch (pPage->enmKind) 4394 4418 { … … 4397 4421 STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g); 4398 4422 void *pvGst; 4399 int rc = PGM_GCPHYS_2_PTR(p Pool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);4423 int rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 4400 4424 pgmPoolTrackDerefPT32Bit32Bit(pPool, pPage, (PX86PT)pvShw, (PCX86PT)pvGst); 4425 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 4401 4426 STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g); 4402 4427 break; … … 4407 4432 STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g); 4408 4433 void *pvGst; 4409 int rc = PGM_GCPHYS_2_PTR_EX(p Pool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);4434 int rc = PGM_GCPHYS_2_PTR_EX(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 4410 4435 pgmPoolTrackDerefPTPae32Bit(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PT)pvGst); 4436 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 4411 4437 STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g); 4412 4438 break; … … 4417 4443 STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g); 4418 4444 void *pvGst; 4419 int rc = PGM_GCPHYS_2_PTR(p Pool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);4445 int rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc); 4420 4446 pgmPoolTrackDerefPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst); 4447 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 4421 4448 STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g); 4422 4449 break; … … 4494 4521 STAM_PROFILE_STOP(&pPool->StatZeroPage, z); 4495 4522 pPage->fZeroed = true; 4496 PGM_DYNMAP_UNUSED_HINT_VM(pPool->CTX_SUFF(pVM), pvShw);4497 4523 Assert(!pPage->cPresent); 4524 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw); 4498 4525 } 4499 4526
Note:
See TracChangeset
for help on using the changeset viewer.