Changeset 25835 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jan 14, 2010 4:27:58 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r25815 r25835 1698 1698 } 1699 1699 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 */ 1707 VMMDECL(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 */ 1719 VMMDECL(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 */ 1731 VMMDECL(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 */ 1743 VMMDECL(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 */ 1755 VMMDECL(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 */ 1767 VMMDECL(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 1700 1776 #ifndef IN_RING0 /** @todo I don't think we need this in R0, so move it to CPUMAll.cpp? */ 1701 1777 -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r25579 r25835 1668 1668 1669 1669 # if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE) 1670 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);1670 bool fNoExecuteBitValid = CPUMIsGuestNXEnabled(pVCpu); 1671 1671 # endif 1672 1672 … … 2132 2132 # endif 2133 2133 # if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE) 2134 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);2134 bool fNoExecuteBitValid = CPUMIsGuestNXEnabled(pVCpu); 2135 2135 # endif 2136 2136 unsigned uPageFaultLevel; … … 2644 2644 { 2645 2645 PGMPOOLACCESS enmAccess; 2646 2647 2646 # 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); 2650 2648 # else 2651 2649 const bool fNoExecute = false; -
trunk/src/VBox/VMM/VMMAll/PGMAllGst.h
r24997 r25835 80 80 * All the other bits in the PDPTE are only valid in long mode (r/w, u/s, nx). */ 81 81 X86PDEPAE Pde = pgmGstGetPaePDE(&pVCpu->pgm.s, GCPtr); 82 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);83 82 84 83 #elif PGM_GST_TYPE == PGM_TYPE_AMD64 … … 86 85 X86PDPE Pdpe; 87 86 X86PDEPAE Pde = pgmGstGetLongModePDEEx(&pVCpu->pgm.s, GCPtr, &pPml4e, &Pdpe); 88 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);89 87 90 88 Assert(pPml4e); … … 134 132 # if PGM_WITH_NX(PGM_GST_TYPE, PGM_GST_TYPE) 135 133 /* The NX bit is determined by a bitwise OR between the PT and PD */ 136 if ( fNoExecuteBitValid)134 if (CPUMIsGuestNXEnabled(pVCpu)) 137 135 *pfFlags |= (Pte.u & Pde.u & X86_PTE_PAE_NX); 138 136 # endif … … 152 150 # if PGM_WITH_NX(PGM_GST_TYPE, PGM_GST_TYPE) 153 151 /* The NX bit is determined by a bitwise OR between the PT and PD */ 154 if ( fNoExecuteBitValid)152 if (CPUMIsGuestNXEnabled(pVCpu)) 155 153 *pfFlags |= (Pde.u & X86_PTE_PAE_NX); 156 154 # endif -
trunk/src/VBox/VMM/VMMAll/PGMAllShw.h
r25244 r25835 152 152 */ 153 153 # if PGM_SHW_TYPE == PGM_TYPE_AMD64 154 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);155 154 X86PDEPAE Pde; 156 155 … … 185 184 186 185 # elif PGM_SHW_TYPE == PGM_TYPE_PAE 187 bool fNoExecuteBitValid = !!(CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_NXE);188 186 X86PDEPAE Pde = pgmShwGetPaePDE(&pVCpu->pgm.s, GCPtr); 189 187 … … 253 251 # if PGM_WITH_NX(PGM_SHW_TYPE, PGM_SHW_TYPE) 254 252 /* The NX bit is determined by a bitwise OR between the PT and PD */ 255 if ( fNoExecuteBitValid)253 if (CPUMIsGuestNXEnabled(pVCpu)) 256 254 *pfFlags |= (Pte.u & Pde.u & X86_PTE_PAE_NX); 257 255 # endif
Note:
See TracChangeset
for help on using the changeset viewer.