VirtualBox

Changeset 25835 in vbox for trunk/include


Ignore:
Timestamp:
Jan 14, 2010 4:27:58 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56615
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/cpum.h

    r24061 r25835  
    661661VMMDECL(uint64_t)   CPUMGetGuestMsr(PVMCPU pVCpu, unsigned idMsr);
    662662VMMDECL(void)       CPUMSetGuestMsr(PVMCPU pVCpu, unsigned idMsr, uint64_t valMsr);
     663VMMDECL(CPUMCPUVENDOR)  CPUMGetGuestCpuVendor(PVM pVM);
     664VMMDECL(CPUMCPUVENDOR)  CPUMGetHostCpuVendor(PVM pVM);
    663665/** @} */
    664666
     
    703705/** @} */
    704706
     707
    705708/** @name Misc Guest Predicate Functions.
    706709 * @{  */
    707710
    708 
    709 VMMDECL(bool)           CPUMIsGuestIn16BitCode(PVMCPU pVCpu);
    710 VMMDECL(bool)           CPUMIsGuestIn32BitCode(PVMCPU pVCpu);
    711 
    712 VMMDECL(CPUMCPUVENDOR)  CPUMGetGuestCpuVendor(PVM pVM);
    713 VMMDECL(CPUMCPUVENDOR)  CPUMGetHostCpuVendor(PVM pVM);
    714 
    715 /**
    716  * Tests if the guest is running in real mode or not.
    717  *
    718  * @returns true if in real mode, otherwise false.
    719  * @param   pVM     The VM handle.
    720  */
    721 DECLINLINE(bool) CPUMIsGuestInRealMode(PVMCPU pVCpu)
    722 {
    723     return !(CPUMGetGuestCR0(pVCpu) & X86_CR0_PE);
    724 }
     711VMMDECL(bool)       CPUMIsGuestIn16BitCode(PVMCPU pVCpu);
     712VMMDECL(bool)       CPUMIsGuestIn32BitCode(PVMCPU pVCpu);
     713VMMDECL(bool)       CPUMIsGuestNXEnabled(PVMCPU pVCpu);
     714VMMDECL(bool)       CPUMIsGuestInRealMode(PVMCPU pVCpu);
     715VMMDECL(bool)       CPUMIsGuestInProtectedMode(PVMCPU pVCpu);
     716VMMDECL(bool)       CPUMIsGuestInPagedProtectedMode(PVMCPU pVCpu);
     717VMMDECL(bool)       CPUMIsGuestInLongMode(PVMCPU pVCpu);
     718VMMDECL(bool)       CPUMIsGuestInPAEMode(PVMCPU pVCpu);
    725719
    726720/**
     
    730724 * @param   pCtx    Current CPU context
    731725 */
    732 DECLINLINE(bool) CPUMIsGuestInRealModeEx(PCPUMCTX pCtx)
     726DECLINLINE(bool)    CPUMIsGuestInRealModeEx(PCPUMCTX pCtx)
    733727{
    734728    return !(pCtx->cr0 & X86_CR0_PE);
     
    736730
    737731/**
    738  * Tests if the guest is running in protected or not.
    739  *
    740  * @returns true if in protected mode, otherwise false.
    741  * @param   pVM     The VM handle.
    742  */
    743 DECLINLINE(bool) CPUMIsGuestInProtectedMode(PVMCPU pVCpu)
    744 {
    745     return !!(CPUMGetGuestCR0(pVCpu) & X86_CR0_PE);
    746 }
    747 
    748 /**
    749732 * Tests if the guest is running in paged protected or not.
    750733 *
     
    752735 * @param   pVM     The VM handle.
    753736 */
    754 DECLINLINE(bool) CPUMIsGuestInPagedProtectedMode(PVMCPU pVCpu)
    755 {
    756     return (CPUMGetGuestCR0(pVCpu) & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
    757 }
    758 
    759 /**
    760  * Tests if the guest is running in paged protected or not.
    761  *
    762  * @returns true if in paged protected mode, otherwise false.
    763  * @param   pVM     The VM handle.
    764  */
    765 DECLINLINE(bool) CPUMIsGuestInPagedProtectedModeEx(PCPUMCTX pCtx)
     737DECLINLINE(bool)    CPUMIsGuestInPagedProtectedModeEx(PCPUMCTX pCtx)
    766738{
    767739    return (pCtx->cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
     
    772744 *
    773745 * @returns true if in long mode, otherwise false.
    774  * @param   pVM     The VM handle.
    775  */
    776 DECLINLINE(bool) CPUMIsGuestInLongMode(PVMCPU pVCpu)
    777 {
    778     return (CPUMGetGuestEFER(pVCpu) & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA;
    779 }
    780 
    781 /**
    782  * Tests if the guest is running in long mode or not.
    783  *
    784  * @returns true if in long mode, otherwise false.
    785746 * @param   pCtx    Current CPU context
    786747 */
    787 DECLINLINE(bool) CPUMIsGuestInLongModeEx(PCPUMCTX pCtx)
     748DECLINLINE(bool)    CPUMIsGuestInLongModeEx(PCPUMCTX pCtx)
    788749{
    789750    return (pCtx->msrEFER & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA;
     
    797758 * @param   pCtx    Current CPU context
    798759 */
    799 DECLINLINE(bool) CPUMIsGuestIn64BitCode(PVMCPU pVCpu, PCCPUMCTXCORE pCtx)
     760DECLINLINE(bool)    CPUMIsGuestIn64BitCode(PVMCPU pVCpu, PCCPUMCTXCORE pCtx)
    800761{
    801762    if (!CPUMIsGuestInLongMode(pVCpu))
     
    812773 * @param   pCtx    Current CPU context
    813774 */
    814 DECLINLINE(bool) CPUMIsGuestIn64BitCodeEx(PCCPUMCTX pCtx)
     775DECLINLINE(bool)    CPUMIsGuestIn64BitCodeEx(PCCPUMCTX pCtx)
    815776{
    816777    if (!(pCtx->msrEFER & MSR_K6_EFER_LMA))
     
    824785 *
    825786 * @returns true if in PAE mode, otherwise false.
    826  * @param   pVM     The VM handle.
    827  */
    828 DECLINLINE(bool) CPUMIsGuestInPAEMode(PVMCPU pVCpu)
    829 {
    830     return (    CPUMIsGuestInPagedProtectedMode(pVCpu)
    831             &&  (CPUMGetGuestCR4(pVCpu) & X86_CR4_PAE)
    832             &&  !CPUMIsGuestInLongMode(pVCpu));
    833 }
    834 
    835 /**
    836  * Tests if the guest is running in PAE mode or not.
    837  *
    838  * @returns true if in PAE mode, otherwise false.
    839787 * @param   pCtx    Current CPU context
    840788 */
    841 DECLINLINE(bool) CPUMIsGuestInPAEModeEx(PCPUMCTX pCtx)
    842 {
    843     return (    CPUMIsGuestInPagedProtectedModeEx(pCtx)
    844             &&  (pCtx->cr4 & X86_CR4_PAE)
     789DECLINLINE(bool)    CPUMIsGuestInPAEModeEx(PCPUMCTX pCtx)
     790{
     791    return (    (pCtx->cr4 & X86_CR4_PAE)
     792            &&  CPUMIsGuestInPagedProtectedModeEx(pCtx)
    845793            &&  !CPUMIsGuestInLongModeEx(pCtx));
    846794}
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