VirtualBox

儲存庫 vbox 的更動 17285


忽略:
時間撮記:
2009-3-3 下午02:34:35 (16 年 以前)
作者:
vboxsync
訊息:

PGM: Gone are MM_RAM_FLAGS_CREFS_SHIFT and MM_RAM_FLAGS_CREFS_MASK.

位置:
trunk
檔案:
修改 5 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/VBox/mm.h

    r17279 r17285  
    8686#define MM_RAM_FLAGS_DYNAMIC_ALLOC      RT_BIT(11)
    8787
    88 /** The shift used to get the reference count. */
    89 #define MM_RAM_FLAGS_CREFS_SHIFT        62
    90 /** The mask applied to the the page pool idx after using MM_RAM_FLAGS_CREFS_SHIFT to shift it down. */
    91 #define MM_RAM_FLAGS_CREFS_MASK         0x3
    9288/** The (shifted) cRef value used to indiciate that the idx is the head of a
    9389 * physical cross reference extent list. */
    94 #define MM_RAM_FLAGS_CREFS_PHYSEXT      MM_RAM_FLAGS_CREFS_MASK
     90#define MM_RAM_FLAGS_CREFS_PHYSEXT      0x3
    9591/** The shift used to get the page pool idx. (Apply MM_RAM_FLAGS_IDX_MASK to the result when shifting down). */
    9692#define MM_RAM_FLAGS_IDX_SHIFT          48
  • trunk/src/VBox/VMM/PGMInternal.h

    r17279 r17285  
    19501950 * simply too many mappings of this page. */
    19511951#define PGMPOOL_TD_IDX_OVERFLOWED       PGMPOOL_TD_IDX_MASK
     1952
     1953/** @def PGMPOOL_TD_MAKE
     1954 * Makes a 16-bit tracking data word.
     1955 *
     1956 * @returns tracking data.
     1957 * @param   cRefs       The @a cRefs field. Must be within bounds!
     1958 * @param   idx         The @a idx field. Must also be within bounds! */
     1959#define PGMPOOL_TD_MAKE(cRefs, idx)     ( ((cRefs) << PGMPOOL_TD_CREFS_SHIFT) | (idx) )
     1960
     1961/** @def PGMPOOL_TD_GET_CREFS
     1962 * Get the @a cRefs field from a tracking data word.
     1963 *
     1964 * @returns The @a cRefs field
     1965 * @param   u16         The tracking data word. */
     1966#define PGMPOOL_TD_GET_CREFS(u16)       ( ((u16) >> PGMPOOL_TD_CREFS_SHIFT) & PGMPOOL_TD_CREFS_MASK )
     1967
     1968/** @def PGMPOOL_TD_GET_IDX
     1969 * Get the @a idx field from a tracking data word.
     1970 *
     1971 * @returns The @a idx field
     1972 * @param   u16         The tracking data word. */
     1973#define PGMPOOL_TD_GET_IDX(u16)         ( ((u16) >> PGMPOOL_TD_IDX_SHIFT)   & PGMPOOL_TD_IDX_MASK   )
    19521974/** @} */
    19531975
    1954 #ifdef MM_RAM_FLAGS_CREFS_SHIFT
    1955 # if MM_RAM_FLAGS_CREFS_SHIFT - MM_RAM_FLAGS_IDX_SHIFT != PGMPOOL_TD_CREFS_SHIFT
    1956 #  error "MM_RAM_FLAGS_CREFS_SHIFT - MM_RAM_FLAGS_IDX_SHIFT != PGMPOOL_TD_CREFS_SHIFT"
    1957 # endif
    1958 # if MM_RAM_FLAGS_CREFS_MASK != MM_RAM_FLAGS_CREFS_MASK
    1959 #  error "MM_RAM_FLAGS_CREFS_MASK != MM_RAM_FLAGS_CREFS_MASK"
    1960 # endif
    1961 # if MM_RAM_FLAGS_CREFS_PHYSEXT != MM_RAM_FLAGS_CREFS_PHYSEXT
    1962 #  error "MM_RAM_FLAGS_CREFS_PHYSEXT != MM_RAM_FLAGS_CREFS_PHYSEXT"
    1963 # endif
     1976#ifdef MM_RAM_FLAGS_IDX_SHIFT
    19641977# if MM_RAM_FLAGS_IDX_SHIFT - 48 != PGMPOOL_TD_IDX_SHIFT
    19651978#  error "MM_RAM_FLAGS_IDX_SHIFT - 48 != PGMPOOL_TD_IDX_SHIFT"
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r17279 r17285  
    14141414# ifdef PGMPOOL_WITH_GCPHYS_TRACKING
    14151415    /*
    1416      * We're making certain assumptions about the placement of cRef and idx.
    1417      */
    1418     Assert(MM_RAM_FLAGS_IDX_SHIFT == 48);
    1419     Assert(MM_RAM_FLAGS_CREFS_SHIFT > MM_RAM_FLAGS_IDX_SHIFT);
    1420 
    1421     /*
    14221416     * Just deal with the simple first time here.
    14231417     */
     
    14251419    {
    14261420        STAM_COUNTER_INC(&pVM->pgm.s.StatTrackVirgin);
    1427         u16 = (1 << PGMPOOL_TD_CREFS_SHIFT) | pShwPage->idx;
     1421        u16 = PGMPOOL_TD_MAKE(1, pShwPage->idx);
    14281422    }
    14291423    else
  • trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp

    r17279 r17285  
    233233
    234234#ifdef PGMPOOL_WITH_GCPHYS_TRACKING
    235             /* This code also makes ASSUMPTIONS about the cRefs and stuff. */
    236             Assert(MM_RAM_FLAGS_IDX_SHIFT < MM_RAM_FLAGS_CREFS_SHIFT);
    237             const uint16_t u16 = pRam->aPages[i].HCPhys >> MM_RAM_FLAGS_IDX_SHIFT; /** @todo PAGE FLAGS */
     235            const uint16_t u16 = PGM_PAGE_GET_TRACKING(&pRam->aPages[i]);
    238236            if (u16)
    239237            {
     
    244242                uint32_t iPrevSubset = PGMDynMapPushAutoSubset(pVCpu);
    245243# endif
    246 
    247                 if ((u16 >> PGMPOOL_TD_CREFS_SHIFT) != MM_RAM_FLAGS_CREFS_PHYSEXT)
     244                if (PGMPOOL_TD_GET_CREFS(u16) != PGMPOOL_TD_CREFS_PHYSEXT)
    248245                    pgmPoolTrackFlushGCPhysPT(pVM,
    249246                                              pPage,
    250                                               u16 & MM_RAM_FLAGS_IDX_MASK,
    251                                               u16 >> PGMPOOL_TD_CREFS_SHIFT);
    252                 else if (u16 != ((MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT) | MM_RAM_FLAGS_IDX_OVERFLOWED))
    253                     pgmPoolTrackFlushGCPhysPTs(pVM, pPage, u16 & MM_RAM_FLAGS_IDX_MASK);
     247                                              PGMPOOL_TD_GET_IDX(u16),
     248                                              PGMPOOL_TD_GET_CREFS(u16));
     249                else if (u16 != PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, PGMPOOL_TD_IDX_OVERFLOWED))
     250                    pgmPoolTrackFlushGCPhysPTs(pVM, pPage, PGMPOOL_TD_GET_IDX(u16));
    254251                else
    255252                    rc = pgmPoolTrackFlushGCPhysPTsSlow(pVM, pPage);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r17279 r17285  
    33413341 * Insert a reference into a list of physical cross reference extents.
    33423342 *
    3343  * @returns The new ram range flags (top 16-bits).
     3343 * @returns The new tracking data for PGMPAGE.
    33443344 *
    33453345 * @param   pVM         The VM handle.
     
    33593359        STAM_COUNTER_INC(&pVM->pgm.s.StatTrackAliasedMany);
    33603360        LogFlow(("pgmPoolTrackPhysExtAddref: %d:{,,%d}\n", iPhysExt, iShwPT));
    3361         return iPhysExt | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3361        return PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, iPhysExt);
    33623362    }
    33633363
     
    33743374                STAM_COUNTER_INC(&pVM->pgm.s.StatTrackAliasedMany);
    33753375                LogFlow(("pgmPoolTrackPhysExtAddref: %d:{%d} i=%d cMax=%d\n", iPhysExt, iShwPT, i, cMax));
    3376                 return iPhysExtStart | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3376                return PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, iPhysExtStart);
    33773377            }
    33783378        if (!--cMax)
     
    33813381            pgmPoolTrackPhysExtFreeList(pVM, iPhysExtStart);
    33823382            LogFlow(("pgmPoolTrackPhysExtAddref: overflow (1) iShwPT=%d\n", iShwPT));
    3383             return MM_RAM_FLAGS_IDX_OVERFLOWED | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3383            return PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, PGMPOOL_TD_IDX_OVERFLOWED);
    33843384        }
    33853385    }
     
    33913391        STAM_COUNTER_INC(&pVM->pgm.s.StatTrackOverflows);
    33923392        pgmPoolTrackPhysExtFreeList(pVM, iPhysExtStart);
    3393         return MM_RAM_FLAGS_IDX_OVERFLOWED | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3393        return PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, PGMPOOL_TD_IDX_OVERFLOWED);
    33943394    }
    33953395    pNew->iNext = iPhysExtStart;
    33963396    pNew->aidx[0] = iShwPT;
    33973397    LogFlow(("pgmPoolTrackPhysExtAddref: added new extent %d:{%d}->%d\n", iPhysExt, iShwPT, iPhysExtStart));
    3398     return iPhysExt | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3398    return PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, iPhysExt);
    33993399}
    34003400
     
    34033403 * Add a reference to guest physical page where extents are in use.
    34043404 *
    3405  * @returns The new ram range flags (top 16-bits).
     3405 * @returns The new tracking data for PGMPAGE.
    34063406 *
    34073407 * @param   pVM         The VM handle.
     
    34113411uint16_t pgmPoolTrackPhysExtAddref(PVM pVM, uint16_t u16, uint16_t iShwPT)
    34123412{
    3413     if ((u16 >> PGMPOOL_TD_CREFS_SHIFT) != MM_RAM_FLAGS_CREFS_PHYSEXT)
     3413    if (PGMPOOL_TD_GET_CREFS(u16) != PGMPOOL_TD_CREFS_PHYSEXT)
    34143414    {
    34153415        /*
    34163416         * Convert to extent list.
    34173417         */
    3418         Assert((u16 >> PGMPOOL_TD_CREFS_SHIFT) == 1);
     3418        Assert(PGMPOOL_TD_GET_CREFS(u16) == 1);
    34193419        uint16_t iPhysExt;
    34203420        PPGMPOOLPHYSEXT pPhysExt = pgmPoolTrackPhysExtAlloc(pVM, &iPhysExt);
    34213421        if (pPhysExt)
    34223422        {
    3423             LogFlow(("pgmPoolTrackPhysExtAddref: new extent: %d:{%d, %d}\n", iPhysExt, u16 & MM_RAM_FLAGS_IDX_MASK, iShwPT));
     3423            LogFlow(("pgmPoolTrackPhysExtAddref: new extent: %d:{%d, %d}\n", iPhysExt, PGMPOOL_TD_GET_IDX(u16), iShwPT));
    34243424            STAM_COUNTER_INC(&pVM->pgm.s.StatTrackAliased);
    3425             pPhysExt->aidx[0] = u16 & MM_RAM_FLAGS_IDX_MASK;
     3425            pPhysExt->aidx[0] = PGMPOOL_TD_GET_IDX(u16);
    34263426            pPhysExt->aidx[1] = iShwPT;
    3427             u16 = iPhysExt | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
     3427            u16 = PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, iPhysExt);
    34283428        }
    34293429        else
    3430             u16 = MM_RAM_FLAGS_IDX_OVERFLOWED | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT);
    3431     }
    3432     else if (u16 != (MM_RAM_FLAGS_IDX_OVERFLOWED | (MM_RAM_FLAGS_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT)))
     3430            u16 = PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, MM_RAM_FLAGS_IDX_OVERFLOWED);
     3431    }
     3432    else if (u16 != PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, MM_RAM_FLAGS_IDX_OVERFLOWED))
    34333433    {
    34343434        /*
    34353435         * Insert into the extent list.
    34363436         */
    3437         u16 = pgmPoolTrackPhysExtInsert(pVM, u16 & MM_RAM_FLAGS_IDX_MASK, iShwPT);
     3437        u16 = pgmPoolTrackPhysExtInsert(pVM, PGMPOOL_TD_GET_IDX(u16), iShwPT);
    34383438    }
    34393439    else
     
    34523452void pgmPoolTrackPhysExtDerefGCPhys(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PPGMPAGE pPhysPage)
    34533453{
    3454     const unsigned cRefs = pPhysPage->HCPhys >> MM_RAM_FLAGS_CREFS_SHIFT; /** @todo PAGE FLAGS */
    3455     AssertFatalMsg(cRefs == MM_RAM_FLAGS_CREFS_PHYSEXT, ("cRefs=%d HCPhys=%RHp pPage=%p:{.idx=%d}\n", cRefs, pPhysPage->HCPhys, pPage, pPage->idx));
    3456 
    3457     uint16_t iPhysExt = (pPhysPage->HCPhys >> MM_RAM_FLAGS_IDX_SHIFT) & MM_RAM_FLAGS_IDX_MASK;
    3458     if (iPhysExt != MM_RAM_FLAGS_IDX_OVERFLOWED)
     3454    const unsigned cRefs = PGM_PAGE_GET_TD_CREFS(pPhysPage);
     3455    AssertFatalMsg(cRefs == PGMPOOL_TD_CREFS_PHYSEXT, ("cRefs=%d HCPhys=%RHp pPage=%p:{.idx=%d}\n", cRefs, pPhysPage->HCPhys, pPage, pPage->idx));
     3456
     3457    uint16_t iPhysExt = PGM_PAGE_GET_TD_IDX(pPhysPage);
     3458    if (iPhysExt != PGMPOOL_TD_IDX_OVERFLOWED)
    34593459    {
    34603460        uint16_t        iPhysExtPrev = NIL_PGMPOOL_PHYSEXT_INDEX;
     
    34953495                        /* head */
    34963496                        Log2(("pgmPoolTrackPhysExtDerefGCPhys: HCPhys=%RX64 idx=%d head\n", pPhysPage->HCPhys, pPage->idx));
    3497                         PGM_PAGE_SET_TRACKING(pPhysPage, (PGMPOOL_TD_CREFS_PHYSEXT << PGMPOOL_TD_CREFS_SHIFT)
    3498                                                        | (iPhysExtNext << PGMPOOL_TD_IDX_SHIFT));
     3497                        PGM_PAGE_SET_TRACKING(pPhysPage, PGMPOOL_TD_MAKE(PGMPOOL_TD_CREFS_PHYSEXT, iPhysExtNext));
    34993498                        pgmPoolTrackPhysExtFree(pVM, iPhysExt);
    35003499                    }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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