VirtualBox

Changeset 8878

Show
Ignore:
Timestamp:
05/16/08 12:59:52 (3 months ago)
Author:
vboxsync
Message:

Don't automatically flush the TLB when we remain on the same cpu (on entry).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r8876 r8878  
    206206        /** Set by the ring-0 driver to indicate SVM is supported by the CPU. */ 
    207207        bool                        fSupported; 
    208  
    209208        /** Set when we've enabled SVM. */ 
    210209        bool                        fEnabled; 
    211  
    212210        /** Set if we don't have to flush the TLB on VM entry. */ 
    213211        bool                        fResumeVM; 
     
    216214        /** Set if we need to flush the TLB during the world switch. */ 
    217215        bool                        fForceTLBFlush; 
     216 
     217        /* Id of the last cpu we were executing code on (NIL_RTCPUID for the first time) */ 
     218        RTCPUID                     idLastCpu; 
    218219 
    219220        /** R0 memory object for the VM control block (VMCB). */ 
     
    330331typedef HWACCM *PHWACCM; 
    331332 
    332 static struct 
    333 { 
    334     struct 
    335     { 
    336         RTR0MEMOBJ  pMemObj; 
    337         bool        fVMXConfigured; 
    338         bool        fSVMConfigured; 
    339     } aCpuInfo[RTCPUSET_MAX_CPUS]; 
    340  
    341     struct 
    342     { 
    343         /** Set by the ring-0 driver to indicate VMX is supported by the CPU. */ 
    344         bool                        fSupported; 
    345  
    346         /** Host CR4 value (set by ring-0 VMX init) */ 
    347         uint64_t                    hostCR4; 
    348  
    349         /** VMX MSR values */ 
    350         struct 
    351         { 
    352             uint64_t                feature_ctrl; 
    353             uint64_t                vmx_basic_info; 
    354             uint64_t                vmx_pin_ctls; 
    355             uint64_t                vmx_proc_ctls; 
    356             uint64_t                vmx_exit; 
    357             uint64_t                vmx_entry; 
    358             uint64_t                vmx_misc; 
    359             uint64_t                vmx_cr0_fixed0; 
    360             uint64_t                vmx_cr0_fixed1; 
    361             uint64_t                vmx_cr4_fixed0; 
    362             uint64_t                vmx_cr4_fixed1; 
    363             uint64_t                vmx_vmcs_enum; 
    364         } msr; 
    365         /* Last instruction error */ 
    366         uint32_t                    ulLastInstrError; 
    367     } vmx; 
    368     struct 
    369     { 
    370         /** Set by the ring-0 driver to indicate SVM is supported by the CPU. */ 
    371         bool                        fSupported; 
    372  
    373         /** SVM revision. */ 
    374         uint32_t                    u32Rev; 
    375  
    376         /** Maximum ASID allowed. */ 
    377         uint32_t                    u32MaxASID; 
    378  
    379         /** SVM feature bits from cpuid 0x8000000a */ 
    380         uint32_t                    u32Features; 
    381     } svm; 
    382     /** Saved error from detection */ 
    383     int32_t         lLastError; 
    384  
    385     struct 
    386     { 
    387         uint32_t                    u32AMDFeatureECX; 
    388         uint32_t                    u32AMDFeatureEDX; 
    389     } cpuid; 
    390  
    391     HWACCMSTATE     enmHwAccmState; 
    392 } HWACCMR0GLOBALS; 
    393  
    394333typedef struct 
    395334{ 
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r8876 r8878  
    705705    CPUMCTX *pCtx; 
    706706    int      rc; 
     707    RTCPUID  idCpu = RTMpCpuId(); 
    707708 
    708709    rc = CPUMQueryGuestCtxPtr(pVM, &pCtx); 
     
    730731    { 
    731732        Assert(pVM->hwaccm.s.svm.fSupported); 
    732         rc  = SVMR0Enter(pVM); 
     733        rc  = SVMR0Enter(pVM, &HWACCMR0Globals.aCpuInfo[idCpu]); 
    733734        AssertRC(rc); 
    734735        rc |= SVMR0LoadGuestState(pVM, pCtx); 
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r8876 r8878  
    188188    } 
    189189 
     190    /* Invalidate the last cpu we were running on. */ 
     191    pVM->hwaccm.s.svm.idLastCpu = NIL_RTCPUID; 
    190192    return VINF_SUCCESS; 
    191193} 
     
    16431645 * @returns VBox status code. 
    16441646 * @param   pVM         The VM to operate on. 
     1647 * @param   pCpu        CPU info struct 
    16451648 */ 
    1646 HWACCMR0DECL(int) SVMR0Enter(PVM pVM
     1649HWACCMR0DECL(int) SVMR0Enter(PVM pVM, PHWACCM_CPUINFO pCpu
    16471650{ 
    16481651    Assert(pVM->hwaccm.s.svm.fSupported); 
    16491652 
    1650     /* Force a TLB flush on VM entry. */ 
    1651     pVM->hwaccm.s.svm.fForceTLBFlush = true; 
     1653    if (pVM->hwaccm.s.svm.idLastCpu != pCpu->idCpu) 
     1654    { 
     1655        /* Force a TLB flush on VM entry. */ 
     1656        pVM->hwaccm.s.svm.fForceTLBFlush = true; 
     1657    } 
     1658    pVM->hwaccm.s.svm.idLastCpu = pCpu->idCpu; 
    16521659 
    16531660    pVM->hwaccm.s.svm.fResumeVM = false; 
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.h

    r8876 r8878  
    4747 * @returns VBox status code. 
    4848 * @param   pVM         The VM to operate on. 
     49 * @param   pCpu        CPU info struct 
    4950 */ 
    50 HWACCMR0DECL(int) SVMR0Enter(PVM pVM); 
     51HWACCMR0DECL(int) SVMR0Enter(PVM pVM, PHWACCM_CPUINFO pCpu); 
    5152 
    5253/** 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy