VirtualBox

Changeset 15348 in vbox


Ignore:
Timestamp:
Dec 12, 2008 2:00:10 AM (16 years ago)
Author:
vboxsync
Message:

#3202: Optimized PGMPOOL_PAGE_2_PTR for darwin/R0 and */RC.

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

Legend:

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

    r15346 r15348  
    18171817
    18181818
     1819#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
     1820DECLINLINE(void *) pgmPoolMapPageInlined(PVM pVM, PPGMPOOLPAGE pPage);
     1821#endif
     1822
    18191823/** @def PGMPOOL_PAGE_2_PTR
    18201824 * Maps a pool page pool into the current context.
     
    18241828 * @param   pPage   The pool page.
    18251829 *
    1826  * @remark  In HC this uses PGMGCDynMapHCPage(), so it will consume of the
     1830 * @remark  In RC this uses PGMGCDynMapHCPage(), so it will consume of the
    18271831 *          small page window employeed by that function. Be careful.
    18281832 * @remark  There is no need to assert on the result.
    18291833 */
    18301834#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    1831 # define PGMPOOL_PAGE_2_PTR(pVM, pPage)    pgmPoolMapPage((pVM), (pPage))
     1835# define PGMPOOL_PAGE_2_PTR(pVM, pPage)  pgmPoolMapPageInlined(&(pVM)->pgm.s, (pPage))
     1836#elif defined(VBOX_STRICT)
     1837# define PGMPOOL_PAGE_2_PTR(pVM, pPage)  pgmPoolMapPageStrict(pPage)
     1838DECLINLINE(void *) pgmPoolMapPageStrict(PPGMPOOLPAGE pPage)
     1839{
     1840    Assert(pPage->pvPageR3);
     1841    return pPage->pvPageR3;
     1842}
    18321843#else
    1833  DECLINLINE(R3R0PTRTYPE(void *)) PGMPOOL_PAGE_2_PTR(PVM pVM, PPGMPOOLPAGE pPage)
    1834  {
    1835      Assert(pPage->pvPageR3);
    1836      return pPage->pvPageR3;
    1837  }
    1838 #endif
     1844# define PGMPOOL_PAGE_2_PTR(pVM, pPage)  ((pPage)->pvPageR3)
     1845#endif
     1846
     1847/** @def PGMPOOL_PAGE_2_PTR_BY_PGM
     1848 * Maps a pool page pool into the current context.
     1849 *
     1850 * @returns VBox status code.
     1851 * @param   pPGM    Pointer to the PGM instance data.
     1852 * @param   pPage   The pool page.
     1853 *
     1854 * @remark  In RC this uses PGMGCDynMapHCPage(), so it will consume of the
     1855 *          small page window employeed by that function. Be careful.
     1856 * @remark  There is no need to assert on the result.
     1857 */
     1858#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
     1859# define PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pPage)  pgmPoolMapPageInlined((pPGM), (pPage))
     1860#else
     1861# define PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pPage)  PGMPOOL_PAGE_2_PTR(PGM2VM(pPGM), pPage)
     1862#endif
     1863
    18391864
    18401865
     
    28972922#endif
    28982923#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    2899 void           *pgmPoolMapPage(PVM pVM, PPGMPOOLPAGE pPage);
     2924void           *pgmPoolMapPageFallback(PPGM pPGM, PPGMPOOLPAGE pPage);
    29002925#endif
    29012926int             pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage);
     
    40764101{
    40774102#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    4078     return (PX86PD)PGMPOOL_PAGE_2_PTR(PGM2VM(pPGM), pPGM->CTX_SUFF(pShwPageCR3));
     4103    return (PX86PD)PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pPGM->CTX_SUFF(pShwPageCR3));
    40794104#else
    40804105# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
     
    41394164{
    41404165#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    4141     return (PX86PDPT)PGMPOOL_PAGE_2_PTR(PGM2VM(pPGM), pPGM->CTX_SUFF(pShwPageCR3));
     4166    return (PX86PDPT)PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pPGM->CTX_SUFF(pShwPageCR3));
    41424167#else
    41434168# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
     
    41714196    AssertReturn(pShwPde, NULL);
    41724197
    4173     return (PX86PDPAE)PGMPOOL_PAGE_2_PTR(PGM2VM(pPGM), pShwPde);
     4198    return (PX86PDPAE)PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pShwPde);
    41744199#else
    41754200    const unsigned  iPdpt = (GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE;
     
    42364261{
    42374262#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    4238     return (PX86PML4)PGMPOOL_PAGE_2_PTR(PGM2VM(pPGM), pPGM->CTX_SUFF(pShwPageCR3));
     4263    return (PX86PML4)PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pPGM->CTX_SUFF(pShwPageCR3));
    42394264#else
    42404265# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
     
    45874612#endif /* PGMPOOL_WITH_CACHE */
    45884613
     4614
     4615#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
     4616/**
     4617 * Maps the page into current context (RC and maybe R0).
     4618 *
     4619 * @returns pointer to the mapping.
     4620 * @param   pVM         Pointer to the PGM instance data.
     4621 * @param   pPage       The page.
     4622 */
     4623DECLINLINE(void *) pgmPoolMapPageInlined(PPGM pPGM, PPGMPOOLPAGE pPage)
     4624{
     4625    if (pPage->idx >= PGMPOOL_IDX_FIRST)
     4626    {
     4627        Assert(pPage->idx < pPGM->CTX_SUFF(pPool)->cCurPages);
     4628        void *pv;
     4629# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
     4630        int rc = pgmR0DynMapHCPageInlined(pPGM, pPage->Core.Key, &pv);
     4631# else
     4632        int rc = PGMDynMapHCPage(PGM2VM(pPGM), pPage->Core.Key, &pv);
     4633# endif
     4634        if (RT_SUCCESS(rc))
     4635            return pv;
     4636    }
     4637    return pgmPoolMapPageFallback(pPGM, pPage);
     4638}
     4639#endif
     4640
     4641
    45894642/**
    45904643 * Tells if mappings are to be put into the shadow page table or not
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r15344 r15348  
    9292 *
    9393 * @returns Pointer to the mapping.
    94  * @param   pVM     The VM handle.
     94 * @param   pPGM    Pointer to the PGM instance data.
    9595 * @param   pPage   The page to map.
    9696 */
    97 void *pgmPoolMapPage(PVM pVM, PPGMPOOLPAGE pPage)
    98 {
    99     /* general pages. */
    100     if (pPage->idx >= PGMPOOL_IDX_FIRST)
    101     {
    102         Assert(pPage->idx < pVM->pgm.s.CTX_SUFF(pPool)->cCurPages);
    103         void *pv;
    104 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    105         int rc = pgmR0DynMapHCPageInlined(&pVM->pgm.s, pPage->Core.Key, &pv);
    106 # else
    107         int rc = PGMDynMapHCPage(pVM, pPage->Core.Key, &pv);
    108 # endif
    109         AssertReleaseRC(rc);
    110         return pv;
    111     }
    112 
     97void *pgmPoolMapPageFallback(PPGM pPGM, PPGMPOOLPAGE pPage)
     98{
     99    /* general pages are take care of by the inlined part, it
     100       only ends up here in case of failure. */
     101    AssertReleaseReturn(pPage->idx < PGMPOOL_IDX_FIRST, NULL);
     102
     103/** @todo make sure HCPhys is valid for *all* indexes. */
    113104    /* special pages. */
    114105# ifdef IN_RC
     
    116107    {
    117108        case PGMPOOL_IDX_PD:
    118             return pVM->pgm.s.pShw32BitPdRC;
     109            return pPGM->pShw32BitPdRC;
    119110        case PGMPOOL_IDX_PAE_PD:
    120111        case PGMPOOL_IDX_PAE_PD_0:
    121             return pVM->pgm.s.apShwPaePDsRC[0];
     112            return pPGM->apShwPaePDsRC[0];
    122113        case PGMPOOL_IDX_PAE_PD_1:
    123             return pVM->pgm.s.apShwPaePDsRC[1];
     114            return pPGM->apShwPaePDsRC[1];
    124115        case PGMPOOL_IDX_PAE_PD_2:
    125             return pVM->pgm.s.apShwPaePDsRC[2];
     116            return pPGM->apShwPaePDsRC[2];
    126117        case PGMPOOL_IDX_PAE_PD_3:
    127             return pVM->pgm.s.apShwPaePDsRC[3];
     118            return pPGM->apShwPaePDsRC[3];
    128119        case PGMPOOL_IDX_PDPT:
    129             return pVM->pgm.s.pShwPaePdptRC;
     120            return pPGM->pShwPaePdptRC;
    130121        default:
    131122            AssertReleaseMsgFailed(("Invalid index %d\n", pPage->idx));
     
    138129    {
    139130        case PGMPOOL_IDX_PD:
    140             HCPhys = pVM->pgm.s.HCPhysShw32BitPD;
     131            HCPhys = pPGM->HCPhysShw32BitPD;
    141132            break;
    142133        case PGMPOOL_IDX_PAE_PD_0:
    143             HCPhys = pVM->pgm.s.aHCPhysPaePDs[0];
     134            HCPhys = pPGM->aHCPhysPaePDs[0];
    144135            break;
    145136        case PGMPOOL_IDX_PAE_PD_1:
    146             HCPhys = pVM->pgm.s.aHCPhysPaePDs[1];
     137            HCPhys = pPGM->aHCPhysPaePDs[1];
    147138            break;
    148139        case PGMPOOL_IDX_PAE_PD_2:
    149             HCPhys = pVM->pgm.s.aHCPhysPaePDs[2];
     140            HCPhys = pPGM->aHCPhysPaePDs[2];
    150141            break;
    151142        case PGMPOOL_IDX_PAE_PD_3:
    152             HCPhys = pVM->pgm.s.aHCPhysPaePDs[3];
     143            HCPhys = pPGM->aHCPhysPaePDs[3];
    153144            break;
    154145        case PGMPOOL_IDX_PDPT:
    155             HCPhys = pVM->pgm.s.HCPhysShwPaePdpt;
     146            HCPhys = pPGM->HCPhysShwPaePdpt;
    156147            break;
    157148        case PGMPOOL_IDX_PAE_PD:
     
    163154    }
    164155    void *pv;
    165     int rc = pgmR0DynMapHCPageInlined(&pVM->pgm.s, HCPhys, &pv);
    166     AssertReleaseRC(rc);
     156    int rc = pgmR0DynMapHCPageInlined(pPGM, HCPhys, &pv);
     157    AssertReleaseRCReturn(rc, NULL);
    167158    return pv;
    168159# endif /* VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
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