VirtualBox

Changeset 92331 in vbox for trunk/src


Ignore:
Timestamp:
Nov 10, 2021 4:55:00 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148181
Message:

VMM: Nested VMX: bugref:10092 Have R and W as separate bits in PGMPTATTRS now that bit 0 is freed up (still retains 1:1 with regular page-table format).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r92319 r92331  
    149149# endif
    150150
    151     uint64_t fEffective = X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A | 1;  /** @todo can this default assignment be removed? */
     151    uint64_t fEffective;
    152152    {
    153153# if PGM_GST_TYPE == PGM_TYPE_AMD64
     
    170170        else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 4);
    171171
    172         pWalk->Core.fEffective = fEffective = Pml4e.u & (  X86_PML4E_RW | X86_PML4E_US | X86_PML4E_PWT
     172        pWalk->Core.fEffective = fEffective = Pml4e.u & (  X86_PML4E_P   | X86_PML4E_RW | X86_PML4E_US | X86_PML4E_PWT
    173173                                                         | X86_PML4E_PCD | X86_PML4E_A  | X86_PML4E_NX);
    174174
     
    204204
    205205# if PGM_GST_TYPE == PGM_TYPE_AMD64
    206         pWalk->Core.fEffective = fEffective &= (Pdpe.u & (X86_PDPE_RW | X86_PDPE_US | X86_PDPE_PWT | X86_PDPE_PCD | X86_PDPE_A))
     206        pWalk->Core.fEffective = fEffective &= (Pdpe.u & (  X86_PDPE_P   | X86_PDPE_RW  | X86_PDPE_US
     207                                                          | X86_PDPE_PWT | X86_PDPE_PCD | X86_PDPE_A))
    207208                                             | (Pdpe.u & X86_PDPE_LM_NX);
    208209# else
    209210        /* NX in the legacy-mode PAE PDPE is reserved. The valid check above ensures the NX bit is not set. */
    210         pWalk->Core.fEffective = fEffective  = X86_PDPE_RW  | X86_PDPE_US | X86_PDPE_A
     211        pWalk->Core.fEffective = fEffective  = X86_PDPE_P | X86_PDPE_RW  | X86_PDPE_US | X86_PDPE_A
    211212                                             | (Pdpe.u & (X86_PDPE_PWT | X86_PDPE_PCD));
    212213# endif
     
    245246             */
    246247# if PGM_GST_TYPE == PGM_TYPE_32BIT
    247             fEffective &=  Pde.u & (X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A);
     248            fEffective  =  Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A);
    248249# else
    249             fEffective &= (Pde.u & (X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A))
     250            fEffective &= (Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A))
    250251                        | (Pde.u & X86_PDE2M_PAE_NX);
    251252# endif
     
    254255            pWalk->Core.fEffective = fEffective;
    255256            Assert(GST_IS_NX_ACTIVE(pVCpu) || !(fEffective & PGM_PTATTRS_NX_MASK));
     257            Assert(fEffective & PGM_PTATTRS_R_MASK);
    256258
    257259            pWalk->Core.fEffectiveRW = !!(fEffective & X86_PTE_RW);
     
    273275            return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 2);
    274276# if PGM_GST_TYPE == PGM_TYPE_32BIT
    275         pWalk->Core.fEffective = fEffective &= Pde.u & (X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A);
     277        pWalk->Core.fEffective = fEffective  = Pde.u & (  X86_PDE_P   | X86_PDE_RW  | X86_PDE_US
     278                                                        | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A);
    276279# else
    277         pWalk->Core.fEffective = fEffective &= (Pde.u & (X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A))
     280        pWalk->Core.fEffective = fEffective &= (Pde.u & (  X86_PDE_P   | X86_PDE_RW  | X86_PDE_US
     281                                                         | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A))
    278282                                             | (Pde.u & X86_PDE_PAE_NX);
    279283# endif
     
    306310         */
    307311# if PGM_GST_TYPE == PGM_TYPE_32BIT
    308         fEffective &= Pte.u & (X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A);
     312        fEffective &=  Pte.u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A);
    309313# else
    310         fEffective &= (Pte.u & (X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A))
     314        fEffective &= (Pte.u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A))
    311315                   |  (Pte.u & X86_PTE_PAE_NX);
    312316# endif
     
    314318        pWalk->Core.fEffective = fEffective;
    315319        Assert(GST_IS_NX_ACTIVE(pVCpu) || !(fEffective & PGM_PTATTRS_NX_MASK));
     320        Assert(fEffective & PGM_PTATTRS_R_MASK);
    316321
    317322        pWalk->Core.fEffectiveRW = !!(fEffective & X86_PTE_RW);
     
    376381        if (!Walk.Core.fBigPage)
    377382            *pfFlags = (Walk.Pte.u & ~(GST_PTE_PG_MASK | X86_PTE_RW | X86_PTE_US))                      /* NX not needed */
    378                      | (Walk.Core.fEffective & (  PGM_PTATTRS_RW_MASK
     383                     | (Walk.Core.fEffective & (  PGM_PTATTRS_W_MASK
    379384                                                | PGM_PTATTRS_US_MASK))
    380385# if PGM_WITH_NX(PGM_GST_TYPE, PGM_GST_TYPE)
     
    385390        {
    386391            *pfFlags = (Walk.Pde.u & ~(GST_PTE_PG_MASK | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PS))   /* NX not needed */
    387                      | (Walk.Core.fEffective & (  PGM_PTATTRS_RW_MASK
     392                     | (Walk.Core.fEffective & (  PGM_PTATTRS_W_MASK
    388393                                                | PGM_PTATTRS_US_MASK
    389394                                                | PGM_PTATTRS_PAT_MASK))
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r92313 r92331  
    23412341 * The following bits map 1:1 (shifted by PGM_PTATTRS_EPT_SHIFT) to the Intel EPT
    23422342 * attributes as these are unique to EPT and fit within 64-bits despite the shift:
    2343  *   - R           (Read access).
    2344  *   - W           (Write access).
    2345  *   - X_SUPER    (Execute or execute access for supervisor-mode linear addresses).
     2343 *   - EPT_R       (Read access).
     2344 *   - EPT_W       (Write access).
     2345 *   - EPT_X_SUPER (Execute or execute access for supervisor-mode linear addresses).
    23462346 *   - EPT_MEMTYPE (EPT memory type).
    23472347 *   - IGNORE_PAT  (Ignore PAT memory type).
    23482348 *   - X_USER      (Execute access for user-mode linear addresses).
     2349 *
     2350 * For regular page tables, the R bit is always 1 (same as P bit).
     2351 * For Intel EPT, the EPT_R and EPT_W bits are copied to R and W bits respectively.
    23492352 *
    23502353 * The following EPT attributes are mapped to the following positions because they
     
    23662369typedef PGMPTATTRS *PPGMPTATTRS;
    23672370
    2368 /** Reserved bit. */
    2369 #define PGM_PTATTRS_RSVD_0_SHIFT                    0
    2370 #define PGM_PTATTRS_RSVD_0_MASK                     RT_BIT_64(PGM_PTATTRS_RSVD_0_SHIFT)
    2371 /** Read and write access bit. */
    2372 #define PGM_PTATTRS_RW_SHIFT                        1
    2373 #define PGM_PTATTRS_RW_MASK                         RT_BIT_64(PGM_PTATTRS_RW_SHIFT)
     2371/** Read bit (always 1 for regular PT, copy of EPT_R for EPT). */
     2372#define PGM_PTATTRS_R_SHIFT                         0
     2373#define PGM_PTATTRS_R_MASK                          RT_BIT_64(PGM_PTATTRS_R_SHIFT)
     2374/** Write access bit (aka read/write bit for regular PT). */
     2375#define PGM_PTATTRS_W_SHIFT                         1
     2376#define PGM_PTATTRS_W_MASK                          RT_BIT_64(PGM_PTATTRS_W_SHIFT)
    23742377/** User-mode access bit. */
    23752378#define PGM_PTATTRS_US_SHIFT                        2
     
    24342437
    24352438RT_BF_ASSERT_COMPILE_CHECKS(PGM_PTATTRS_, UINT64_C(0), UINT64_MAX,
    2436                             (RSVD_0, RW, US, PWT, PCD, A, D, PAT, G, RSVD_12_9, EPT_R, EPT_W, EPT_X_SUPER, EPT_MEMTYPE,
    2437                              EPT_IGNORE_PAT, RSVD_22_20, EPT_X_USER, RSVD_23, EPT_SUPER_SHW_STACK, EPT_SUPPRESS_VE_XCPT,
    2438                              RSVD_62_27, NX));
     2439                            (R, W, US, PWT, PCD, A, D, PAT, G, RSVD_12_9, EPT_R, EPT_W, EPT_X_SUPER, EPT_MEMTYPE, EPT_IGNORE_PAT,
     2440                             RSVD_22_20, EPT_X_USER, RSVD_23, EPT_SUPER_SHW_STACK, EPT_SUPPRESS_VE_XCPT, RSVD_62_27, NX));
    24392441
    24402442/** The bit position where the EPT specific attributes begin. */
     
    24452447
    24462448/** The mask of all PGM page attribute bits for regular page-tables. */
    2447 #define PGM_PTATTRS_PT_VALID_MASK                   (  PGM_PTATTRS_RW_MASK \
     2449#define PGM_PTATTRS_PT_VALID_MASK                   (  PGM_PTATTRS_R_MASK \
     2450                                                     | PGM_PTATTRS_W_MASK \
    24482451                                                     | PGM_PTATTRS_US_MASK \
    24492452                                                     | PGM_PTATTRS_PWT_MASK \
     
    24562459
    24572460/** The mask of all PGM page attribute bits for EPT. */
    2458 #define PGM_PTATTRS_EPT_VALID_MASK                  (  PGM_PTATTRS_A_MASK \
     2461#define PGM_PTATTRS_EPT_VALID_MASK                  (  PGM_PTATTRS_R_MASK \
     2462                                                     | PGM_PTATTRS_W_MASK \
     2463                                                     | PGM_PTATTRS_A_MASK \
    24592464                                                     | PGM_PTATTRS_D_MASK \
    2460                                                      | PGM_PTATTRS_R_MASK \
    2461                                                      | PGM_PTATTRS_W_MASK \
     2465                                                     | PGM_PTATTRS_EPT_R_MASK \
     2466                                                     | PGM_PTATTRS_EPT_W_MASK \
    24622467                                                     | PGM_PTATTRS_EPT_X_SUPER \
    24632468                                                     | PGM_PTATTRS_EPT_MEMTYPE \
     
    24712476
    24722477/* Verify bits match the regular PT bits. */
    2473 AssertCompile(PGM_PTATTRS_RW_SHIFT  == X86_PTE_BIT_RW);
     2478AssertCompile(PGM_PTATTRS_W_SHIFT   == X86_PTE_BIT_RW);
    24742479AssertCompile(PGM_PTATTRS_US_SHIFT  == X86_PTE_BIT_US);
    24752480AssertCompile(PGM_PTATTRS_PWT_SHIFT == X86_PTE_BIT_PWT);
     
    24792484AssertCompile(PGM_PTATTRS_PAT_SHIFT == X86_PTE_BIT_PAT);
    24802485AssertCompile(PGM_PTATTRS_G_SHIFT   == X86_PTE_BIT_G);
    2481 AssertCompile(PGM_PTATTRS_RW_MASK   == X86_PTE_RW);
     2486AssertCompile(PGM_PTATTRS_W_MASK    == X86_PTE_RW);
    24822487AssertCompile(PGM_PTATTRS_US_MASK   == X86_PTE_US);
    24832488AssertCompile(PGM_PTATTRS_PWT_MASK  == X86_PTE_PWT);
Note: See TracChangeset for help on using the changeset viewer.

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