VirtualBox

Changeset 93160 in vbox for trunk


Ignore:
Timestamp:
Jan 10, 2022 7:59:44 AM (3 years ago)
Author:
vboxsync
Message:

VMM: Nested VMX: bugref:10092 Fix invalid cumulation of NX bit into the effective page attributes while walking pages.

File:
1 edited

Legend:

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

    r93115 r93160  
    184184        else return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 4);
    185185
    186         pWalk->fEffective = fEffective = Pml4e.u & (  X86_PML4E_P   | X86_PML4E_RW | X86_PML4E_US | X86_PML4E_PWT
    187                                                     | X86_PML4E_PCD | X86_PML4E_A  | X86_PML4E_NX);
     186        fEffective = Pml4e.u & (  X86_PML4E_P | X86_PML4E_RW | X86_PML4E_US | X86_PML4E_PWT | X86_PML4E_PCD | X86_PML4E_A
     187                                | X86_PML4E_NX);
     188        pWalk->fEffective = fEffective;
    188189
    189190        /*
     
    218219
    219220# if PGM_GST_TYPE == PGM_TYPE_AMD64
    220         pWalk->fEffective = fEffective &= (Pdpe.u & (  X86_PDPE_P   | X86_PDPE_RW  | X86_PDPE_US
    221                                                      | X86_PDPE_PWT | X86_PDPE_PCD | X86_PDPE_A))
    222                                         | (Pdpe.u & X86_PDPE_LM_NX);
     221        fEffective &= (Pdpe.u & (  X86_PDPE_P   | X86_PDPE_RW  | X86_PDPE_US
     222                                 | X86_PDPE_PWT | X86_PDPE_PCD | X86_PDPE_A));
     223        fEffective |= Pdpe.u & X86_PDPE_LM_NX;
    223224# else
    224         /* NX in the legacy-mode PAE PDPE is reserved. The valid check above ensures the NX bit is not set. */
    225         pWalk->fEffective = fEffective  = X86_PDPE_P | X86_PDPE_RW  | X86_PDPE_US | X86_PDPE_A
    226                                         | (Pdpe.u & (X86_PDPE_PWT | X86_PDPE_PCD));
    227 # endif
     225        /*
     226         * NX in the legacy-mode PAE PDPE is reserved. The valid check above ensures the NX bit is not set.
     227         * The RW, US, A bits MBZ in PAE PDPTE entries but must be 1 the way we compute cumulative (effective) access rights.
     228         */
     229        Assert(!(Pdpe.u & X86_PDPE_LM_NX));
     230        fEffective = X86_PDPE_P | X86_PDPE_RW  | X86_PDPE_US | X86_PDPE_A
     231                   | (Pdpe.u & (X86_PDPE_PWT | X86_PDPE_PCD));
     232# endif
     233        pWalk->fEffective = fEffective;
    228234
    229235        /*
     
    260266             */
    261267# if PGM_GST_TYPE == PGM_TYPE_32BIT
    262             fEffective  =  Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A);
     268            fEffective  = Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A);
    263269# else
    264             fEffective &= (Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A))
    265                         | (Pde.u & X86_PDE2M_PAE_NX);
     270            fEffective &= Pde.u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_PWT | X86_PDE4M_PCD | X86_PDE4M_A);
     271            fEffective |= Pde.u & X86_PDE2M_PAE_NX;
    266272# endif
    267273            fEffective |= Pde.u & (X86_PDE4M_D | X86_PDE4M_G);
     
    286292            return PGM_GST_NAME(WalkReturnRsvdError)(pVCpu, pWalk, 2);
    287293# if PGM_GST_TYPE == PGM_TYPE_32BIT
    288         pWalk->fEffective = fEffective  = Pde.u & (  X86_PDE_P   | X86_PDE_RW  | X86_PDE_US
    289                                                    | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A);
     294        fEffective  = Pde.u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A);
    290295# else
    291         pWalk->fEffective = fEffective &= (Pde.u & (  X86_PDE_P   | X86_PDE_RW  | X86_PDE_US
    292                                                     | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A))
    293                                         | (Pde.u & X86_PDE_PAE_NX);
    294 # endif
     296        fEffective &= Pde.u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_PWT | X86_PDE_PCD | X86_PDE_A);
     297        fEffective |= Pde.u & X86_PDE_PAE_NX;
     298# endif
     299        pWalk->fEffective = fEffective;
    295300
    296301        /*
     
    320325         * We're done.
    321326         */
    322 # if PGM_GST_TYPE == PGM_TYPE_32BIT
    323         fEffective &=  Pte.u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A);
    324 # else
    325         fEffective &= (Pte.u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A))
    326                    |  (Pte.u & X86_PTE_PAE_NX);
    327 # endif
     327        fEffective &= Pte.u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A);
    328328        fEffective |= Pte.u & (X86_PTE_D | X86_PTE_PAT | X86_PTE_G);
     329# if PGM_GST_TYPE != PGM_TYPE_32BIT
     330        fEffective |= Pte.u & X86_PTE_PAE_NX;
     331# endif
    329332        pWalk->fEffective = fEffective;
    330333        Assert(GST_IS_NX_ACTIVE(pVCpu) || !(fEffective & PGM_PTATTRS_NX_MASK));
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