VirtualBox

Changeset 9690 in vbox


Ignore:
Timestamp:
Jun 13, 2008 3:51:14 PM (17 years ago)
Author:
vboxsync
Message:

Paging updates for amd64.

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

Legend:

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

    r9596 r9690  
    12791279/** The extended PAE page directory (2048 entries, works as root currently). */
    12801280#define PGMPOOL_IDX_PAE_PD      2
    1281  /** PAE Page Directory Table 0. */
     1281/** PAE Page Directory Table 0. */
    12821282#define PGMPOOL_IDX_PAE_PD_0    3
    1283  /** PAE Page Directory Table 1. */
     1283/** PAE Page Directory Table 1. */
    12841284#define PGMPOOL_IDX_PAE_PD_1    4
    1285  /** PAE Page Directory Table 2. */
     1285/** PAE Page Directory Table 2. */
    12861286#define PGMPOOL_IDX_PAE_PD_2    5
    1287  /** PAE Page Directory Table 3. */
     1287/** PAE Page Directory Table 3. */
    12881288#define PGMPOOL_IDX_PAE_PD_3    6
     1289/** AMD64 Page Directory Table. */
     1290#define PGMPOOL_IDX_AMD64_PD    7
    12891291/** Page Directory Pointer Table (PAE root, not currently used). */
    1290 #define PGMPOOL_IDX_PDPT        7
     1292#define PGMPOOL_IDX_PDPT        8
    12911293/** Page Map Level-4 (64-bit root). */
    1292 #define PGMPOOL_IDX_PML4        8
     1294#define PGMPOOL_IDX_PML4        9
    12931295/** The first normal index. */
    1294 #define PGMPOOL_IDX_FIRST       9
     1296#define PGMPOOL_IDX_FIRST       10
    12951297/** The last valid index. (inclusive, 14 bits) */
    12961298#define PGMPOOL_IDX_LAST        0x3fff
     
    13091311    uint16_t            iNext;
    13101312    /** The user page index. */
    1311     uint16_t            iUser;
     1313    uint32_t            iUser;
    13121314    /** Index into the user table. */
    1313     uint16_t            iUserTable;
     1315    uint32_t            iUserTable;
    13141316} PGMPOOLUSER, *PPGMPOOLUSER;
    13151317typedef const PGMPOOLUSER *PCPGMPOOLUSER;
     
    13691371    /** Shw: 64-bit page directory pointer table;   Gst: 64-bit page directory pointer table. */
    13701372    PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT,
     1373    /** Shw: 64-bit page directory table;   Gst: 64-bit page directory table. */
     1374    PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD,
    13711375
    13721376    /** Shw: Root 32-bit page directory. */
     
    26232627void           *pgmGCPoolMapPage(PVM pVM, PPGMPOOLPAGE pPage);
    26242628#endif
    2625 int             pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint16_t iUserTable, PPPGMPOOLPAGE ppPage);
     2629int             pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage);
    26262630PPGMPOOLPAGE    pgmPoolGetPageByHCPhys(PVM pVM, RTHCPHYS HCPhys);
    2627 void            pgmPoolFree(PVM pVM, RTHCPHYS HCPhys, uint16_t iUser, uint16_t iUserTable);
    2628 void            pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint16_t iUserTable);
     2631void            pgmPoolFree(PVM pVM, RTHCPHYS HCPhys, uint16_t iUser, uint32_t iUserTable);
     2632void            pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable);
    26292633int             pgmPoolFlushPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage);
    26302634void            pgmPoolFlushAll(PVM pVM);
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r9686 r9690  
    779779
    780780        Assert(!(pPdpe->u & X86_PDPE_PG_MASK));
    781         rc = pgmPoolAlloc(pVM, pPdptGst->a[iPdPt].u & X86_PDPE_PG_MASK, PGMPOOLKIND_PAE_PD_FOR_PAE_PD, PGMPOOL_IDX_PDPT, iPdPt, &pShwPage);
     781        rc = pgmPoolAlloc(pVM, pPdptGst->a[iPdPt].u & X86_PDPE_PG_MASK, PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD, PGMPOOL_IDX_PDPT, iPml4e * X86_PG_PAE_ENTRIES + iPdPt, &pShwPage);
    782782        if (rc == VERR_PGM_POOL_FLUSHED)
    783783            return VINF_PGM_SYNC_CR3;
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r9684 r9690  
    21532153    PX86PDPAE       pPDDst = pVM->pgm.s.CTXMID(ap,PaePDs)[0];
    21542154# elif PGM_SHW_TYPE == PGM_TYPE_AMD64
     2155    const unsigned  iPml4e = (GCPtrPage >> X86_PML4_SHIFT) & X86_PML4_MASK;
     2156    const unsigned  iPdPte = (GCPtrPage >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64;
    21552157    const unsigned  iPDDst = (GCPtrPage >> SHW_PD_SHIFT) & SHW_PD_MASK;
    21562158    PX86PDPAE       pPDDst;
     
    21662168    PSHWPDE         pPdeDst = &pPDDst->a[iPDDst];
    21672169    SHWPDE          PdeDst = *pPdeDst;
     2170
     2171    /* Calculate unique identifier for the PD pool allocations. */
     2172# if PGM_SHW_TYPE == PGM_TYPE_AMD64
     2173    const unsigned iPoolIdx = (iPml4e * X86_PG_PAE_ENTRIES + iPdPte) * X86_PG_PAE_ENTRIES + iPDDst;
     2174# else
     2175    const unsigned iPoolIdx = iPDDst;
     2176# endif
    21682177
    21692178# ifndef PGM_WITHOUT_MAPPINGS
     
    22272236            GCPhys |= (iPDDst & 1) * (PAGE_SIZE / 2);
    22282237# endif
    2229             rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_PT, SHW_POOL_ROOT_IDX, iPDDst, &pShwPage);
     2238            rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_PT, SHW_POOL_ROOT_IDX, iPoolIdx, &pShwPage);
    22302239        }
    22312240        else
     
    22362245            GCPhys |= GCPtrPage & (1 << X86_PD_PAE_SHIFT);
    22372246# endif
    2238             rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_BIG, SHW_POOL_ROOT_IDX, iPDDst, &pShwPage);
     2247            rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_BIG, SHW_POOL_ROOT_IDX, iPoolIdx, &pShwPage);
    22392248        }
    22402249        if (rc == VINF_SUCCESS)
     
    30083017                                && !(pPDDst->a[iPD].u & PGM_PDFLAGS_MAPPING))
    30093018                            {
    3010                                 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDDst->a[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PAE_PD, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD);
     3019                                AssertCompile(PGMPOOL_IDX_AMD64_PD == SHW_POOL_ROOT_IDX);
     3020                                pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDDst->a[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_AMD64_PD, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD);
    30113021                                pPDDst->a[iPD].u = 0;
    30123022                            }
    30133023                        }
    30143024
    3015                         pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPDPTE);
     3025                        pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPML4E * X86_PG_PAE_ENTRIES + iPDPTE);
    30163026                        pPdptDst->a[iPDPTE].u = 0;
    30173027                    }
     
    30713081                        {
    30723082#   if PGM_GST_TYPE == PGM_TYPE_AMD64
    3073                             pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PAE_PD, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD);
     3083                            pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), SHW_POOL_ROOT_IDX, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD);
    30743084#   else
    3075                             pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PAE_PD, iPDPTE * X86_PG_PAE_ENTRIES + iPD);
     3085                            pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), SHW_POOL_ROOT_IDX, iPDPTE * X86_PG_PAE_ENTRIES + iPD);
    30763086#   endif
    30773087                            pPDEDst[iPD].u = 0;
     
    30843094                    if (!(pPdptDst->a[iPDPTE].u & PGM_PLXFLAGS_PERMANENT))
    30853095                    {
    3086                         pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPDPTE);
     3096#   if PGM_GST_TYPE == PGM_TYPE_AMD64
     3097                        pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPML4E * X86_PG_PAE_ENTRIES + iPDPTE);
     3098#   else
     3099                        AssertFailed(); /* can't happen; the 4 pdpt pages are fixed! */
     3100#   endif
    30873101                        pPdptDst->a[iPDPTE].u = 0;
    30883102                    }
     
    31623176#  if PGM_SHW_TYPE == PGM_TYPE_PAE && PGM_GST_TYPE == PGM_TYPE_32BIT
    31633177                    for (unsigned i = 0, iPdShw = iPD * 2; i < 2; i++, iPdShw++) /* pray that the compiler unrolls this */
    3164 #  elif PGM_GST_TYPE == PGM_TYPE_PAE || PGM_GST_TYPE == PGM_TYPE_AMD64
     3178#  elif PGM_GST_TYPE == PGM_TYPE_PAE
    31653179                    const unsigned iPdShw = iPD + iPDPTE * X86_PG_PAE_ENTRIES; NOREF(iPdShw);
     3180#  elif PGM_GST_TYPE == PGM_TYPE_AMD64
     3181                    const unsigned iPdShw = iPD + (iPDPTE + iPML4E * X86_PG_PAE_ENTRIES) * X86_PG_PAE_ENTRIES; NOREF(iPdShw);
    31663182#  else
    31673183                    const unsigned iPdShw = iPD; NOREF(iPdShw);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r9689 r9690  
    5555#endif
    5656#ifdef PGMPOOL_WITH_CACHE
    57 static int pgmPoolTrackAddUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint16_t iUserTable);
     57static int pgmPoolTrackAddUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable);
    5858#endif
    5959#ifdef PGMPOOL_WITH_MONITORING
     
    10471047 * @param   ppPage      Where to store the pointer to the page.
    10481048 */
    1049 static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint16_t iUserTable, PPPGMPOOLPAGE ppPage)
     1049static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage)
    10501050{
    10511051#ifndef IN_GC
     
    18161816 * @param   iUserTable  The user table index.
    18171817 */
    1818 DECLINLINE(int) pgmPoolTrackInsert(PPGMPOOL pPool, PPGMPOOLPAGE pPage, RTGCPHYS GCPhys, uint16_t iUser, uint16_t iUserTable)
     1818DECLINLINE(int) pgmPoolTrackInsert(PPGMPOOL pPool, PPGMPOOLPAGE pPage, RTGCPHYS GCPhys, uint16_t iUser, uint32_t iUserTable)
    18191819{
    18201820    int rc = VINF_SUCCESS;
     
    19061906 * @param   iUserTable  The user table.
    19071907 */
    1908 static int pgmPoolTrackAddUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint16_t iUserTable)
     1908static int pgmPoolTrackAddUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable)
    19091909{
    19101910    PPGMPOOLUSER paUsers = pPool->CTXSUFF(paUsers);
     
    19701970 * @param   iUserTable  The index into the user table (shadowed).
    19711971 */
    1972 static void pgmPoolTrackFreeUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint16_t iUserTable)
     1972static void pgmPoolTrackFreeUser(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable)
    19731973{
    19741974    /*
     
    23932393            Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
    23942394            break;
     2395        case PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD:
     2396            Assert(!(u.pau64[pUser->iUser] & PGM_PDFLAGS_MAPPING));
     2397            Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES*X86_PG_PAE_ENTRIES && pUser->iUser == PGMPOOL_IDX_PDPT);
     2398            break;
    23952399        case PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT:
     2400            Assert(!(u.pau64[pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));
     2401            Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES && pUser->iUser == PGMPOOL_IDX_PML4);
     2402            break;
    23962403        case PGMPOOLKIND_ROOT_PML4:
    23972404            Assert(!(u.pau64[pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));
     
    31973204        paUsers[i].iNext = i + 1;
    31983205        paUsers[i].iUser = NIL_PGMPOOL_IDX;
    3199         paUsers[i].iUserTable = 0xfffe;
     3206        paUsers[i].iUserTable = 0xfffffffe;
    32003207    }
    32013208    paUsers[cMaxUsers - 1].iNext = NIL_PGMPOOL_USER_INDEX;
     
    33743381 * @param   iUserTable  The index into the user table (shadowed).
    33753382 */
    3376 void pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint16_t iUserTable)
     3383void pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable)
    33773384{
    33783385    STAM_PROFILE_START(&pPool->StatFree, a);
     
    34593466 * @param   ppPage      Where to store the pointer to the page. NULL is stored here on failure.
    34603467 */
    3461 int pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint16_t iUserTable, PPPGMPOOLPAGE ppPage)
     3468int pgmPoolAlloc(PVM pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint32_t iUserTable, PPPGMPOOLPAGE ppPage)
    34623469{
    34633470    PPGMPOOL pPool = pVM->pgm.s.CTXSUFF(pPool);
     
    35793586 * @param   iUserTable  The index into the user table (shadowed).
    35803587 */
    3581 void pgmPoolFree(PVM pVM, RTHCPHYS HCPhys, uint16_t iUser, uint16_t iUserTable)
     3588void pgmPoolFree(PVM pVM, RTHCPHYS HCPhys, uint16_t iUser, uint32_t iUserTable)
    35823589{
    35833590    LogFlow(("pgmPoolFree: HCPhys=%VHp iUser=%#x iUserTable=%#x\n", HCPhys, iUser, iUserTable));
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r9039 r9690  
    7878# define SHW_PDPT_MASK         X86_PDPT_MASK_AMD64
    7979# define SHW_TOTAL_PD_ENTRIES   (X86_PG_AMD64_ENTRIES*X86_PG_AMD64_PDPE_ENTRIES)
    80 # define SHW_POOL_ROOT_IDX      PGMPOOL_IDX_PML4
     80# define SHW_POOL_ROOT_IDX      PGMPOOL_IDX_AMD64_PD
    8181#else /* 32 bits PAE mode */
    8282# define SHW_PDPT_SHIFT        X86_PDPT_SHIFT
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