Changeset 31657 in vbox for trunk/src/VBox
- Timestamp:
- Aug 13, 2010 2:53:34 PM (14 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMInternal.h
r31606 r31657 2341 2341 * 2342 2342 * @returns The @a cRefs field 2343 * @param u16 The tracking data word. */ 2343 * @param u16 The tracking data word. 2344 * @remarks This will only return 1 or PGMPOOL_TD_CREFS_PHYSEXT for a 2345 * non-zero @a u16. */ 2344 2346 #define PGMPOOL_TD_GET_CREFS(u16) ( ((u16) >> PGMPOOL_TD_CREFS_SHIFT) & PGMPOOL_TD_CREFS_MASK ) 2345 2347 -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r31636 r31657 1412 1412 { 1413 1413 PVM pVM = pVCpu->CTX_SUFF(pVM); 1414 1414 1415 /* 1415 1416 * Just deal with the simple first time here. -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r31636 r31657 2948 2948 2949 2949 /** 2950 * Scans one shadow page table for mappings of a physical page. 2951 * 2952 * @returns true/false indicating removal of all relevant PTEs 2950 * Checks one shadow page table entry for a mapping of a physical page. 2951 * 2952 * @returns true / false indicating removal of all relevant PTEs 2953 * 2953 2954 * @param pVM The VM handle. 2954 2955 * @param pPhysPage The guest page in question. … … 2956 2957 * @param iShw The shadow page table. 2957 2958 * @param iPte Page table entry or NIL_PGMPOOL_PHYSEXT_IDX_PTE if unknown 2958 * @param cRefs The number of references made in that PT. 2959 */ 2960 static bool pgmPoolTrackFlushGCPhysPTInt(PVM pVM, PCPGMPAGE pPhysPage, bool fFlushPTEs, uint16_t iShw, uint16_t iPte, uint16_t cRefs) 2961 { 2962 LogFlow(("pgmPoolTrackFlushGCPhysPT: pPhysPage=%RHp iShw=%d iPte=%d cRefs=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw, iPte, cRefs)); 2959 */ 2960 static bool pgmPoolTrackFlushGCPhysPTInt(PVM pVM, PCPGMPAGE pPhysPage, bool fFlushPTEs, uint16_t iShw, uint16_t iPte) 2961 { 2962 LogFlow(("pgmPoolTrackFlushGCPhysPTInt: pPhysPage=%RHp iShw=%d iPte=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw, iPte)); 2963 2963 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); 2964 2964 bool fRet = false; … … 2967 2967 * Assert sanity. 2968 2968 */ 2969 Assert(cRefs == 1);2970 2969 Assert(iPte != NIL_PGMPOOL_PHYSEXT_IDX_PTE); 2971 2970 AssertFatalMsg(iShw < pPool->cCurPages && iShw != NIL_PGMPOOL_IDX, ("iShw=%d\n", iShw)); … … 3015 3014 if (!u32AndMask) 3016 3015 { 3017 Assert(pPage->cPresent >= cRefs);3018 Assert(pPool->cPresent >= cRefs);3019 pPage->cPresent -= cRefs;3020 pPool->cPresent -= cRefs;3016 Assert(pPage->cPresent ); 3017 Assert(pPool->cPresent); 3018 pPage->cPresent--; 3019 pPool->cPresent--; 3021 3020 } 3022 3021 … … 3025 3024 X86PTE Pte; 3026 3025 3027 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX32 cRefs=%#x\n", iPte, pPT->a[iPte], cRefs));3026 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX32\n", iPte, pPT->a[iPte])); 3028 3027 Pte.u = (pPT->a[iPte].u & u32AndMask) | u32OrMask; 3029 3028 if (Pte.u & PGM_PTFLAGS_TRACK_DIRTY) … … 3035 3034 } 3036 3035 #ifdef LOG_ENABLED 3037 Log((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3038 for (unsigned i = 0 ; i < RT_ELEMENTS(pPT->a); i++)3036 Log(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3037 for (unsigned i = 0, cFound = 0; i < RT_ELEMENTS(pPT->a); i++) 3039 3038 if ((pPT->a[i].u & (X86_PTE_PG_MASK | X86_PTE_P)) == u32) 3040 3039 { 3041 Log(("i=%d c Refs=%d\n", i, cRefs--));3040 Log(("i=%d cFound=%d\n", i, ++cFound)); 3042 3041 } 3043 3042 #endif 3044 AssertFatalMsgFailed((" cRefs=%d iFirstPresent=%d cPresent=%d u32=%RX32 poolkind=%x\n", cRefs, pPage->iFirstPresent, pPage->cPresent, u32, pPage->enmKind));3043 AssertFatalMsgFailed(("iFirstPresent=%d cPresent=%d u32=%RX32 poolkind=%x\n", pPage->iFirstPresent, pPage->cPresent, u32, pPage->enmKind)); 3045 3044 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3046 3045 break; … … 3089 3088 if (!u64AndMask) 3090 3089 { 3091 Assert(pPage->cPresent >= cRefs);3092 Assert(pPool->cPresent >= cRefs);3093 pPage->cPresent -= cRefs;3094 pPool->cPresent -= cRefs;3090 Assert(pPage->cPresent); 3091 Assert(pPool->cPresent); 3092 pPage->cPresent--; 3093 pPool->cPresent--; 3095 3094 } 3096 3095 … … 3099 3098 X86PTEPAE Pte; 3100 3099 3101 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX64 cRefs=%#x\n", iPte, pPT->a[iPte], cRefs));3100 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX64\n", iPte, pPT->a[iPte])); 3102 3101 Pte.u = (pPT->a[iPte].u & u64AndMask) | u64OrMask; 3103 3102 if (Pte.u & PGM_PTFLAGS_TRACK_DIRTY) … … 3109 3108 } 3110 3109 #ifdef LOG_ENABLED 3111 Log((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3110 Log(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3112 3111 Log(("Found %RX64 expected %RX64\n", pPT->a[iPte].u & (X86_PTE_PAE_PG_MASK | X86_PTE_P), u64)); 3113 for (unsigned i = 0 ; i < RT_ELEMENTS(pPT->a); i++)3112 for (unsigned i = 0, cFound = 0; i < RT_ELEMENTS(pPT->a); i++) 3114 3113 if ((pPT->a[i].u & (X86_PTE_PAE_PG_MASK | X86_PTE_P | X86_PTE_PAE_MBZ_MASK_NX)) == u64) 3115 { 3116 Log(("i=%d cRefs=%d\n", i, cRefs--)); 3117 } 3114 Log(("i=%d cFound=%d\n", i, ++cFound)); 3118 3115 #endif 3119 AssertFatalMsgFailed((" cRefs=%d iFirstPresent=%d cPresent=%d u64=%RX64 poolkind=%x\n", cRefs, pPage->iFirstPresent, pPage->cPresent, u64, pPage->enmKind));3116 AssertFatalMsgFailed(("iFirstPresent=%d cPresent=%d u64=%RX64 poolkind=%x\n", pPage->iFirstPresent, pPage->cPresent, u64, pPage->enmKind)); 3120 3117 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3121 3118 break; … … 3133 3130 if ((pPD->a[iPte].u & (EPT_PDE2M_PG_MASK | X86_PDE4M_P | X86_PDE4M_PS)) == u64) 3134 3131 { 3135 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pde=%RX64 cRefs=%#x\n", iPte, pPD->a[iPte], cRefs));3132 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pde=%RX64\n", iPte, pPD->a[iPte])); 3136 3133 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 3137 3134 pPD->a[iPte].u = 0; … … 3147 3144 } 3148 3145 # ifdef LOG_ENABLED 3149 Log((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3150 for (unsigned i = 0 ; i < RT_ELEMENTS(pPD->a); i++)3146 Log(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3147 for (unsigned i = 0, cFound = 0; i < RT_ELEMENTS(pPD->a); i++) 3151 3148 if ((pPD->a[i].u & (EPT_PDE2M_PG_MASK | X86_PDE4M_P | X86_PDE4M_PS)) == u64) 3152 { 3153 Log(("i=%d cRefs=%d\n", i, cRefs--)); 3154 } 3149 Log(("i=%d cFound=%d\n", i, ++cFound)); 3155 3150 # endif 3156 AssertFatalMsgFailed((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3151 AssertFatalMsgFailed(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3157 3152 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3158 3153 break; … … 3169 3164 if ((pPD->a[iPte].u & (X86_PDE2M_PAE_PG_MASK | X86_PDE4M_P | X86_PDE4M_PS)) == u64) 3170 3165 { 3171 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pde=%RX64 cRefs=%#x\n", iPte, pPD->a[iPte], cRefs));3166 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pde=%RX64\n", iPte, pPD->a[iPte])); 3172 3167 STAM_COUNTER_INC(&pPool->StatTrackFlushEntry); 3173 3168 pPD->a[iPte].u = 0; … … 3182 3177 } 3183 3178 # ifdef LOG_ENABLED 3184 Log((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3185 for (unsigned i = 0 ; i < RT_ELEMENTS(pPD->a); i++)3179 Log(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3180 for (unsigned i = 0, cFound = 0; i < RT_ELEMENTS(pPD->a); i++) 3186 3181 if ((pPD->a[i].u & (X86_PDE2M_PAE_PG_MASK | X86_PDE4M_P | X86_PDE4M_PS)) == u64) 3187 { 3188 Log(("i=%d cRefs=%d\n", i, cRefs--)); 3189 } 3182 Log(("i=%d cFound=%d\n", i, ++cFound)); 3190 3183 # endif 3191 AssertFatalMsgFailed((" cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));3184 AssertFatalMsgFailed(("iFirstPresent=%d cPresent=%d\n", pPage->iFirstPresent, pPage->cPresent)); 3192 3185 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD); 3193 3186 break; … … 3209 3202 * @param fFlushPTEs Flush PTEs or allow them to be updated (e.g. in case of an RW bit change) 3210 3203 * @param iShw The shadow page table. 3211 * @param cRefs The number of references made in that PT. 3212 */ 3213 static void pgmPoolTrackFlushGCPhysPT(PVM pVM, PPGMPAGE pPhysPage, bool fFlushPTEs, uint16_t iShw, uint16_t cRefs) 3204 */ 3205 static void pgmPoolTrackFlushGCPhysPT(PVM pVM, PPGMPAGE pPhysPage, bool fFlushPTEs, uint16_t iShw) 3214 3206 { 3215 3207 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); NOREF(pPool); … … 3217 3209 /* We should only come here with when there's only one reference to this physical page. */ 3218 3210 Assert(PGMPOOL_TD_GET_CREFS(PGM_PAGE_GET_TRACKING(pPhysPage)) == 1); 3219 Assert(cRefs == 1); 3220 3221 Log2(("pgmPoolTrackFlushGCPhysPT: pPhysPage=%RHp iShw=%d cRefs=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw, cRefs)); 3211 3212 Log2(("pgmPoolTrackFlushGCPhysPT: pPhysPage=%RHp iShw=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw)); 3222 3213 STAM_PROFILE_START(&pPool->StatTrackFlushGCPhysPT, f); 3223 bool fKeptPTEs = pgmPoolTrackFlushGCPhysPTInt(pVM, pPhysPage, fFlushPTEs, iShw, PGM_PAGE_GET_PTE_INDEX(pPhysPage) , cRefs);3214 bool fKeptPTEs = pgmPoolTrackFlushGCPhysPTInt(pVM, pPhysPage, fFlushPTEs, iShw, PGM_PAGE_GET_PTE_INDEX(pPhysPage)); 3224 3215 if (!fKeptPTEs) 3225 3216 PGM_PAGE_SET_TRACKING(pPhysPage, 0); … … 3255 3246 if (pPhysExt->aidx[i] != NIL_PGMPOOL_IDX) 3256 3247 { 3257 bool fKeptPTEs = pgmPoolTrackFlushGCPhysPTInt(pVM, pPhysPage, fFlushPTEs, pPhysExt->aidx[i], pPhysExt->apte[i] , 1);3248 bool fKeptPTEs = pgmPoolTrackFlushGCPhysPTInt(pVM, pPhysPage, fFlushPTEs, pPhysExt->aidx[i], pPhysExt->apte[i]); 3258 3249 if (!fKeptPTEs) 3259 3250 { … … 3365 3356 3366 3357 if (PGMPOOL_TD_GET_CREFS(u16) != PGMPOOL_TD_CREFS_PHYSEXT) 3358 { 3359 Assert(PGMPOOL_TD_GET_CREFS(u16) == 1); 3367 3360 pgmPoolTrackFlushGCPhysPT(pVM, 3368 3361 pPhysPage, 3369 3362 fFlushPTEs, 3370 PGMPOOL_TD_GET_IDX(u16) ,3371 PGMPOOL_TD_GET_CREFS(u16));3363 PGMPOOL_TD_GET_IDX(u16)); 3364 } 3372 3365 else if (u16 != PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, PGMPOOL_TD_IDX_OVERFLOWED)) 3373 3366 pgmPoolTrackFlushGCPhysPTs(pVM, pPhysPage, fFlushPTEs, PGMPOOL_TD_GET_IDX(u16)); … … 3902 3895 return u16; 3903 3896 } 3897 3904 3898 3905 3899 /**
Note:
See TracChangeset
for help on using the changeset viewer.