VirtualBox

Changeset 6869 in vbox


Ignore:
Timestamp:
Feb 8, 2008 3:47:35 PM (17 years ago)
Author:
vboxsync
Message:

Use PGM_PAGE_SET/GET/IS/CLEAR/INIT macros.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/MMPagePool.cpp

    r6529 r6869  
    494494        AssertRelease(pVM->mm.s.pvDummyPage);
    495495        pVM->mm.s.HCPhysDummyPage = mmPagePoolPtr2Phys(pVM->mm.s.pPagePool, pVM->mm.s.pvDummyPage);
     496        AssertRelease(!(pVM->mm.s.HCPhysDummyPage & ~X86_PTE_PAE_PG_MASK));
    496497    }
    497498    return pVM->mm.s.pvDummyPage;
  • trunk/src/VBox/VMM/PGMInternal.h

    r6862 r6869  
    508508 * of information into as few bits as possible. The format is also subject
    509509 * to change (there is one comming up soon). Which means that for we'll be
    510  * using PGM_PAGE_GET_* and PGM_PAGE_SET_* macros for all accessess to the
    511  * structure.
     510 * using PGM_PAGE_GET_*, PGM_PAGE_IS_ and PGM_PAGE_SET_* macros for *all*
     511 * accessess to the structure.
    512512 */
    513513typedef struct PGMPAGE
     
    516516    RTHCPHYS    HCPhys;
    517517    /** The page state. */
    518     uint32_t    u2State : 2;
     518    uint32_t    u2StateX : 2;
    519519    /** Flag indicating that a write monitored page was written to when set. */
    520     uint32_t    fWrittenTo : 1;
     520    uint32_t    fWrittenToX : 1;
    521521    /** For later. */
    522522    uint32_t    fSomethingElse : 1;
     
    524524     * @todo  Merge with HCPhys once we've liberated HCPhys of its stuff.
    525525     *        The HCPhys will be 100% static. */
    526     uint32_t    idPage : 28;
     526    uint32_t    idPageX : 28;
    527527    /** The page type (PGMPAGETYPE). */
    528528    uint32_t    u3Type : 3;
     
    537537typedef PPGMPAGE *PPPGMPAGE;
    538538
    539 /** @name The Page state, PGMPAGE::u2State.
     539
     540/**
     541 * Clears the page structure.
     542 * @param   pPage       Pointer to the physical guest page tracking structure.
     543 */
     544#define PGM_PAGE_CLEAR(pPage) \
     545    do { \
     546        (pPage)->HCPhys         = 0; \
     547        (pPage)->u2StateX       = 0; \
     548        (pPage)->fWrittenToX    = 0; \
     549        (pPage)->fSomethingElse = 0; \
     550        (pPage)->idPageX        = 0; \
     551        (pPage)->u3Type         = 0; \
     552        (pPage)->u29B           = 0; \
     553    } while (0)
     554
     555/**
     556 * Clears the page structure.
     557 * @param   pPage       Pointer to the physical guest page tracking structure.
     558 */
     559#define PGM_PAGE_INIT(pPage, _HCPhys, _idPage, _uType, _uState) \
     560    do { \
     561        (pPage)->HCPhys         = (_HCPhys); \
     562        (pPage)->u2StateX       = (_uState); \
     563        (pPage)->fWrittenToX    = 0; \
     564        (pPage)->fSomethingElse = 0; \
     565        (pPage)->idPageX        = (_idPage); \
     566        (pPage)->u3Type         = (_uType); \
     567        (pPage)->u29B           = 0; \
     568    } while (0)
     569
     570/**
     571 * Clears the page structure.
     572 * @param   pPage       Pointer to the physical guest page tracking structure.
     573 */
     574#ifdef VBOX_WITH_NEW_PHYS_CODE
     575# define PGM_PAGE_INIT_ZERO(pPage, pVM, _uType)  \
     576    PGM_PAGE_INIT(pPage, (pVM)->pgm.s.HCPhysZeroPg, NIL_GMM_PAGEID, PGM_PAGE_STATE_ZERO, (_uType))
     577#else
     578# define PGM_PAGE_INIT_ZERO(pPage, pVM, _uType)  \
     579    PGM_PAGE_INIT(pPage, 0, NIL_GMM_PAGEID, PGM_PAGE_STATE_ZERO, (_uType))
     580#endif
     581/** Temporary hack. Replaced by PGM_PAGE_INIT_ZERO once the old code is kicked out. */
     582# define PGM_PAGE_INIT_ZERO_REAL(pPage, pVM, _uType)  \
     583    PGM_PAGE_INIT(pPage, (pVM)->pgm.s.HCPhysZeroPg, NIL_GMM_PAGEID, PGM_PAGE_STATE_ZERO, (_uType))
     584
     585
     586/** @name The Page state, PGMPAGE::u2StateX.
    540587 * @{ */
    541588/** The zero page.
     
    562609 * @param   pPage       Pointer to the physical guest page tracking structure.
    563610 */
    564 #define PGM_PAGE_GET_STATE(pPage)       ( (pPage)->u2State )
     611#define PGM_PAGE_GET_STATE(pPage)       ( (pPage)->u2StateX )
    565612
    566613/**
     
    570617 */
    571618#define PGM_PAGE_SET_STATE(pPage, _uState) \
    572                                         do { (pPage)->u2State = (_uState); } while (0)
     619                                        do { (pPage)->u2StateX = (_uState); } while (0)
    573620
    574621
     
    594641 * @param   pPage       Pointer to the physical guest page tracking structure.
    595642 */
    596 #define PGM_PAGE_GET_PAGEID(pPage)      ( (pPage)->idPage )
     643#define PGM_PAGE_GET_PAGEID(pPage)      ( (pPage)->idPageX )
    597644/* later:
    598645#define PGM_PAGE_GET_PAGEID(pPage)      (   ((uint32_t)(pPage)->HCPhys >> (48 - 12))
     
    603650 * @param   pPage       Pointer to the physical guest page tracking structure.
    604651 */
    605 #define PGM_PAGE_SET_PAGEID(pPage, _idPage)  do { (pPage)->idPage = (_idPage); } while (0)
     652#define PGM_PAGE_SET_PAGEID(pPage, _idPage)  do { (pPage)->idPageX = (_idPage); } while (0)
    606653/* later:
    607654#define PGM_PAGE_SET_PAGEID(pPage, _idPage)  do { (pPage)->HCPhys = (((pPage)->HCPhys) & UINT64_C(0x0000fffffffff000)) \
     
    615662 * @param   pPage       Pointer to the physical guest page tracking structure.
    616663 */
    617 #define PGM_PAGE_GET_CHUNKID(pPage)     ( (pPage)->idPage >> GMM_CHUNKID_SHIFT )
     664#define PGM_PAGE_GET_CHUNKID(pPage)     ( (pPage)->idPageX >> GMM_CHUNKID_SHIFT )
    618665/* later:
    619666#if GMM_CHUNKID_SHIFT == 12
     
    634681 * @param   pPage       Pointer to the physical guest page tracking structure.
    635682 */
    636 #define PGM_PAGE_GET_PAGE_IN_CHUNK(pPage)   ( (pPage)->idPage & GMM_PAGEID_IDX_MASK )
     683#define PGM_PAGE_GET_PAGE_IN_CHUNK(pPage)   ( (pPage)->idPageX & GMM_PAGEID_IDX_MASK )
    637684/* later:
    638685#if GMM_CHUNKID_SHIFT <= 12
     
    680727 * @param   pPage       Pointer to the physical guest page tracking structure.
    681728 */
    682 #define PGM_PAGE_IS_ZERO(pPage)         ( (pPage)->u2State == PGM_PAGE_STATE_ZERO )
     729#define PGM_PAGE_IS_ZERO(pPage)         ( (pPage)->u2StateX == PGM_PAGE_STATE_ZERO )
    683730
    684731/**
     
    687734 * @param   pPage       Pointer to the physical guest page tracking structure.
    688735 */
    689 #define PGM_PAGE_IS_SHARED(pPage)        ( (pPage)->u2State == PGM_PAGE_STATE_SHARED )
    690 
     736#define PGM_PAGE_IS_SHARED(pPage)        ( (pPage)->u2StateX == PGM_PAGE_STATE_SHARED )
     737
     738
     739/**
     740 * Marks the paget as written to (for GMM change monitoring).
     741 * @param   pPage       Pointer to the physical guest page tracking structure.
     742 */
     743#define PGM_PAGE_SET_WRITTEN_TO(pPage)      do { (pPage)->fWrittenToX = 1; } while (0)
     744
     745/**
     746 * Clears the written-to indicator.
     747 * @param   pPage       Pointer to the physical guest page tracking structure.
     748 */
     749#define PGM_PAGE_CLEAR_WRITTEN_TO(pPage)    do { (pPage)->fWrittenToX = 0; } while (0)
     750
     751/**
     752 * Checks if the page was marked as written-to.
     753 * @returns true/false.
     754 * @param   pPage       Pointer to the physical guest page tracking structure.
     755 */
     756#define PGM_PAGE_IS_WRITTEN_TO(pPage)       ( (pPage)->fWrittenToX )
    691757
    692758/**
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r6861 r6869  
    227227    RTGCPHYS iPage = cPages;
    228228    while (iPage-- > 0)
    229     {
    230 #ifdef VBOX_WITH_NEW_PHYS_CODE
    231         pNew->aPages[iPage].HCPhys = pVM->pgm.s.HCPhysZeroPg;
    232 #else
    233         pNew->aPages[iPage].HCPhys = 0;
    234 #endif
    235         pNew->aPages[iPage].fWrittenTo = 0;
    236         pNew->aPages[iPage].fSomethingElse = 0;
    237         pNew->aPages[iPage].u29B = 0;
    238         PGM_PAGE_SET_TYPE(&pNew->aPages[iPage],   PGMPAGETYPE_RAM);
    239         PGM_PAGE_SET_STATE(&pNew->aPages[iPage],  PGM_PAGE_STATE_ZERO);
    240         PGM_PAGE_SET_PAGEID(&pNew->aPages[iPage], NIL_GMM_PAGEID);
    241     }
     229        PGM_PAGE_INIT_ZERO(&pNew->aPages[iPage], pVM, PGMPAGETYPE_RAM);
    242230
    243231    /*
     
    512500                for (uint32_t iPage = 0; iPage < cPages; iPage++, pPage++, pRomPage++)
    513501                {
    514                     pPage->fWrittenTo = 0;
    515                     pPage->fSomethingElse = 0;
    516                     pPage->u29B = 0;
    517                     PGM_PAGE_SET_TYPE(pPage,   PGMPAGETYPE_ROM);
    518                     PGM_PAGE_SET_HCPHYS(pPage, pReq->aPages[iPage].HCPhysGCPhys);
    519                     PGM_PAGE_SET_STATE(pPage,  PGM_PAGE_STATE_ALLOCATED);
    520                     PGM_PAGE_SET_PAGEID(pPage, pReq->aPages[iPage].idPage);
     502                    PGM_PAGE_INIT(pPage,
     503                                  pReq->aPages[iPage].HCPhysGCPhys,
     504                                  pReq->aPages[iPage].idPage,
     505                                  PGMPAGETYPE_ROM,
     506                                  PGM_PAGE_STATE_ALLOCATED);
    521507
    522508                    pRomPage->Virgin = *pPage;
     
    591577                    {
    592578                        PPGMROMPAGE pPage = &pRomNew->aPages[iPage];
    593 
    594                         pPage->Shadow.HCPhys = 0;
    595                         pPage->Shadow.fWrittenTo = 0;
    596                         pPage->Shadow.fSomethingElse = 0;
    597                         pPage->Shadow.u29B = 0;
    598                         PGM_PAGE_SET_TYPE(  &pPage->Shadow, PGMPAGETYPE_ROM_SHADOW);
    599                         PGM_PAGE_SET_STATE( &pPage->Shadow, PGM_PAGE_STATE_ZERO);
    600                         PGM_PAGE_SET_PAGEID(&pPage->Shadow, pReq->aPages[iPage].idPage);
    601 
    602                         pRomNew->aPages[iPage].enmProt = PGMROMPROT_READ_ROM_WRITE_IGNORE;
     579                        pPage->enmProt = PGMROMPROT_READ_ROM_WRITE_IGNORE;
     580                        PGM_PAGE_INIT_ZERO_REAL(&pPage->Shadow, pVM, PGMPAGETYPE_ROM_SHADOW);
    603581                    }
    604582
     
    787765                    for (iPage = 0; iPage < cPages; iPage++)
    788766                        if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO)
    789                         {
    790                             PGM_PAGE_SET_STATE( &pRom->aPages[iPage].Shadow, PGM_PAGE_STATE_ZERO);
    791                             PGM_PAGE_SET_HCPHYS(&pRom->aPages[iPage].Shadow, pVM->pgm.s.HCPhysZeroPg);
    792                             PGM_PAGE_SET_PAGEID(&pRom->aPages[iPage].Shadow, NIL_GMM_PAGEID);
    793                             pRom->aPages[iPage].Shadow.fWrittenTo = false;
    794                             iReqPage++;
    795                         }
     767                            PGM_PAGE_INIT_ZERO_REAL(&pRom->aPages[iPage].Shadow, pVM, PGMPAGETYPE_ROM_SHADOW);
    796768                }
    797769            }
     
    909881                    *pOld = *pRamPage;
    910882                    *pRamPage = *pNew;
    911                     /** @todo sync the volatile flags (handlers) when these have been moved out of HCPhys. */
     883                    /** @todo preserve the volatile flags (handlers) when these have been moved out of HCPhys! */
    912884                }
    913885            }
     
    10501022            while (iPage-- > 0)
    10511023            {
    1052                 pNew->aPages[iPage].HCPhys = (paPages[iPage].Phys & X86_PTE_PAE_PG_MASK) | fFlags; /** @todo PAGE FLAGS */
    1053                 pNew->aPages[iPage].fWrittenTo = 0;
    1054                 pNew->aPages[iPage].fSomethingElse = 0;
    1055                 pNew->aPages[iPage].u29B = 0;
    1056                 PGM_PAGE_SET_PAGEID(&pNew->aPages[iPage],   NIL_GMM_PAGEID);
    1057                 PGM_PAGE_SET_TYPE(&pNew->aPages[iPage],     fFlags & MM_RAM_FLAGS_MMIO2 ? PGMPAGETYPE_MMIO2 : PGMPAGETYPE_RAM);
    1058                 PGM_PAGE_SET_STATE(&pNew->aPages[iPage],    PGM_PAGE_STATE_ALLOCATED);
     1024                PGM_PAGE_INIT(&pNew->aPages[iPage], paPages[iPage].Phys & X86_PTE_PAE_PG_MASK, NIL_GMM_PAGEID,
     1025                              fFlags & MM_RAM_FLAGS_MMIO2 ? PGMPAGETYPE_MMIO2 : PGMPAGETYPE_RAM,
     1026                              PGM_PAGE_STATE_ALLOCATED);
     1027                pNew->aPages[iPage].HCPhys |= fFlags; /** @todo PAGE FLAGS*/
    10591028            }
    10601029        }
     
    10711040            while (iPage-- > 0)
    10721041            {
     1042                PGM_PAGE_INIT(&pNew->aPages[iPage], 0, NIL_GMM_PAGEID, PGMPAGETYPE_RAM, PGM_PAGE_STATE_ZERO);
    10731043                pNew->aPages[iPage].HCPhys = fFlags; /** @todo PAGE FLAGS */
    1074                 pNew->aPages[iPage].fWrittenTo = 0;
    1075                 pNew->aPages[iPage].fSomethingElse = 0;
    1076                 pNew->aPages[iPage].u29B = 0;
    1077                 PGM_PAGE_SET_PAGEID(&pNew->aPages[iPage],   NIL_GMM_PAGEID);
    1078                 PGM_PAGE_SET_TYPE(&pNew->aPages[iPage],     PGMPAGETYPE_RAM);
    1079                 PGM_PAGE_SET_STATE(&pNew->aPages[iPage],    PGM_PAGE_STATE_ZERO);
    10801044            }
    10811045        }
     
    10831047        {
    10841048            Assert(fFlags == (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO));
    1085             RTHCPHYS HCPhysDummyPage = (MMR3PageDummyHCPhys(pVM) & X86_PTE_PAE_PG_MASK) | fFlags; /** @todo PAGE FLAGS */
     1049            RTHCPHYS HCPhysDummyPage = MMR3PageDummyHCPhys(pVM);
    10861050            while (iPage-- > 0)
    10871051            {
    1088                 pNew->aPages[iPage].HCPhys = HCPhysDummyPage; /** @todo PAGE FLAGS */
    1089                 pNew->aPages[iPage].fWrittenTo = 0;
    1090                 pNew->aPages[iPage].fSomethingElse = 0;
    1091                 pNew->aPages[iPage].u29B = 0;
    1092                 PGM_PAGE_SET_PAGEID(&pNew->aPages[iPage],   NIL_GMM_PAGEID);
    1093                 PGM_PAGE_SET_TYPE(&pNew->aPages[iPage],     PGMPAGETYPE_MMIO);
    1094                 PGM_PAGE_SET_STATE(&pNew->aPages[iPage],    PGM_PAGE_STATE_ZERO);
     1052                PGM_PAGE_INIT(&pNew->aPages[iPage], HCPhysDummyPage, NIL_GMM_PAGEID, PGMPAGETYPE_MMIO, PGM_PAGE_STATE_ZERO);
     1053                pNew->aPages[iPage].HCPhys |= fFlags; /** @todo PAGE FLAGS*/
    10951054            }
    10961055        }
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r6856 r6869  
    425425int pgmPhysPageMakeWritable(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys)
    426426{
    427     switch (pPage->u2State)
     427    switch (PGM_PAGE_GET_STATE(pPage))
    428428    {
    429429        case PGM_PAGE_STATE_WRITE_MONITORED:
    430             pPage->fWrittenTo = true;
    431             pPage->u2State = PGM_PAGE_STATE_ALLOCATED;
     430            PGM_PAGE_SET_WRITTEN_TO(pPage);
     431            PGM_PAGE_SET_STATE(pPage, PGM_PAGE_STATE_ALLOCATED);
    432432            /* fall thru */
    433433        default: /* to shut up GCC */
     
    641641         */
    642642        PPGMPAGE pPage = pTlbe->pPage;
    643         if (RT_UNLIKELY(pPage->u2State != PGM_PAGE_STATE_ALLOCATED))
     643        if (RT_UNLIKELY(PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED))
    644644        {
    645645            rc = pgmPhysPageMakeWritable(pVM, pPage, GCPhys);
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