VirtualBox

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


Ignore:
Timestamp:
Jan 14, 2010 4:27:58 PM (15 years ago)
Author:
vboxsync
Message:

CPUM,VMM: Avoid calling CPUMGetGuestEFER until it's needed (see defect 4597). Also pushed the inlined CPUM predicates that was calling into CPUMGetSomething anyway into CPUMAllRegs.cpp since that's faster and smaller.

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

Legend:

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

    r25815 r25835  
    16981698}
    16991699
     1700
     1701/**
     1702 * Tests if the guest has No-Execute Page Protection Enabled (NXE).
     1703 *
     1704 * @returns true if in real mode, otherwise false.
     1705 * @param   pVCpu       The virtual CPU handle.
     1706 */
     1707VMMDECL(bool) CPUMIsGuestNXEnabled(PVMCPU pVCpu)
     1708{
     1709    return !!(pVCpu->cpum.s.Guest.msrEFER & MSR_K6_EFER_NXE);
     1710}
     1711
     1712
     1713/**
     1714 * Tests if the guest is running in real mode or not.
     1715 *
     1716 * @returns true if in real mode, otherwise false.
     1717 * @param   pVCpu       The virtual CPU handle.
     1718 */
     1719VMMDECL(bool) CPUMIsGuestInRealMode(PVMCPU pVCpu)
     1720{
     1721    return !(pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE);
     1722}
     1723
     1724
     1725/**
     1726 * Tests if the guest is running in protected or not.
     1727 *
     1728 * @returns true if in protected mode, otherwise false.
     1729 * @param   pVCpu       The virtual CPU handle.
     1730 */
     1731VMMDECL(bool) CPUMIsGuestInProtectedMode(PVMCPU pVCpu)
     1732{
     1733    return !!(pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE);
     1734}
     1735
     1736
     1737/**
     1738 * Tests if the guest is running in paged protected or not.
     1739 *
     1740 * @returns true if in paged protected mode, otherwise false.
     1741 * @param   pVCpu       The virtual CPU handle.
     1742 */
     1743VMMDECL(bool) CPUMIsGuestInPagedProtectedMode(PVMCPU pVCpu)
     1744{
     1745    return (pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
     1746}
     1747
     1748
     1749/**
     1750 * Tests if the guest is running in long mode or not.
     1751 *
     1752 * @returns true if in long mode, otherwise false.
     1753 * @param   pVCpu       The virtual CPU handle.
     1754 */
     1755VMMDECL(bool) CPUMIsGuestInLongMode(PVMCPU pVCpu)
     1756{
     1757    return (pVCpu->cpum.s.Guest.msrEFER & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA;
     1758}
     1759
     1760
     1761/**
     1762 * Tests if the guest is running in PAE mode or not.
     1763 *
     1764 * @returns true if in PAE mode, otherwise false.
     1765 * @param   pVCpu       The virtual CPU handle.
     1766 */
     1767VMMDECL(bool) CPUMIsGuestInPAEMode(PVMCPU pVCpu)
     1768{
     1769    return (pVCpu->cpum.s.Guest.cr4 & X86_CR4_PAE)
     1770        && (pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG)
     1771        && !(pVCpu->cpum.s.Guest.msrEFER & MSR_K6_EFER_LMA);
     1772}
     1773
     1774
     1775
    17001776#ifndef IN_RING0  /** @todo I don't think we need this in R0, so move it to CPUMAll.cpp? */
    17011777
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r25579 r25835  
    16681668
    16691669# if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE)
    1670     bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
     1670    bool fNoExecuteBitValid = CPUMIsGuestNXEnabled(pVCpu);
    16711671# endif
    16721672
     
    21322132# endif
    21332133# if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE)
    2134     bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
     2134    bool fNoExecuteBitValid = CPUMIsGuestNXEnabled(pVCpu);
    21352135# endif
    21362136    unsigned uPageFaultLevel;
     
    26442644        {
    26452645            PGMPOOLACCESS enmAccess;
    2646 
    26472646# if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE)
    2648             const bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
    2649             const bool fNoExecute = fNoExecuteBitValid && PdeSrc.n.u1NoExecute;
     2647            const bool fNoExecute = PdeSrc.n.u1NoExecute && CPUMIsGuestNXEnabled(pVCpu);
    26502648# else
    26512649            const bool fNoExecute = false;
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r24997 r25835  
    8080     * All the other bits in the PDPTE are only valid in long mode (r/w, u/s, nx). */
    8181    X86PDEPAE   Pde = pgmGstGetPaePDE(&pVCpu->pgm.s, GCPtr);
    82     bool        fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
    8382
    8483#elif PGM_GST_TYPE == PGM_TYPE_AMD64
     
    8685    X86PDPE     Pdpe;
    8786    X86PDEPAE   Pde = pgmGstGetLongModePDEEx(&pVCpu->pgm.s, GCPtr, &pPml4e, &Pdpe);
    88     bool        fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
    8987
    9088    Assert(pPml4e);
     
    134132# if PGM_WITH_NX(PGM_GST_TYPE, PGM_GST_TYPE)
    135133            /* The NX bit is determined by a bitwise OR between the PT and PD */
    136             if (fNoExecuteBitValid)
     134            if (CPUMIsGuestNXEnabled(pVCpu))
    137135                *pfFlags |= (Pte.u & Pde.u & X86_PTE_PAE_NX);
    138136# endif
     
    152150# if PGM_WITH_NX(PGM_GST_TYPE, PGM_GST_TYPE)
    153151            /* The NX bit is determined by a bitwise OR between the PT and PD */
    154             if (fNoExecuteBitValid)
     152            if (CPUMIsGuestNXEnabled(pVCpu))
    155153                *pfFlags |= (Pde.u & X86_PTE_PAE_NX);
    156154# endif
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r25244 r25835  
    152152     */
    153153# if PGM_SHW_TYPE == PGM_TYPE_AMD64
    154     bool            fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
    155154    X86PDEPAE Pde;
    156155
     
    185184
    186185# elif PGM_SHW_TYPE == PGM_TYPE_PAE
    187     bool            fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);
    188186    X86PDEPAE       Pde = pgmShwGetPaePDE(&pVCpu->pgm.s, GCPtr);
    189187
     
    253251# if PGM_WITH_NX(PGM_SHW_TYPE, PGM_SHW_TYPE)
    254252        /* The NX bit is determined by a bitwise OR between the PT and PD */
    255         if (fNoExecuteBitValid)
     253        if (CPUMIsGuestNXEnabled(pVCpu))
    256254            *pfFlags |= (Pte.u & Pde.u & X86_PTE_PAE_NX);
    257255# endif
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