VirtualBox

Changeset 31446 in vbox for trunk


Ignore:
Timestamp:
Aug 7, 2010 9:13:53 PM (14 years ago)
Author:
vboxsync
Message:

PGMAllPool.cpp: Added lots more PGM_DYNMAP_UNUSED_HINT_VM calls to avoid running out of mapping space.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGMInternal.h

    r31402 r31446  
    319319 * is no longer used.
    320320 *
     321 * For best effect only apply this to the page that was mapped most recently.
     322 *
    321323 * @param   pVCpu   The current CPU.
    322324 * @param   pPage   The pool page.
     
    335337 * Hints to the dynamic mapping code in RC and R0/darwin that the specified page
    336338 * is no longer used.
     339 *
     340 * For best effect only apply this to the page that was mapped most recently.
    337341 *
    338342 * @param   pVM     The VM handle.
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r31402 r31446  
    10701070        int rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    10711071        pgmPoolTrackCheckPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst);
     1072        PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
     1073        PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw);
    10721074    }
    10731075#endif
     
    13441346    unsigned LastPTE    = ~0U;          /* initialized to shut up gcc */
    13451347    RTHCPHYS LastHCPhys = NIL_RTHCPHYS; /* initialized to shut up gcc */
     1348    PVM      pVM        = pPool->CTX_SUFF(pVM);
    13461349
    13471350#ifdef VBOX_STRICT
     
    13541357        {
    13551358            RTHCPHYS HCPhys = NIL_RTHCPHYS;
    1356             int rc = PGMPhysGCPhys2HCPhys(pPool->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);
    13571360            if (    rc != VINF_SUCCESS
    13581361                ||  (pShwPT->a[i].u & X86_PTE_PAE_PG_MASK) != HCPhys)
     
    13651368
    13661369                RTHCPHYS HCPhysPT = NIL_RTHCPHYS;
    1367                 rc = PGMPhysGCPhys2HCPhys(pPool->CTX_SUFF(pVM), pPage->GCPhys, &HCPhysPT);
     1370                rc = PGMPhysGCPhys2HCPhys(pVM, pPage->GCPhys, &HCPhysPT);
    13681371                AssertRC(rc);
    13691372
     
    13741377                    if (pTempPage->enmKind == PGMPOOLKIND_PAE_PT_FOR_PAE_PT)
    13751378                    {
    1376                         PX86PTPAE pShwPT2 = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pTempPage);
     1379                        PX86PTPAE pShwPT2 = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pVM, pTempPage);
    13771380
    13781381                        for (unsigned j = 0; j < RT_ELEMENTS(pShwPT->a); j++)
     
    13851388                            }
    13861389                        }
     1390
     1391                        PGM_DYNMAP_UNUSED_HINT_VM(pVM, pShwPT2);
    13871392                    }
    13881393                }
     
    14061411 * @param   pfFlush         Flush reused page table (out)
    14071412 */
    1408 DECLINLINE(unsigned) pgmPoolTrackFlushPTPaePae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PTPAE pGstPT, PCX86PTPAE pOldGstPT, bool fAllowRemoval, bool *pfFlush)
     1413DECLINLINE(unsigned) pgmPoolTrackFlushPTPaePae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PTPAE pGstPT,
     1414                                               PCX86PTPAE pOldGstPT, bool fAllowRemoval, bool *pfFlush)
    14091415{
    14101416    unsigned cChanged = 0;
     
    15111517    /* Flush those PTEs that have changed. */
    15121518    STAM_PROFILE_START(&pPool->StatTrackDeref,a);
    1513     void *pvShw = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
     1519    void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage);
    15141520    void *pvGst;
     1521    rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    15151522    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);
    15181527    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. */
    15201529
    15211530    /* This page is likely to be modified again, so reduce the nr of modifications just a bit here. */
     
    15781587    Log(("Add dirty page %RGp (slot=%d)\n", pPage->GCPhys, idxFree));
    15791588
    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     */
    15841594    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);
    15861596    memcpy(&pPool->aDirtyPages[idxFree][0], pvGst, PAGE_SIZE);
    15871597#ifdef VBOX_STRICT
     1598    void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage);
    15881599    pgmPoolTrackCheckPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst);
     1600    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw);
    15891601#endif
     1602    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
    15901603
    15911604    STAM_COUNTER_INC(&pPool->StatDirtyPage);
     
    29152928    LogFlow(("pgmPoolTrackFlushGCPhysPT: pPhysPage=%RHp iShw=%d iPte=%d cRefs=%d\n", PGM_PAGE_GET_HCPHYS(pPhysPage), iShw, iPte, cRefs));
    29162929    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
    2917     bool bRet = false;
     2930    bool     fRet = false;
    29182931
    29192932    /*
     
    29362949            const uint32_t  u32 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P;
    29372950            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;
    29422953
    29432954            if (!fFlushPTEs)
     
    29452956                switch (PGM_PAGE_GET_HNDL_PHYS_STATE(pPhysPage))
    29462957                {
    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;
    29642975                }
    29652976            }
     
    29862997
    29872998                ASMAtomicWriteSize(&pPT->a[iPte].u, Pte.u);
    2988                 return bRet;
     2999                PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT);
     3000                return fRet;
    29893001            }
    29903002#ifdef LOG_ENABLED
     
    29973009#endif
    29983010            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);
    29993012            break;
    30003013        }
     
    30093022            const uint64_t  u64 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P;
    30103023            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
    30153027            if (!fFlushPTEs)
    30163028            {
    30173029                switch (PGM_PAGE_GET_HNDL_PHYS_STATE(pPhysPage))
    30183030                {
    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;
    30373049                }
    30383050            }
     
    30593071
    30603072                ASMAtomicWriteSize(&pPT->a[iPte].u, Pte.u);
    3061                 return bRet;
     3073                PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT);
     3074                return fRet;
    30623075            }
    30633076#ifdef LOG_ENABLED
     
    30713084#endif
    30723085            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);
    30733087            break;
    30743088        }
     
    30883102                STAM_COUNTER_INC(&pPool->StatTrackFlushEntry);
    30893103                pPD->a[iPte].u = 0;
     3104                PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD);
    30903105
    30913106                /* Update the counter as we're removing references. */
     
    30953110                pPool->cPresent--;
    30963111
    3097                 return bRet;
     3112                return fRet;
    30983113            }
    30993114# ifdef LOG_ENABLED
     
    31063121# endif
    31073122            AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));
     3123            PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD);
    31083124            break;
    31093125        }
     
    31223138                STAM_COUNTER_INC(&pPool->StatTrackFlushEntry);
    31233139                pPD->a[iPte].u = 0;
     3140                PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD);
    31243141
    31253142                /* Update the counter as we're removing references. */
     
    31283145                pPage->cPresent--;
    31293146                pPool->cPresent--;
    3130                 return bRet;
     3147                return fRet;
    31313148            }
    31323149# ifdef LOG_ENABLED
     
    31393156# endif
    31403157            AssertFatalMsgFailed(("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent));
     3158            PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPD);
    31413159            break;
    31423160        }
     
    31463164            AssertFatalMsgFailed(("enmKind=%d iShw=%d\n", pPage->enmKind, iShw));
    31473165    }
    3148     return bRet;
     3166    return fRet;
    31493167}
    31503168
     
    33063324        else
    33073325        {
    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. */
    33093327            /* Start a subset here because pgmPoolTrackFlushGCPhysPTsSlow and
    33103328               pgmPoolTrackFlushGCPhysPTs will/may kill the pool otherwise. */
     
    34153433                                break;
    34163434                        }
     3435                    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT);
    34173436                    break;
    34183437                }
     
    34433462                                break;
    34443463                        }
     3464                    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT);
    34453465                    break;
    34463466                }
     
    34673487                                break;
    34683488                        }
     3489                    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT);
    34693490                    break;
    34703491                }
     
    35933614        case PGMPOOLKIND_PAE_PD_FOR_PAE_PD:
    35943615#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
    35963619             * non-present PDPT will continue to cause page faults.
    35973620             */
    35983621            ASMReloadCR3();
     3622            /* no break */
    35993623#endif
    3600             /* no break */
    36013624        case PGMPOOLKIND_PAE_PD_PHYS:
    36023625        case PGMPOOLKIND_PAE_PDPT_PHYS:
     
    43904413     * Map the shadow page and take action according to the page kind.
    43914414     */
    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);
    43934417    switch (pPage->enmKind)
    43944418    {
     
    43974421            STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g);
    43984422            void *pvGst;
    4399             int rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
     4423            int rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    44004424            pgmPoolTrackDerefPT32Bit32Bit(pPool, pPage, (PX86PT)pvShw, (PCX86PT)pvGst);
     4425            PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
    44014426            STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g);
    44024427            break;
     
    44074432            STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g);
    44084433            void *pvGst;
    4409             int rc = PGM_GCPHYS_2_PTR_EX(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
     4434            int rc = PGM_GCPHYS_2_PTR_EX(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    44104435            pgmPoolTrackDerefPTPae32Bit(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PT)pvGst);
     4436            PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
    44114437            STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g);
    44124438            break;
     
    44174443            STAM_PROFILE_START(&pPool->StatTrackDerefGCPhys, g);
    44184444            void *pvGst;
    4419             int rc = PGM_GCPHYS_2_PTR(pPool->CTX_SUFF(pVM), pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
     4445            int rc = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    44204446            pgmPoolTrackDerefPTPaePae(pPool, pPage, (PX86PTPAE)pvShw, (PCX86PTPAE)pvGst);
     4447            PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
    44214448            STAM_PROFILE_STOP(&pPool->StatTrackDerefGCPhys, g);
    44224449            break;
     
    44944521    STAM_PROFILE_STOP(&pPool->StatZeroPage, z);
    44954522    pPage->fZeroed = true;
    4496     PGM_DYNMAP_UNUSED_HINT_VM(pPool->CTX_SUFF(pVM), pvShw);
    44974523    Assert(!pPage->cPresent);
     4524    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw);
    44984525}
    44994526
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette