VirtualBox

Changeset 36891 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Apr 29, 2011 1:22:57 PM (14 years ago)
Author:
vboxsync
Message:

PGM: Put a TLB in front of the RAM ranges to speed up lookup (disabled).

Location:
trunk/src/VBox/VMM/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/PGMGstDefs.h

    r35333 r36891  
    140140# define GST_GET_PTE_GCPHYS(Pte)                ((Pte).u & GST_PDE_PG_MASK)
    141141# define GST_GET_PDE_GCPHYS(Pde)                ((Pde).u & GST_PDE_PG_MASK)
    142 # define GST_GET_BIG_PDE_GCPHYS(pVM, Pde)       pgmGstGet4MBPhysPage(&(pVM)->pgm.s, Pde)
     142# define GST_GET_BIG_PDE_GCPHYS(pVM, Pde)       pgmGstGet4MBPhysPage((pVM), Pde)
    143143# define GST_GET_PDE_SHW_FLAGS(pVCpu, Pde)      ((Pde).u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_A))
    144144# define GST_GET_BIG_PDE_SHW_FLAGS(pVCpu, Pde) \
  • trunk/src/VBox/VMM/include/PGMInline.h

    r36009 r36891  
    4646 */
    4747
    48 /** @todo Split out all the inline stuff into a separate file.  Then we can
    49  *        include it later when VM and VMCPU are defined and so avoid all that
    50  *        &pVM->pgm.s and &pVCpu->pgm.s stuff.  It also chops ~1600 lines off
    51  *        this file and will make it somewhat easier to navigate... */
    52 
    5348/**
    5449 * Gets the PGMRAMRANGE structure for a guest page.
     
    5752 * @returns NULL on a VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS condition.
    5853 *
    59  * @param   pPGM        PGM handle.
     54 * @param   pVM         The VM handle.
    6055 * @param   GCPhys      The GC physical address.
    6156 */
    62 DECLINLINE(PPGMRAMRANGE) pgmPhysGetRange(PPGM pPGM, RTGCPHYS GCPhys)
    63 {
     57DECLINLINE(PPGMRAMRANGE) pgmPhysGetRange(PVM pVM, RTGCPHYS GCPhys)
     58{
     59#ifdef PGM_USE_RAMRANGE_TLB
     60    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     61    if (!pRam || GCPhys - pRam->GCPhys >= pRam->cb)
     62        pRam = pgmPhysGetRangeSlow(pVM, GCPhys);
     63    STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     64    return pRam;
     65
     66#else
    6467    /*
    6568     * Optimize for the first range.
    6669     */
    67     PPGMRAMRANGE pRam = pPGM->CTX_SUFF(pRamRanges);
     70    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    6871    RTGCPHYS off = GCPhys - pRam->GCPhys;
    6972    if (RT_UNLIKELY(off >= pRam->cb))
     
    7881    }
    7982    return pRam;
    80 }
     83#endif
     84}
     85
     86
     87/**
     88 * Gets the PGMRAMRANGE structure for a guest page, if unassigned get the ram
     89 * range above it.
     90 *
     91 * @returns Pointer to the RAM range on success.
     92 * @returns NULL if the address is located after the last range.
     93 *
     94 * @param   pVM         The VM handle.
     95 * @param   GCPhys      The GC physical address.
     96 */
     97DECLINLINE(PPGMRAMRANGE) pgmPhysGetRangeAtOrAbove(PVM pVM, RTGCPHYS GCPhys)
     98{
     99#ifdef PGM_USE_RAMRANGE_TLB
     100    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     101    if (   !pRam
     102        || (GCPhys - pRam->GCPhys) >= pRam->cb)
     103        return pgmPhysGetRangeAtOrAboveSlow(pVM, GCPhys);
     104    STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     105    return pRam;
     106
     107#else
     108    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
     109    while (pRam && GCPhys > pRam->GCPhysLast)
     110        pRam = pRam->CTX_SUFF(pNext);
     111    return pRam;
     112#endif
     113}
     114
    81115
    82116
     
    87121 * @returns NULL on a VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS condition.
    88122 *
    89  * @param   pPGM        PGM handle.
     123 * @param   pVM         The VM handle.
    90124 * @param   GCPhys      The GC physical address.
    91125 */
    92 DECLINLINE(PPGMPAGE) pgmPhysGetPage(PPGM pPGM, RTGCPHYS GCPhys)
    93 {
     126DECLINLINE(PPGMPAGE) pgmPhysGetPage(PVM pVM, RTGCPHYS GCPhys)
     127{
     128#ifdef PGM_USE_RAMRANGE_TLB
     129    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     130    RTGCPHYS off;
     131    if (   !pRam
     132        || (off = GCPhys - pRam->GCPhys) >= pRam->cb)
     133        return pgmPhysGetPageSlow(pVM, GCPhys);
     134    STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     135    return &pRam->aPages[off >> PAGE_SHIFT];
     136
     137#else
    94138    /*
    95139     * Optimize for the first range.
    96140     */
    97     PPGMRAMRANGE pRam = pPGM->CTX_SUFF(pRamRanges);
     141    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    98142    RTGCPHYS off = GCPhys - pRam->GCPhys;
    99143    if (RT_UNLIKELY(off >= pRam->cb))
     
    108152    }
    109153    return &pRam->aPages[off >> PAGE_SHIFT];
     154#endif
    110155}
    111156
     
    120165 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if the address isn't valid.
    121166 *
    122  * @param   pPGM        PGM handle.
     167 * @param   pVM         The VM handle.
    123168 * @param   GCPhys      The GC physical address.
    124169 * @param   ppPage      Where to store the page pointer on success.
    125170 */
    126 DECLINLINE(int) pgmPhysGetPageEx(PPGM pPGM, RTGCPHYS GCPhys, PPPGMPAGE ppPage)
    127 {
     171DECLINLINE(int) pgmPhysGetPageEx(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGE ppPage)
     172{
     173#ifdef PGM_USE_RAMRANGE_TLB
     174    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     175    RTGCPHYS off;
     176    if (   !pRam
     177        || (off = GCPhys - pRam->GCPhys) >= pRam->cb)
     178        return pgmPhysGetPageExSlow(pVM, GCPhys, ppPage);
     179    *ppPage = &pRam->aPages[(GCPhys - pRam->GCPhys) >> PAGE_SHIFT];
     180    STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     181    return VINF_SUCCESS;
     182
     183#else
    128184    /*
    129185     * Optimize for the first range.
    130186     */
    131     PPGMRAMRANGE pRam = pPGM->CTX_SUFF(pRamRanges);
     187    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    132188    RTGCPHYS off = GCPhys - pRam->GCPhys;
    133189    if (RT_UNLIKELY(off >= pRam->cb))
     
    146202    *ppPage = &pRam->aPages[off >> PAGE_SHIFT];
    147203    return VINF_SUCCESS;
     204#endif
    148205}
    149206
     
    160217 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if the address isn't valid.
    161218 *
    162  * @param   pPGM        PGM handle.
     219 * @param   pVM         The VM handle.
    163220 * @param   GCPhys      The GC physical address.
    164221 * @param   ppPage      Where to store the page pointer on success.
     
    166223 *                      The caller initializes this to NULL before the call.
    167224 */
    168 DECLINLINE(int) pgmPhysGetPageWithHintEx(PPGM pPGM, RTGCPHYS GCPhys, PPPGMPAGE ppPage, PPGMRAMRANGE *ppRamHint)
     225DECLINLINE(int) pgmPhysGetPageWithHintEx(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGE ppPage, PPGMRAMRANGE *ppRamHint)
    169226{
    170227    RTGCPHYS off;
     
    173230        ||  RT_UNLIKELY((off = GCPhys - pRam->GCPhys) >= pRam->cb))
    174231    {
    175         pRam = pPGM->CTX_SUFF(pRamRanges);
     232#ifdef PGM_USE_RAMRANGE_TLB
     233        pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     234        if (   !pRam
     235            || (off = GCPhys - pRam->GCPhys) >= pRam->cb)
     236            return pgmPhysGetPageAndRangeExSlow(pVM, GCPhys, ppPage, ppRamHint);
     237        STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     238
     239#else
     240        pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    176241        off = GCPhys - pRam->GCPhys;
    177242        if (RT_UNLIKELY(off >= pRam->cb))
     
    188253            } while (off >= pRam->cb);
    189254        }
     255#endif
    190256        *ppRamHint = pRam;
    191257    }
     
    201267 * @returns NULL on a VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS condition.
    202268 *
    203  * @param   pPGM        PGM handle.
     269 * @param   pVM         The VM handle.
    204270 * @param   GCPhys      The GC physical address.
    205  * @param   ppRam       Where to store the pointer to the PGMRAMRANGE.
    206  */
    207 DECLINLINE(PPGMPAGE) pgmPhysGetPageAndRange(PPGM pPGM, RTGCPHYS GCPhys, PPGMRAMRANGE *ppRam)
    208 {
     271 * @param   ppPage      Where to store the pointer to the PGMPAGE structure.
     272 * @param   ppRam       Where to store the pointer to the PGMRAMRANGE structure.
     273 */
     274DECLINLINE(int) pgmPhysGetPageAndRangeEx(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGE ppPage, PPGMRAMRANGE *ppRam)
     275{
     276#ifdef PGM_USE_RAMRANGE_TLB
     277    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     278    RTGCPHYS off;
     279    if (   !pRam
     280        || (off = GCPhys - pRam->GCPhys) >= pRam->cb)
     281        return pgmPhysGetPageAndRangeExSlow(pVM, GCPhys, ppPage, ppRam);
     282    STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,RamRangeTlbHits));
     283
     284#else
    209285    /*
    210286     * Optimize for the first range.
    211287     */
    212     PPGMRAMRANGE pRam = pPGM->CTX_SUFF(pRamRanges);
    213     RTGCPHYS off = GCPhys - pRam->GCPhys;
    214     if (RT_UNLIKELY(off >= pRam->cb))
    215     {
    216         do
    217         {
    218             pRam = pRam->CTX_SUFF(pNext);
    219             if (RT_UNLIKELY(!pRam))
    220                 return NULL;
    221             off = GCPhys - pRam->GCPhys;
    222         } while (off >= pRam->cb);
    223     }
    224     *ppRam = pRam;
    225     return &pRam->aPages[off >> PAGE_SHIFT];
    226 }
    227 
    228 
    229 /**
    230  * Gets the PGMPAGE structure for a guest page together with the PGMRAMRANGE.
    231  *
    232  * @returns Pointer to the page on success.
    233  * @returns NULL on a VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS condition.
    234  *
    235  * @param   pPGM        PGM handle.
    236  * @param   GCPhys      The GC physical address.
    237  * @param   ppPage      Where to store the pointer to the PGMPAGE structure.
    238  * @param   ppRam       Where to store the pointer to the PGMRAMRANGE structure.
    239  */
    240 DECLINLINE(int) pgmPhysGetPageAndRangeEx(PPGM pPGM, RTGCPHYS GCPhys, PPPGMPAGE ppPage, PPGMRAMRANGE *ppRam)
    241 {
    242     /*
    243      * Optimize for the first range.
    244      */
    245     PPGMRAMRANGE pRam = pPGM->CTX_SUFF(pRamRanges);
     288    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    246289    RTGCPHYS off = GCPhys - pRam->GCPhys;
    247290    if (RT_UNLIKELY(off >= pRam->cb))
     
    259302        } while (off >= pRam->cb);
    260303    }
     304#endif
    261305    *ppRam = pRam;
    262306    *ppPage = &pRam->aPages[off >> PAGE_SHIFT];
     
    269313 *
    270314 * @returns VBox status.
    271  * @param   pPGM        PGM handle.
     315 * @param   pVM         The VM handle.
    272316 * @param   GCPhys      The GC physical address.
    273317 * @param   pHCPhys     Where to store the corresponding HC physical address.
     
    276320 *              Avoid when writing new code!
    277321 */
    278 DECLINLINE(int) pgmRamGCPhys2HCPhys(PPGM pPGM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys)
     322DECLINLINE(int) pgmRamGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys)
    279323{
    280324    PPGMPAGE pPage;
    281     int rc = pgmPhysGetPageEx(pPGM, GCPhys, &pPage);
     325    int rc = pgmPhysGetPageEx(pVM, GCPhys, &pPage);
    282326    if (RT_FAILURE(rc))
    283327        return rc;
     
    344388     * Get the ram range.
    345389     */
    346     PPGMRAMRANGE    pRam = pVM->pgm.s.CTX_SUFF(pRamRanges);
     390#ifdef PGM_USE_RAMRANGE_TLB
     391    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     392    RTGCPHYS off;
     393    if (   !pRam
     394        || (off = GCPhys - pRam->GCPhys) >= pRam->cb
     395        /** @todo   || page state stuff */
     396       )
     397#else
     398    PPGMRAMRANGE    pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    347399    RTGCPHYS        off  = GCPhys - pRam->GCPhys;
    348400    if (RT_UNLIKELY(off >= pRam->cb
    349401        /** @todo   || page state stuff */))
     402#endif
    350403    {
    351404        /* This case is not counted into StatRZDynMapGCPageInl. */
     
    418471     */
    419472    PVM             pVM  = pVCpu->CTX_SUFF(pVM);
    420     PPGMRAMRANGE    pRam = pVM->pgm.s.CTX_SUFF(pRamRanges);
     473#ifdef PGM_USE_RAMRANGE_TLB
     474    PPGMRAMRANGE    pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
     475    RTGCPHYS        off;
     476    if (   !pRam
     477        || (off = GCPhys - pRam->GCPhys) >= pRam->cb
     478        /** @todo   || page state stuff */
     479       )
     480#else
     481    PPGMRAMRANGE    pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
    421482    RTGCPHYS        off  = GCPhys - pRam->GCPhys;
    422483    if (RT_UNLIKELY(off >= pRam->cb
    423484        /** @todo   || page state stuff */))
     485#endif
    424486    {
    425487        /* This case is not counted into StatRZDynMapGCPageInl. */
     
    513575 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    514576 *
    515  * @param   pPGM        The PGM instance handle.
     577 * @param   pVM         The VM handle.
    516578 * @param   GCPhys      The address of the guest page.
    517579 * @param   ppTlbe      Where to store the pointer to the TLB entry.
    518580 */
    519 DECLINLINE(int) pgmPhysPageQueryTlbe(PPGM pPGM, RTGCPHYS GCPhys, PPPGMPAGEMAPTLBE ppTlbe)
     581DECLINLINE(int) pgmPhysPageQueryTlbe(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGEMAPTLBE ppTlbe)
    520582{
    521583    int rc;
    522     PPGMPAGEMAPTLBE pTlbe = &pPGM->CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
     584    PPGMPAGEMAPTLBE pTlbe = &pVM->pgm.s.CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
    523585    if (pTlbe->GCPhys == (GCPhys & X86_PTE_PAE_PG_MASK))
    524586    {
    525         STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbHits));
     587        STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbHits));
    526588        rc = VINF_SUCCESS;
    527589    }
    528590    else
    529         rc = pgmPhysPageLoadIntoTlb(pPGM, GCPhys);
     591        rc = pgmPhysPageLoadIntoTlb(pVM, GCPhys);
    530592    *ppTlbe = pTlbe;
    531593    return rc;
     
    541603 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    542604 *
    543  * @param   pPGM        The PGM instance handle.
     605 * @param   pVM         The VM handle.
    544606 * @param   pPage       Pointer to the PGMPAGE structure corresponding to
    545607 *                      GCPhys.
     
    547609 * @param   ppTlbe      Where to store the pointer to the TLB entry.
    548610 */
    549 DECLINLINE(int) pgmPhysPageQueryTlbeWithPage(PPGM pPGM, PPGMPAGE pPage, RTGCPHYS GCPhys, PPPGMPAGEMAPTLBE ppTlbe)
     611DECLINLINE(int) pgmPhysPageQueryTlbeWithPage(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, PPPGMPAGEMAPTLBE ppTlbe)
    550612{
    551613    int rc;
    552     PPGMPAGEMAPTLBE pTlbe = &pPGM->CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
     614    PPGMPAGEMAPTLBE pTlbe = &pVM->pgm.s.CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
    553615    if (pTlbe->GCPhys == (GCPhys & X86_PTE_PAE_PG_MASK))
    554616    {
    555         STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbHits));
     617        STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbHits));
    556618        rc = VINF_SUCCESS;
    557619    }
    558620    else
    559         rc = pgmPhysPageLoadIntoTlbWithPage(pPGM, pPage, GCPhys);
     621        rc = pgmPhysPageLoadIntoTlbWithPage(pVM, pPage, GCPhys);
    560622    *ppTlbe = pTlbe;
    561623    return rc;
     
    567629/**
    568630 * Enables write monitoring for an allocated page.
    569  * 
    570  * The caller is responsible for updating the shadow page tables. 
    571  * 
     631 *
     632 * The caller is responsible for updating the shadow page tables.
     633 *
    572634 * @param   pVM         The VM handle.
    573  * @param   pPage       The page to write monitor. 
     635 * @param   pPage       The page to write monitor.
    574636 * @param   GCPhysPage  The address of the page.
    575637 */
     
    585647    if (PGM_PAGE_GET_PDE_TYPE(pPage) == PGM_PAGE_PDE_TYPE_PDE)
    586648    {
    587         PPGMPAGE pFirstPage = pgmPhysGetPage(&pVM->pgm.s, GCPhysPage & X86_PDE2M_PAE_PG_MASK);
     649        PPGMPAGE pFirstPage = pgmPhysGetPage(pVM, GCPhysPage & X86_PDE2M_PAE_PG_MASK);
    588650        AssertFatal(pFirstPage);
    589651        if (PGM_PAGE_GET_PDE_TYPE(pFirstPage) == PGM_PAGE_PDE_TYPE_PDE)
     
    638700 *
    639701 * @returns guest physical address
    640  * @param   pPGM        Pointer to the PGM instance data.
     702 * @param   pVM         The VM handle.
    641703 * @param   Pde         Guest Pde
    642704 */
    643 DECLINLINE(RTGCPHYS) pgmGstGet4MBPhysPage(PPGM pPGM, X86PDE Pde)
     705DECLINLINE(RTGCPHYS) pgmGstGet4MBPhysPage(PVM pVM, X86PDE Pde)
    644706{
    645707    RTGCPHYS GCPhys = Pde.u & X86_PDE4M_PG_MASK;
    646708    GCPhys |= (RTGCPHYS)Pde.b.u8PageNoHigh << 32;
    647709
    648     return GCPhys & pPGM->GCPhys4MBPSEMask;
     710    return GCPhys & pVM->pgm.s.GCPhys4MBPSEMask;
    649711}
    650712
     
    13071369
    13081370/**
    1309  * Clears one physical page of a virtual handler
    1310  *
    1311  * @param   pPGM    Pointer to the PGM instance.
    1312  * @param   pCur    Virtual handler structure
    1313  * @param   iPage   Physical page index
     1371 * Clears one physical page of a virtual handler.
     1372 *
     1373 * @param   pVM         The VM handle.
     1374 * @param   pCur        Virtual handler structure.
     1375 * @param   iPage       Physical page index.
    13141376 *
    13151377 * @remark  Only used when PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL is being set, so no
    13161378 *          need to care about other handlers in the same page.
    13171379 */
    1318 DECLINLINE(void) pgmHandlerVirtualClearPage(PPGM pPGM, PPGMVIRTHANDLER pCur, unsigned iPage)
     1380DECLINLINE(void) pgmHandlerVirtualClearPage(PVM pVM, PPGMVIRTHANDLER pCur, unsigned iPage)
    13191381{
    13201382    const PPGMPHYS2VIRTHANDLER pPhys2Virt = &pCur->aPhysToVirt[iPage];
     
    13311393    {
    13321394        /* We're the head of the alias chain. */
    1333         PPGMPHYS2VIRTHANDLER pRemove = (PPGMPHYS2VIRTHANDLER)RTAvlroGCPhysRemove(&pPGM->CTX_SUFF(pTrees)->PhysToVirtHandlers, pPhys2Virt->Core.Key); NOREF(pRemove);
     1395        PPGMPHYS2VIRTHANDLER pRemove = (PPGMPHYS2VIRTHANDLER)RTAvlroGCPhysRemove(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysToVirtHandlers, pPhys2Virt->Core.Key); NOREF(pRemove);
    13341396#ifdef VBOX_STRICT_PGM_HANDLER_VIRTUAL
    13351397        AssertReleaseMsg(pRemove != NULL,
     
    13521414#endif
    13531415            pNext->offNextAlias |= PGMPHYS2VIRTHANDLER_IS_HEAD;
    1354             bool fRc = RTAvlroGCPhysInsert(&pPGM->CTX_SUFF(pTrees)->PhysToVirtHandlers, &pNext->Core);
     1416            bool fRc = RTAvlroGCPhysInsert(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysToVirtHandlers, &pNext->Core);
    13551417            AssertRelease(fRc);
    13561418        }
     
    13591421    {
    13601422        /* Locate the previous node in the alias chain. */
    1361         PPGMPHYS2VIRTHANDLER pPrev = (PPGMPHYS2VIRTHANDLER)RTAvlroGCPhysGet(&pPGM->CTX_SUFF(pTrees)->PhysToVirtHandlers, pPhys2Virt->Core.Key);
     1423        PPGMPHYS2VIRTHANDLER pPrev = (PPGMPHYS2VIRTHANDLER)RTAvlroGCPhysGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysToVirtHandlers, pPhys2Virt->Core.Key);
    13621424#ifdef VBOX_STRICT_PGM_HANDLER_VIRTUAL
    13631425        AssertReleaseMsg(pPrev != pPhys2Virt,
     
    14051467     * Clear the ram flags for this page.
    14061468     */
    1407     PPGMPAGE pPage = pgmPhysGetPage(pPGM, pPhys2Virt->Core.Key);
     1469    PPGMPAGE pPage = pgmPhysGetPage(pVM, pPhys2Virt->Core.Key);
    14081470    AssertReturnVoid(pPage);
    14091471    PGM_PAGE_SET_HNDL_VIRT_STATE(pPage, PGM_PAGE_HNDL_VIRT_STATE_NONE);
     
    15211583 * @param   pPage       PGM pool page
    15221584 */
    1523 DECLINLINE(bool) pgmPoolIsPageLocked(PPGM pPGM, PPGMPOOLPAGE pPage)
     1585DECLINLINE(bool) pgmPoolIsPageLocked(PPGMPOOLPAGE pPage)
    15241586{
    15251587    if (pPage->cLocked)
     
    15401602 * @param   pVM         VM handle.
    15411603 */
    1542 DECL_FORCE_INLINE(bool) pgmMapAreMappingsEnabled(PPGM pPGM)
     1604DECL_FORCE_INLINE(bool) pgmMapAreMappingsEnabled(PVM pVM)
    15431605{
    15441606#ifdef PGM_WITHOUT_MAPPINGS
    15451607    /* There are no mappings in VT-x and AMD-V mode. */
    1546     Assert(pPGM->fMappingsDisabled);
     1608    Assert(pVM->pgm.s.fMappingsDisabled);
    15471609    return false;
    15481610#else
    1549     return !pPGM->fMappingsDisabled;
     1611    return !pVM->pgm.s.fMappingsDisabled;
    15501612#endif
    15511613}
     
    15581620 * @param   pVM         The VM handle.
    15591621 */
    1560 DECL_FORCE_INLINE(bool) pgmMapAreMappingsFloating(PPGM pPGM)
     1622DECL_FORCE_INLINE(bool) pgmMapAreMappingsFloating(PVM pVM)
    15611623{
    15621624#ifdef PGM_WITHOUT_MAPPINGS
    15631625    /* There are no mappings in VT-x and AMD-V mode. */
    1564     Assert(pPGM->fMappingsDisabled);
     1626    Assert(pVM->pgm.s.fMappingsDisabled);
    15651627    return false;
    15661628#else
    1567     return !pPGM->fMappingsDisabled
    1568         && !pPGM->fMappingsFixed;
     1629    return !pVM->pgm.s.fMappingsDisabled
     1630        && !pVM->pgm.s.fMappingsFixed;
    15691631#endif
    15701632}
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r36629 r36891  
    13261326#define PGM_RAM_RANGE_IS_AD_HOC(pRam) \
    13271327    (!!( (pRam)->fFlags & (PGM_RAM_RANGE_FLAGS_AD_HOC_ROM | PGM_RAM_RANGE_FLAGS_AD_HOC_MMIO | PGM_RAM_RANGE_FLAGS_AD_HOC_MMIO2) ) )
     1328
     1329/* enable the tlbs. */
     1330//#define PGM_USE_RAMRANGE_TLB
     1331/** The number of entries in the RAM range TLBs (there is one for each
     1332 *  context).  Must be a power of two. */
     1333#define PGM_RAMRANGE_TLB_ENTRIES            8
     1334
     1335/**
     1336 * Calculates the RAM range TLB index for the physical address.
     1337 *
     1338 * @returns RAM range TLB index.
     1339 * @param   GCPhys      The guest physical address.
     1340 */
     1341#define PGM_RAMRANGE_TLB_IDX(a_GCPhys)      ( ((a_GCPhys) >> 20) & (PGM_RAMRANGE_TLB_ENTRIES - 1) )
     1342
    13281343
    13291344
     
    27922807    STAMCOUNTER StatR3PageMapTlbHits;               /**< R3: Ring-3/0 page mapper TLB hits. */
    27932808    STAMCOUNTER StatR3PageMapTlbMisses;             /**< R3: Ring-3/0 page mapper TLB misses. */
     2809    STAMCOUNTER StatRZRamRangeTlbHits;              /**< RC/R0: RAM range TLB hits. */
     2810    STAMCOUNTER StatRZRamRangeTlbMisses;            /**< RC/R0: RAM range TLB misses. */
     2811    STAMCOUNTER StatR3RamRangeTlbHits;              /**< R3: RAM range TLB hits. */
     2812    STAMCOUNTER StatR3RamRangeTlbMisses;            /**< R3: RAM range TLB misses. */
    27942813    STAMPROFILE StatRZSyncCR3HandlerVirtualReset;   /**< RC/R0: Profiling of the virtual handler resets. */
    27952814    STAMPROFILE StatRZSyncCR3HandlerVirtualUpdate;  /**< RC/R0: Profiling of the virtual handler updates. */
     
    29462965    /** Pointer to the list of RAM ranges (Phys GC -> Phys HC conversion) - for R3.
    29472966     * This is sorted by physical address and contains no overlapping ranges. */
    2948     R3PTRTYPE(PPGMRAMRANGE)         pRamRangesR3;
     2967    R3PTRTYPE(PPGMRAMRANGE)         pRamRangesXR3;
     2968#ifdef PGM_USE_RAMRANGE_TLB
     2969    /** Ram range TLB for R3. */
     2970    R3PTRTYPE(PPGMRAMRANGE)         apRamRangesTlbR3[PGM_RAMRANGE_TLB_ENTRIES];
     2971#endif
    29492972    /** PGM offset based trees - R3 Ptr. */
    29502973    R3PTRTYPE(PPGMTREES)            pTreesR3;
     
    29672990    /*RTR3PTR                         R3PtrAlignment0;*/
    29682991
    2969 
    2970     /** R0 pointer corresponding to PGM::pRamRangesR3. */
    2971     R0PTRTYPE(PPGMRAMRANGE)         pRamRangesR0;
     2992    /** R0 pointer corresponding to PGM::pRamRangesXR3. */
     2993    R0PTRTYPE(PPGMRAMRANGE)         pRamRangesXR0;
     2994#ifdef PGM_USE_RAMRANGE_TLB
     2995    /** Ram range TLB for R0. */
     2996    R0PTRTYPE(PPGMRAMRANGE)         apRamRangesTlbR0[PGM_RAMRANGE_TLB_ENTRIES];
     2997#endif
    29722998    /** PGM offset based trees - R0 Ptr. */
    29732999    R0PTRTYPE(PPGMTREES)            pTreesR0;
     
    29843010
    29853011
    2986     /** RC pointer corresponding to PGM::pRamRangesR3. */
    2987     RCPTRTYPE(PPGMRAMRANGE)         pRamRangesRC;
     3012    /** RC pointer corresponding to PGM::pRamRangesXR3. */
     3013    RCPTRTYPE(PPGMRAMRANGE)         pRamRangesXRC;
     3014#ifdef PGM_USE_RAMRANGE_TLB
     3015    /** Ram range TLB for RC. */
     3016    RCPTRTYPE(PPGMRAMRANGE)         apRamRangesTlbRC[PGM_RAMRANGE_TLB_ENTRIES];
     3017#endif
    29883018    /** PGM offset based trees - RC Ptr. */
    29893019    RCPTRTYPE(PPGMTREES)            pTreesRC;
     
    37713801int             pgmPhysAllocLargePage(PVM pVM, RTGCPHYS GCPhys);
    37723802int             pgmPhysRecheckLargePage(PVM pVM, RTGCPHYS GCPhys, PPGMPAGE pLargePage);
    3773 int             pgmPhysPageLoadIntoTlb(PPGM pPGM, RTGCPHYS GCPhys);
    3774 int             pgmPhysPageLoadIntoTlbWithPage(PPGM pPGM, PPGMPAGE pPage, RTGCPHYS GCPhys);
     3803int             pgmPhysPageLoadIntoTlb(PVM pVM, RTGCPHYS GCPhys);
     3804int             pgmPhysPageLoadIntoTlbWithPage(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys);
    37753805void            pgmPhysPageMakeWriteMonitoredWritable(PVM pVM, PPGMPAGE pPage);
    37763806int             pgmPhysPageMakeWritable(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys);
     
    37843814VMMDECL(int)    pgmPhysRomWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
    37853815int             pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys);
     3816void            pgmPhysInvalidRamRangeTlbs(PVM pVM);
     3817PPGMRAMRANGE    pgmPhysGetRangeSlow(PVM pVM, RTGCPHYS GCPhys);
     3818PPGMRAMRANGE    pgmPhysGetRangeAtOrAboveSlow(PVM pVM, RTGCPHYS GCPhys);
     3819PPGMPAGE        pgmPhysGetPageSlow(PVM pVM, RTGCPHYS GCPhys);
     3820int             pgmPhysGetPageExSlow(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGE ppPage);
     3821int             pgmPhysGetPageAndRangeExSlow(PVM pVM, RTGCPHYS GCPhys, PPPGMPAGE ppPage, PPGMRAMRANGE *ppRam);
    37863822
    37873823#ifdef IN_RING3
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