VirtualBox

Changeset 104932 in vbox for trunk/include


Ignore:
Timestamp:
Jun 15, 2024 12:29:39 AM (6 months ago)
Author:
vboxsync
Message:

VMM/PGM,IEM: Refactored+copied PGMGstGetPage into PGMGstQueryPage that takes care of table walking, setting A & D bits and validating the access. Use new function in IEM. bugref:10687

Location:
trunk/include/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r104840 r104932  
    110110/** The requested feature is not supported by NEM. */
    111111#define VERR_NOT_SUP_BY_NEM                 (-1026)
     112/** Reserved page table bits set. */
     113#define VERR_RESERVED_PAGE_TABLE_BITS       (-1027)
    112114/** @} */
    113115
  • trunk/include/VBox/vmm/pgm.h

    r104910 r104932  
    316316 */
    317317typedef uint32_t PGMWALKFAIL;
    318 /** Regular page fault (MBZ since guest Walk code don't set these explicitly). */
    319 #define PGM_WALKFAIL_PAGE_FAULT                     UINT32_C(0)
     318/** No fault. */
     319#define PGM_WALKFAIL_SUCCESS                        UINT32_C(0)
     320
     321/** Not present (X86_TRAP_PF_P). */
     322#define PGM_WALKFAIL_NOT_PRESENT                    RT_BIT_32(0)
     323/** Reserved bit set in table entry (X86_TRAP_PF_RSVD). */
     324#define PGM_WALKFAIL_RESERVED_BITS                  RT_BIT_32(1)
     325/** Bad physical address (VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS). */
     326#define PGM_WALKFAIL_BAD_PHYSICAL_ADDRESS           RT_BIT_32(2)
     327
    320328/** EPT violation - Intel. */
    321 #define PGM_WALKFAIL_EPT_VIOLATION                  RT_BIT_32(0)
     329#define PGM_WALKFAIL_EPT_VIOLATION                  RT_BIT_32(3)
    322330/** EPT violation, convertible to \#VE exception - Intel. */
    323 #define PGM_WALKFAIL_EPT_VIOLATION_CONVERTIBLE      RT_BIT_32(1)
     331#define PGM_WALKFAIL_EPT_VIOLATION_CONVERTIBLE      RT_BIT_32(4)
    324332/** EPT misconfiguration - Intel. */
    325 #define PGM_WALKFAIL_EPT_MISCONFIG                  RT_BIT_32(2)
    326 
     333#define PGM_WALKFAIL_EPT_MISCONFIG                  RT_BIT_32(5)
    327334/** Mask of all EPT induced page-walk failures - Intel. */
    328335#define PGM_WALKFAIL_EPT                            (  PGM_WALKFAIL_EPT_VIOLATION \
    329336                                                     | PGM_WALKFAIL_EPT_VIOLATION_CONVERTIBLE \
    330337                                                     | PGM_WALKFAIL_EPT_MISCONFIG)
     338
     339/** Access denied: Not writable (VERR_ACCESS_DENIED). */
     340#define PGM_WALKFAIL_NOT_WRITABLE                   RT_BIT_32(6)
     341/** Access denied: Not executable (VERR_ACCESS_DENIED). */
     342#define PGM_WALKFAIL_NOT_EXECUTABLE                 RT_BIT_32(7)
     343/** Access denied: Not user/supervisor mode accessible (VERR_ACCESS_DENIED). */
     344#define PGM_WALKFAIL_NOT_ACCESSIBLE_BY_MODE         RT_BIT_32(8)
     345
     346/** The level the problem arrised at.
     347 * PTE is level 1, PDE is level 2, PDPE is level 3, PML4 is level 4, CR3 is
     348 * level 8.  This is 0 on success. */
     349#define PGM_WALKFAIL_LEVEL_MASK                     UINT32_C(0x0000f100)
     350/** Level shift (see PGM_WALKINFO_LEVEL_MASK).   */
     351#define PGM_WALKFAIL_LEVEL_SHIFT                    11
     352
    331353/** @} */
    332354
    333355
    334 /** @name PGMPTATTRS - PGM page-table attributes.
     356/** @name PGM_PTATTRS_XXX - PGM page-table attributes.
    335357 *
    336358 * This is VirtualBox's combined page table attributes. It combines regular page
     
    578600
    579601
     602/** @name PGM_WALKINFO_XXX - flag based PGM page table walk info.
     603 * @{ */
     604/** Set if the walk succeeded. */
     605#define PGM_WALKINFO_SUCCEEDED                  RT_BIT_32(0)
     606/** Whether this is a second-level address translation. */
     607#define PGM_WALKINFO_IS_SLAT                    RT_BIT_32(1)
     608/** Set if it involves a big page (2/4 MB). */
     609#define PGM_WALKINFO_BIG_PAGE                   RT_BIT_32(2)
     610/** Set if it involves a gigantic page (1 GB). */
     611#define PGM_WALKINFO_GIGANTIC_PAGE              RT_BIT_32(3)
     612
     613/** Whether the linear address (GCPtr) caused the second-level
     614 * address translation - read the code to figure this one.
     615 * @todo for PGMPTWALKFAST::fFailed?  */
     616#define PGM_WALKINFO_IS_LINEAR_ADDR_VALID       RT_BIT_32(7)
     617/** @} */
     618
     619/**
     620 * Fast page table walk information.
     621 *
     622 * This is a slimmed down version of PGMPTWALK for use by IEM.
     623 */
     624typedef struct PGMPTWALKFAST
     625{
     626    /** The linear address that is being resolved (input). */
     627    RTGCPTR         GCPtr;
     628
     629    /** The physical address that is the result of the walk (output).
     630     * This includes the offset mask from the GCPtr input value.  */
     631    RTGCPHYS        GCPhys;
     632
     633    /** The second-level physical address (input/output).
     634     *  @remarks only valid if fIsSlat is set. */
     635    RTGCPHYS        GCPhysNested;
     636
     637    /** Walk information PGM_WALKINFO_XXX (output). */
     638    uint32_t        fInfo;
     639    /** Page-walk failure type, PGM_WALKFAIL_XXX (output). */
     640    PGMWALKFAIL     fFailed;
     641
     642    /** The effective page-table attributes, PGM_PTATTRS_XXX (output). */
     643    PGMPTATTRS      fEffective;
     644} PGMPTWALKFAST;
     645/** Pointer to fast page walk information. */
     646typedef PGMPTWALKFAST *PPGMPTWALKFAST;
     647/** Pointer to const fast page walk information. */
     648typedef PGMPTWALKFAST const *PCPGMPTWALKFAST;
     649
     650#define PGMPTWALKFAST_ZERO(a_pWalkFast) do { \
     651        (a_pWalkFast)->GCPtr        = 0; \
     652        (a_pWalkFast)->GCPhys       = 0; \
     653        (a_pWalkFast)->GCPhysNested = 0; \
     654        (a_pWalkFast)->fInfo        = 0; \
     655        (a_pWalkFast)->fFailed      = 0; \
     656        (a_pWalkFast)->fEffective   = 0; \
     657    } while (0)
     658
     659
    580660/** Macro for checking if the guest is using paging.
    581661 * @param enmMode   PGMMODE_*.
     
    635715/** @}*/
    636716VMMDECL(int)        PGMGstGetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, PPGMPTWALK pWalk);
     717/** @name PGMQPAGE_F_XXX - Flags for PGMGstQueryPageFast
     718 * @{ */
     719/** Querying for read access, set A bits accordingly. */
     720#define PGMQPAGE_F_READ         RT_BIT_32(0)
     721/** Querying for write access, set A bits and D bit accordingly.
     722 * Don't set leaf entry bits if is read-only.  */
     723#define PGMQPAGE_F_WRITE        RT_BIT_32(1)
     724/** Querying for execute access, set A bits accordingly. */
     725#define PGMQPAGE_F_EXECUTE      RT_BIT_32(2)
     726/** The query is for a user mode access, so don't set leaf A or D bits
     727 * unless the effective access allows usermode access.
     728 * Assume supervisor access when not set. */
     729#define PGMQPAGE_F_USER_MODE    RT_BIT_32(3)
     730/** Treat CR0.WP as zero when evalutating the access.
     731 * @note Same value as X86_CR0_WP.  */
     732#define PGMQPAGE_F_CR0_WP0      RT_BIT_32(16)
     733/** The valid flag mask.   */
     734#define PGMQPAGE_F_VALID_MASK   UINT32_C(0x0001000f)
     735/** @} */
     736VMM_INT_DECL(int)   PGMGstQueryPageFast(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags, PPGMPTWALKFAST pWalkFast);
    637737VMMDECL(int)        PGMGstModifyPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
    638738VMM_INT_DECL(bool)  PGMGstArePaePdpesValid(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
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