VirtualBox

Changeset 36926 in vbox


Ignore:
Timestamp:
May 3, 2011 10:06:14 AM (14 years ago)
Author:
vboxsync
Message:

PGM: PGMPAGE adjustments in progress...

File:
1 edited

Legend:

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

    r36910 r36926  
    693693    /** The physical address and the Page ID. */
    694694    RTHCPHYS    HCPhysAndPageID;
     695#ifndef PGMPAGE_USE_MORE_BITFIELDS
    695696    /** Combination of:
    696697     *  - [0-7]: u2HandlerPhysStateY - the physical handler state
     
    712713     *          32-bit ones, which may be efficient (stalls).
    713714     */
    714     RTUINT16U   u16MiscY;
    715     /** The page state.
    716      * Only 3 bits are really needed for this. */
    717     uint16_t    uStateY   : 3;
    718     /** The page type (PGMPAGETYPE).
    719      * Only 3 bits are really needed for this. */
    720     uint16_t    uTypeY    : 3;
    721     /** PTE index for usage tracking (page pool). */
    722     uint16_t    uPteIdx   : 10;
     715    union
     716    {
     717        struct
     718        {
     719            uint16_t    u16MiscY;
     720            /** The page state.
     721             * Only 3 bits are really needed for this. */
     722            uint16_t    uStateY   : 3;
     723            /** The page type (PGMPAGETYPE).
     724             * Only 3 bits are really needed for this. */
     725            uint16_t    uTypeY    : 3;
     726            /** PTE index for usage tracking (page pool). */
     727            uint16_t    u10PteIdx : 10;
     728        } bit;
     729
     730        /** 32-bit integer view. */
     731        uint32_t    u;
     732        /** 16-bit view. */
     733        uint16_t    au16[2];
     734        /** 8-bit view. */
     735        uint8_t     au8[4];
     736    } u1;
     737#else
     738    union
     739    {
     740        /** Bit field. */
     741        struct
     742        {
     743            /** 7:0   - The physical handler state
     744             *  (PGM_PAGE_HNDL_PHYS_STATE_*). */
     745            uint32_t    u2HandlerPhysStateY : 8;
     746            /** 9:8   - The physical handler state
     747             *  (PGM_PAGE_HNDL_VIRT_STATE_*). */
     748            uint32_t    u2HandlerVirtStateY : 2;
     749            /** 10    - Indicator of dirty page for fault tolerance
     750             *  tracking. */
     751            uint32_t    u1FTDirtyY  : 1;
     752            /** 12:11 - Currently unused. */
     753            uint32_t    u2Unused2   : 2;
     754            /** 14:13 - Paging structure needed to map the page
     755             * (PGM_PAGE_PDE_TYPE_*). */
     756            uint32_t    u2PDETypeY  : 2;
     757            /** 15    - Flag indicating that a write monitored page was written
     758             *  to when set. */
     759            uint32_t    fWrittenToY : 1;
     760            /** 18:16 - The page state. */
     761            uint32_t    uStateY     : 3;
     762            /** 21:19 - The page type (PGMPAGETYPE). */
     763            uint32_t    uTypeY      : 3;
     764            /** 31:22 - PTE index for usage tracking (page pool). */
     765            uint32_t    u10PteIdx   : 10;
     766        } bit;
     767        /** 32-bit integer view. */
     768        uint32_t    u;
     769        /** 16-bit view. */
     770        uint16_t    au16[2];
     771        /** 8-bit view. */
     772        uint8_t     au8[4];
     773    } u1;
     774#endif
    723775    /** Usage tracking (page pool). */
    724776    uint16_t    u16TrackingY;
     
    744796    do { \
    745797        (a_pPage)->HCPhysAndPageID     = 0; \
    746         (a_pPage)->uStateY             = 0; \
    747         (a_pPage)->uTypeY              = 0; \
    748         (a_pPage)->uPteIdx             = 0; \
    749         (a_pPage)->u16MiscY.u          = 0; \
     798        (a_pPage)->u1.u                = 0; \
    750799        (a_pPage)->u16TrackingY        = 0; \
    751800        (a_pPage)->cReadLocksY         = 0; \
     
    761810        RTHCPHYS SetHCPhysTmp = (a_HCPhys); \
    762811        AssertFatal(!(SetHCPhysTmp & ~UINT64_C(0x0000fffffffff000))); \
    763         (a_pPage)->HCPhysAndPageID  = (SetHCPhysTmp << (28-12)) | ((a_idPage) & UINT32_C(0x0fffffff)); \
    764         (a_pPage)->uStateY          = (a_uState); \
    765         (a_pPage)->uTypeY           = (a_uType); \
    766         (a_pPage)->uPteIdx          = 0; \
    767         (a_pPage)->u16MiscY.u       = 0; \
    768         (a_pPage)->u16TrackingY     = 0; \
    769         (a_pPage)->cReadLocksY      = 0; \
    770         (a_pPage)->cWriteLocksY     = 0; \
     812        (a_pPage)->u1.u                 = 0; \
     813        (a_pPage)->u16TrackingY         = 0; \
     814        (a_pPage)->cReadLocksY          = 0; \
     815        (a_pPage)->cWriteLocksY         = 0; \
     816        (a_pPage)->HCPhysAndPageID      = (SetHCPhysTmp << (28-12)) | ((a_idPage) & UINT32_C(0x0fffffff)); \
     817        (a_pPage)->u1.bit.uStateY       = (a_uState); \
     818        (a_pPage)->u1.bit.uTypeY        = (a_uType); \
    771819    } while (0)
    772820
     
    809857 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    810858 */
    811 #define PGM_PAGE_GET_STATE(a_pPage)           ( (a_pPage)->uStateY )
     859#define PGM_PAGE_GET_STATE(a_pPage)             ( (a_pPage)->u1.bit.uStateY )
    812860
    813861/**
     
    816864 * @param   a_uState    The new page state.
    817865 */
    818 #define PGM_PAGE_SET_STATE(a_pPage, a_uState)  do { (a_pPage)->uStateY = (a_uState); } while (0)
     866#define PGM_PAGE_SET_STATE(a_pPage, a_uState)   do { (a_pPage)->u1.bit.uStateY = (a_uState); } while (0)
    819867
    820868
     
    824872 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    825873 */
    826 #define PGM_PAGE_GET_HCPHYS(a_pPage)        ( ((a_pPage)->HCPhysAndPageID >> 28) << 12 )
     874#define PGM_PAGE_GET_HCPHYS(a_pPage)            ( ((a_pPage)->HCPhysAndPageID >> 28) << 12 )
    827875
    828876/**
     
    844892 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    845893 */
    846 #define PGM_PAGE_GET_PAGEID(a_pPage)        (  (uint32_t)((a_pPage)->HCPhysAndPageID & UINT32_C(0x0fffffff)) )
     894#define PGM_PAGE_GET_PAGEID(a_pPage)            (  (uint32_t)((a_pPage)->HCPhysAndPageID & UINT32_C(0x0fffffff)) )
    847895
    848896/**
     
    876924 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    877925 */
    878 #define PGM_PAGE_GET_TYPE(a_pPage)              (a_pPage)->uTypeY
     926#define PGM_PAGE_GET_TYPE(a_pPage)              ( (a_pPage)->u1.bit.uTypeY )
    879927
    880928/**
     
    883931 * @param   a_enmType   The new page type (PGMPAGETYPE).
    884932 */
    885 #define PGM_PAGE_SET_TYPE(a_pPage, a_enmType)   do { (a_pPage)->uTypeY = (a_enmType); } while (0)
     933#define PGM_PAGE_SET_TYPE(a_pPage, a_enmType)   do { (a_pPage)->u1.bit.uTypeY = (a_enmType); } while (0)
    886934
    887935/**
     
    890938 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    891939 */
    892 #define PGM_PAGE_GET_PTE_INDEX(a_pPage)         (a_pPage)->uPteIdx
     940#define PGM_PAGE_GET_PTE_INDEX(a_pPage)         ( (a_pPage)->u1.bit.u10PteIdx )
    893941
    894942/**
     
    897945 * @param   a_iPte      New page table index.
    898946 */
    899 #define PGM_PAGE_SET_PTE_INDEX(a_pPage, a_iPte) do { (a_pPage)->uPteIdx = (a_iPte); } while (0)
     947#define PGM_PAGE_SET_PTE_INDEX(a_pPage, a_iPte) do { (a_pPage)->u1.bit.u10PteIdx = (a_iPte); } while (0)
    900948
    901949/**
     
    904952 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    905953 */
    906 #define PGM_PAGE_IS_MMIO(a_pPage)               ( (a_pPage)->uTypeY == PGMPAGETYPE_MMIO )
     954#define PGM_PAGE_IS_MMIO(a_pPage)               ( (a_pPage)->u1.bit.uTypeY == PGMPAGETYPE_MMIO )
    907955
    908956/**
     
    911959 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    912960 */
    913 #define PGM_PAGE_IS_ZERO(a_pPage)               ( (a_pPage)->uStateY == PGM_PAGE_STATE_ZERO )
     961#define PGM_PAGE_IS_ZERO(a_pPage)               ( (a_pPage)->u1.bit.uStateY == PGM_PAGE_STATE_ZERO )
    914962
    915963/**
     
    918966 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    919967 */
    920 #define PGM_PAGE_IS_SHARED(a_pPage)             ( (a_pPage)->uStateY == PGM_PAGE_STATE_SHARED )
     968#define PGM_PAGE_IS_SHARED(a_pPage)             ( (a_pPage)->u1.bit.uStateY == PGM_PAGE_STATE_SHARED )
    921969
    922970/**
     
    925973 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    926974 */
    927 #define PGM_PAGE_IS_BALLOONED(a_pPage)          ( (a_pPage)->uStateY == PGM_PAGE_STATE_BALLOONED )
     975#define PGM_PAGE_IS_BALLOONED(a_pPage)          ( (a_pPage)->u1.bit.uStateY == PGM_PAGE_STATE_BALLOONED )
    928976
    929977/**
     
    932980 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    933981 */
    934 #define PGM_PAGE_IS_ALLOCATED(a_pPage)          ( (a_pPage)->uStateY == PGM_PAGE_STATE_ALLOCATED )
     982#define PGM_PAGE_IS_ALLOCATED(a_pPage)          ( (a_pPage)->u1.bit.uStateY == PGM_PAGE_STATE_ALLOCATED )
    935983
    936984/**
     
    938986 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    939987 */
    940 #define PGM_PAGE_SET_WRITTEN_TO(a_pPage)        do { (a_pPage)->u16MiscY.au8[1] |= UINT8_C(0x80); } while (0)
     988#define PGM_PAGE_SET_WRITTEN_TO(a_pPage)        do { (a_pPage)->u1.au8[1] |= UINT8_C(0x80); } while (0)
    941989
    942990/**
     
    944992 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    945993 */
    946 #define PGM_PAGE_CLEAR_WRITTEN_TO(a_pPage)      do { (a_pPage)->u16MiscY.au8[1] &= UINT8_C(0x7f); } while (0)
     994#define PGM_PAGE_CLEAR_WRITTEN_TO(a_pPage)      do { (a_pPage)->u1.au8[1] &= UINT8_C(0x7f); } while (0)
    947995
    948996/**
     
    951999 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    9521000 */
    953 #define PGM_PAGE_IS_WRITTEN_TO(a_pPage)         ( !!((a_pPage)->u16MiscY.au8[1] & UINT8_C(0x80)) )
     1001#define PGM_PAGE_IS_WRITTEN_TO(a_pPage)         ( !!((a_pPage)->u1.au8[1] & UINT8_C(0x80)) )
    9541002
    9551003/**
     
    9571005 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    9581006 */
    959 #define PGM_PAGE_SET_FT_DIRTY(a_pPage)          do { (a_pPage)->u16MiscY.au8[1] |= UINT8_C(0x04); } while (0)
     1007#define PGM_PAGE_SET_FT_DIRTY(a_pPage)          do { (a_pPage)->u1.au8[1] |= UINT8_C(0x04); } while (0)
    9601008
    9611009/**
     
    9631011 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    9641012 */
    965 #define PGM_PAGE_CLEAR_FT_DIRTY(a_pPage)        do { (a_pPage)->u16MiscY.au8[1] &= UINT8_C(0xfb); } while (0)
     1013#define PGM_PAGE_CLEAR_FT_DIRTY(a_pPage)        do { (a_pPage)->u1.au8[1] &= UINT8_C(0xfb); } while (0)
    9661014
    9671015/**
     
    9701018 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    9711019 */
    972 #define PGM_PAGE_IS_FT_DIRTY(a_pPage)           ( !!((a_pPage)->u16MiscY.au8[1] & UINT8_C(0x04)) )
     1020#define PGM_PAGE_IS_FT_DIRTY(a_pPage)           ( !!((a_pPage)->u1.au8[1] & UINT8_C(0x04)) )
    9731021
    9741022
     
    9931041#define PGM_PAGE_SET_PDE_TYPE(a_pPage, a_uType) \
    9941042    do { \
    995         (a_pPage)->u16MiscY.au8[1] = ((a_pPage)->u16MiscY.au8[1] & UINT8_C(0x9f)) \
    996                                    | (((a_uType)                 & UINT8_C(0x03)) << 5); \
     1043        (a_pPage)->u1.au8[1] = ((a_pPage)->u1.au8[1] & UINT8_C(0x9f)) \
     1044                             | (((a_uType)           & UINT8_C(0x03)) << 5); \
    9971045    } while (0)
    9981046
     
    10021050 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    10031051 */
    1004 #define PGM_PAGE_GET_PDE_TYPE(a_pPage)          ( ((a_pPage)->u16MiscY.au8[1] & UINT8_C(0x60)) >> 5)
     1052#define PGM_PAGE_GET_PDE_TYPE(a_pPage)          ( ((a_pPage)->u1.au8[1] & UINT8_C(0x60)) >> 5)
    10051053
    10061054/** Enabled optimized access handler tests.
    1007  * These optimizations makes ASSUMPTIONS about the state values and the u16MiscY
     1055 * These optimizations makes ASSUMPTIONS about the state values and the s1
    10081056 * layout.  When enabled, the compiler should normally generate more compact
    10091057 * code.
     
    10311079 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    10321080 */
    1033 #define PGM_PAGE_GET_HNDL_PHYS_STATE(a_pPage)   ( (a_pPage)->u16MiscY.au8[0] )
     1081#define PGM_PAGE_GET_HNDL_PHYS_STATE(a_pPage)   ( (a_pPage)->u1.au8[0] )
    10341082
    10351083/**
     
    10391087 */
    10401088#define PGM_PAGE_SET_HNDL_PHYS_STATE(a_pPage, a_uState) \
    1041     do { (a_pPage)->u16MiscY.au8[0] = (a_uState); } while (0)
     1089    do { (a_pPage)->u1.au8[0] = (a_uState); } while (0)
    10421090
    10431091/**
     
    10771125 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    10781126 */
    1079 #define PGM_PAGE_GET_HNDL_VIRT_STATE(a_pPage)   ((uint8_t)( (a_pPage)->u16MiscY.au8[1] & UINT8_C(0x03) ))
     1127#define PGM_PAGE_GET_HNDL_VIRT_STATE(a_pPage)   ((uint8_t)( (a_pPage)->u1.au8[1] & UINT8_C(0x03) ))
    10801128
    10811129/**
     
    10861134#define PGM_PAGE_SET_HNDL_VIRT_STATE(a_pPage, a_uState) \
    10871135    do { \
    1088         (a_pPage)->u16MiscY.au8[1] = ((a_pPage)->u16MiscY.au8[1] & UINT8_C(0xfc)) \
    1089                                    | ((a_uState)                 & UINT8_C(0x03)); \
     1136        (a_pPage)->u1.au8[1] = ((a_pPage)->u1.au8[1] & UINT8_C(0xfc)) \
     1137                             | ((a_uState)           & UINT8_C(0x03)); \
    10901138    } while (0)
    10911139
     
    11151163#ifdef PGM_PAGE_WITH_OPTIMIZED_HANDLER_ACCESS
    11161164# define PGM_PAGE_HAS_ANY_HANDLERS(a_pPage) \
    1117     ( ((a_pPage)->u16MiscY.u & UINT16_C(0x0303)) != 0 )
     1165    ( ((a_pPage)->u1.u & UINT16_C(0x0303)) != 0 )
    11181166#else
    11191167# define PGM_PAGE_HAS_ANY_HANDLERS(a_pPage) \
     
    11291177#ifdef PGM_PAGE_WITH_OPTIMIZED_HANDLER_ACCESS
    11301178# define PGM_PAGE_HAS_ACTIVE_HANDLERS(a_pPage) \
    1131     ( ((a_pPage)->u16MiscY.u & UINT16_C(0x0202)) != 0 )
     1179    ( ((a_pPage)->u1.u & UINT16_C(0x0202)) != 0 )
    11321180#else
    11331181# define PGM_PAGE_HAS_ACTIVE_HANDLERS(a_pPage) \
     
    11431191#ifdef PGM_PAGE_WITH_OPTIMIZED_HANDLER_ACCESS
    11441192# define PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(a_pPage) \
    1145     (   ( ((a_pPage)->u16MiscY.au8[0] | (a_pPage)->u16MiscY.au8[1]) & UINT8_C(0x3) ) \
     1193    (   ( ((a_pPage)->u1.au8[0] | (a_pPage)->u1.au8[1]) & UINT8_C(0x3) ) \
    11461194     == PGM_PAGE_HNDL_PHYS_STATE_ALL )
    11471195#else
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