VirtualBox

Changeset 7730 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 3, 2008 4:30:35 PM (17 years ago)
Author:
vboxsync
Message:

Added CPUMSet/GetGuestEFER.
Corrected NX bit handling.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r7650 r7730  
    639639}
    640640
     641CPUMDECL(void) CPUMSetGuestEFER(PVM pVM, uint64_t val)
     642{
     643    pVM->cpum.s.Guest.msrEFER = val;
     644}
    641645
    642646CPUMDECL(uint32_t) CPUMGetGuestIDTR(PVM pVM, uint16_t *pcbLimit)
     
    686690    return pVM->cpum.s.Guest.ldtr;
    687691}
    688 
    689692
    690693CPUMDECL(uint32_t) CPUMGetGuestCR0(PVM pVM)
     
    851854    }
    852855    return VINF_SUCCESS;
     856}
     857
     858CPUMDECL(uint64_t) CPUMGetGuestEFER(PVM pVM)
     859{
     860    return pVM->cpum.s.Guest.msrEFER;
    853861}
    854862
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r7728 r7730  
    16221622PGM_BTH_DECL(int, CheckPageFault)(PVM pVM, uint32_t uErr, PSHWPDE pPdeDst, PGSTPDE pPdeSrc, RTGCUINTPTR GCPtrPage)
    16231623{
    1624     bool fWriteProtect   = !!(CPUMGetGuestCR0(pVM) & X86_CR0_WP);
    1625     bool fUserLevelFault = !!(uErr & X86_TRAP_PF_US);
    1626     bool fWriteFault     = !!(uErr & X86_TRAP_PF_RW);
     1624    bool fWriteProtect      = !!(CPUMGetGuestCR0(pVM) & X86_CR0_WP);
     1625    bool fUserLevelFault    = !!(uErr & X86_TRAP_PF_US);
     1626    bool fWriteFault        = !!(uErr & X86_TRAP_PF_RW);
     1627# if PGM_WITH_NX(PGM_GST_TYPE)
     1628    bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVM) & MSR_K6_EFER_NXE);
     1629# endif
    16271630
    16281631    STAM_PROFILE_START(&pVM->pgm.s.CTXMID(Stat, DirtyBitTracking), a);
     
    16391642    if (    (uErr & X86_TRAP_PF_RSVD)
    16401643        ||  !pPdpeSrc->n.u1Present
    1641         ||  ((uErr & X86_TRAP_PF_ID) &&  pPdpeSrc->n.u1NoExecute)
     1644# if PGM_WITH_NX(PGM_GST_TYPE)
     1645        ||  (fNoExecuteBitValid && (uErr & X86_TRAP_PF_ID) &&  pPdpeSrc->n.u1NoExecute)
     1646# endif
    16421647        ||  (fWriteFault && !pPdpeSrc->n.u1Write && (fUserLevelFault || fWriteProtect))
    16431648        ||  (fUserLevelFault && !pPdpeSrc->n.u1User) )
     
    16851690    if (    (uErr & X86_TRAP_PF_RSVD)
    16861691        ||  !pPdeSrc->n.u1Present
    1687 #  if PGM_WITH_NX(PGM_GST_TYPE)
    1688         ||  ((uErr & X86_TRAP_PF_ID) &&  pPdeSrc->n.u1NoExecute)
    1689 #  endif
     1692# if PGM_WITH_NX(PGM_GST_TYPE)
     1693        ||  (fNoExecuteBitValid && (uErr & X86_TRAP_PF_ID) &&  pPdeSrc->n.u1NoExecute)
     1694# endif
    16901695        ||  (fWriteFault && !pPdeSrc->n.u1Write && (fUserLevelFault || fWriteProtect))
    16911696        ||  (fUserLevelFault && !pPdeSrc->n.u1User) )
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r7728 r7730  
    150150    return VINF_SUCCESS;
    151151
    152 #elif PGM_GST_TYPE == PGM_TYPE_32BIT \
    153    || PGM_GST_TYPE == PGM_TYPE_PAE \
    154    || PGM_GST_TYPE == PGM_TYPE_AMD64
    155        
    156 #if PGM_GST_TYPE == PGM_TYPE_AMD64
     152#elif PGM_GST_TYPE == PGM_TYPE_AMD64
    157153    /* later */
     154    /* check level 3 & 4 bits as well (r/w, u/s, nxe) */
    158155    AssertFailed();
    159156    return VERR_NOT_IMPLEMENTED;
    160 #endif
    161 
     157
     158#elif PGM_GST_TYPE == PGM_GST_32BIT || PGM_GST_TYPE == PGM_GST_PAE
    162159
    163160    /*
    164161     * Get the PDE.
    165162     */
    166 #if PGM_GST_TYPE == PGM_TYPE_32BIT
     163# if PGM_GST_TYPE == PGM_TYPE_32BIT
    167164    const X86PDE Pde = CTXSUFF(pVM->pgm.s.pGuestPD)->a[GCPtr >> X86_PD_SHIFT];
    168 #else /* PAE */
    169     X86PDEPAE   Pde;
     165# else /* PAE */
     166    X86PDEPAE    Pde;
     167    bool         fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVM) & MSR_K6_EFER_NXE);
     168
     169    /* pgmGstGetPaePDE will return 0 if the PDPTE is marked as not present
     170     * All the other bits in the PDPTE are only valid in long mode (r/w, u/s, nx)
     171     */
    170172    Pde.u = pgmGstGetPaePDE(&pVM->pgm.s, GCPtr);
    171 #endif
     173# endif
    172174
    173175    /*
     
    203205# if PGM_WITH_NX(PGM_GST_TYPE)
    204206            /* The NX bit is determined by a bitwise OR between the PT and PD */
    205             if (Pde.u & X86_PTE_PAE_NX)
    206                 *pfFlags |= X86_PTE_PAE_NX;
     207            if (fNoExecuteBitValid)
     208                *pFlags |= (Pte.u & Pde.u & X86_PTE_PAE_NX);
    207209# endif
    208210        }
     
    216218         */
    217219        if (pfFlags)
     220        {
    218221            *pfFlags = (Pde.u & ~(GST_PTE_PG_MASK | X86_PTE_PAT))
    219222                     | ((Pde.u & X86_PDE4M_PAT) >> X86_PDE4M_PAT_SHIFT);
     223# if PGM_WITH_NX(PGM_GST_TYPE)
     224            /* The NX bit is determined by a bitwise OR between the PT and PD */
     225            if (fNoExecuteBitValid)
     226                *pfFlags |= (Pde.u & X86_PTE_PAE_NX);
     227# endif
     228        }
    220229        if (pGCPhys)
    221230            *pGCPhys = (Pde.u & GST_PDE_BIG_PG_MASK) | (GCPtr & (~GST_PDE_BIG_PG_MASK ^ ~GST_PTE_PG_MASK)); /** @todo pse36 */
     
    249258#if PGM_GST_TYPE == PGM_TYPE_AMD64
    250259    /* later */
     260    /* check level 3 & 4 bits as well (r/w, u/s, nxe) */
    251261    AssertFailed();
    252262    return VERR_NOT_IMPLEMENTED;
     
    261271        PX86PDE pPde = &CTXSUFF(pVM->pgm.s.pGuestPD)->a[GCPtr >> X86_PD_SHIFT];
    262272#else /* PAE */
     273        /* pgmGstGetPaePDEPtr will return 0 if the PDPTE is marked as not present
     274         * All the other bits in the PDPTE are only valid in long mode (r/w, u/s, nx)
     275         */
    263276        PX86PDEPAE pPde = pgmGstGetPaePDEPtr(&pVM->pgm.s, GCPtr);
    264277        Assert(pPde);
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