VirtualBox

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


Ignore:
Timestamp:
May 15, 2008 1:57:31 PM (17 years ago)
Author:
vboxsync
Message:

Manual page invalidation or TLB flush is required for AMD-V.

Location:
trunk/src/VBox/VMM
Files:
6 edited

Legend:

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

    r8806 r8853  
    211211        bool                        fResumeVM;
    212212        /** Set if erratum 170 affects the AMD cpu. */
     213        bool                        fAlwaysFlushTLB;
     214        /** Set if we need to flush the TLB during the world switch. */
    213215        bool                        fForceTLBFlush;
    214216
  • trunk/src/VBox/VMM/PGMInternal.h

    r8659 r8853  
    3636#include <VBox/log.h>
    3737#include <VBox/gmm.h>
     38#include <VBox/hwaccm.h>
    3839#include <iprt/avl.h>
    3940#include <iprt/assert.h>
     
    266267#ifdef IN_GC
    267268# define PGM_INVL_PG(GCVirt)        ASMInvalidatePage((void *)(GCVirt))
     269#elif defined(IN_RING0)
     270# define PGM_INVL_PG(GCVirt)        HWACCMR0InvalidatePage(pVM, (RTGCPTR)(GCVirt))
    268271#else
    269272# define PGM_INVL_PG(GCVirt)        ((void)0)
     
    277280#ifdef IN_GC
    278281# define PGM_INVL_BIG_PG(GCVirt)    ASMReloadCR3()
     282#elif defined(IN_RING0)
     283# define PGM_INVL_BIG_PG(GCVirt)    HWACCMR0FlushTLB(pVM)
    279284#else
    280285# define PGM_INVL_BIG_PG(GCVirt)    ((void)0)
     
    286291#ifdef IN_GC
    287292# define PGM_INVL_GUEST_TLBS()      ASMReloadCR3()
     293#elif defined(IN_RING0)
     294# define PGM_INVL_GUEST_TLBS()      HWACCMR0FlushTLB(pVM)
    288295#else
    289296# define PGM_INVL_GUEST_TLBS()      ((void)0)
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r8454 r8853  
    908908static int pgmPoolCacheFreeOne(PPGMPOOL pPool, uint16_t iUser)
    909909{
     910#ifdef IN_RING0
     911    const PVM pVM = pPool->CTXSUFF(pVM);
     912#endif
    910913    Assert(pPool->iAgeHead != pPool->iAgeTail); /* We shouldn't be here if there < 2 cached entries! */
    911914    STAM_COUNTER_INC(&pPool->StatCacheFreeUpOne);
     
    10321035static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint16_t iUserTable, PPPGMPOOLPAGE ppPage)
    10331036{
     1037#ifdef IN_RING0
     1038    const PVM pVM = pPool->CTXSUFF(pVM);
     1039#endif
    10341040    /*
    10351041     * Look up the GCPhys in the hash.
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r8554 r8853  
    807807        return SVMR0RunGuestCode(pVM, pCtx);
    808808    }
     809}
     810
     811/**
     812 * Invalidates a guest page
     813 *
     814 * @returns VBox status code.
     815 * @param   pVM         The VM to operate on.
     816 * @param   GCVirt      Page to invalidate
     817 */
     818HWACCMR0DECL(int) HWACCMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt)
     819{
     820    if (pVM->hwaccm.s.svm.fSupported)
     821        return SVMR0InvalidatePage(pVM, GCVirt);
     822
     823    return VINF_SUCCESS;
     824}
     825
     826/**
     827 * Flushes the guest TLB
     828 *
     829 * @returns VBox status code.
     830 * @param   pVM         The VM to operate on.
     831 */
     832HWACCMR0DECL(int) HWACCMR0FlushTLB(PVM pVM)
     833{
     834    if (pVM->hwaccm.s.svm.fSupported)
     835        return SVMR0FlushTLB(pVM);
     836
     837    return VINF_SUCCESS;
    809838}
    810839
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r8848 r8853  
    170170    {
    171171        Log(("SVMR0InitVM: AMD cpu with erratum 170 family %x model %x stepping %x\n", u32Family, u32Model, u32Stepping));
    172         pVM->hwaccm.s.svm.fForceTLBFlush = true;
     172        pVM->hwaccm.s.svm.fAlwaysFlushTLB = true;
    173173    }
    174174
     
    681681    uint64_t    exitCode = (uint64_t)SVM_EXIT_INVALID;
    682682    SVM_VMCB   *pVMCB;
    683     bool        fForceTLBFlush = false;
    684683    bool        fGuestStateSynced = false;
    685684    unsigned    cResume = 0;
     
    768767    STAM_PROFILE_ADV_START(&pVM->hwaccm.s.StatInGC, x);
    769768
    770     if (    pVM->hwaccm.s.svm.fResumeVM == false
    771         ||  pVM->hwaccm.s.svm.fForceTLBFlush
    772         ||  fForceTLBFlush)
     769    if (    pVM->hwaccm.s.svm.fForceTLBFlush
     770        ||  pVM->hwaccm.s.svm.fAlwaysFlushTLB)
    773771    {
    774772        pVMCB->ctrl.TLBCtrl.n.u1TLBFlush = 1;
     
    778776
    779777    /* In case we execute a goto ResumeExecution later on. */
    780     pVM->hwaccm.s.svm.fResumeVM = true;
    781     fForceTLBFlush = false;
     778    pVM->hwaccm.s.svm.fResumeVM      = true;
     779    pVM->hwaccm.s.svm.fForceTLBFlush = false;
    782780
    783781    Assert(sizeof(pVM->hwaccm.s.svm.pVMCBPhys) == 8);
     
    12871285
    12881286            /** @note Force a TLB flush. SVM requires us to do it manually. */
    1289             fForceTLBFlush = true;
     1287            pVM->hwaccm.s.svm.fForceTLBFlush = true;
    12901288        }
    12911289        if (rc == VINF_SUCCESS)
     
    15991597
    16001598    /* Force a TLB flush on VM entry. */
     1599    pVM->hwaccm.s.svm.fForceTLBFlush = true;
     1600
    16011601    pVM->hwaccm.s.svm.fResumeVM = false;
    16021602
     
    16541654    }
    16551655    Assert(rc == VERR_REM_FLUSHED_PAGES_OVERFLOW);
    1656     return (rc == VERR_REM_FLUSHED_PAGES_OVERFLOW) ? VERR_EM_INTERPRETER : rc;
     1656    return rc;
    16571657}
    16581658
     
    17031703}
    17041704
     1705
     1706/**
     1707 * Invalidates a guest page
     1708 *
     1709 * @returns VBox status code.
     1710 * @param   pVM         The VM to operate on.
     1711 * @param   GCVirt      Page to invalidate
     1712 */
     1713HWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt)
     1714{
     1715    SVM_VMCB   *pVMCB;
     1716
     1717    Log2(("SVMR0InvalidatePage %VGv\n", GCVirt));
     1718    AssertReturn(pVM, VERR_INVALID_PARAMETER);
     1719    Assert(pVM->hwaccm.s.svm.fSupported);
     1720
     1721    pVMCB = (SVM_VMCB *)pVM->hwaccm.s.svm.pVMCB;
     1722    AssertMsgReturn(pVMCB, ("Invalid pVMCB\n"), VERR_EM_INTERNAL_ERROR);
     1723
     1724    SVMInvlpgA(GCVirt, pVMCB->ctrl.TLBCtrl.n.u32ASID);
     1725    return VINF_SUCCESS;
     1726}
     1727
     1728/**
     1729 * Flushes the guest TLB
     1730 *
     1731 * @returns VBox status code.
     1732 * @param   pVM         The VM to operate on.
     1733 */
     1734HWACCMR0DECL(int) SVMR0FlushTLB(PVM pVM)
     1735{
     1736    Log2(("SVMR0FlushTLB\n"));
     1737    pVM->hwaccm.s.svm.fForceTLBFlush = true;
     1738
     1739    return VINF_SUCCESS;
     1740}
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.h

    r8155 r8853  
    125125HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
    126126
     127/**
     128 * Invalidates a guest page
     129 *
     130 * @returns VBox status code.
     131 * @param   pVM         The VM to operate on.
     132 * @param   GCVirt      Page to invalidate
     133 */
     134HWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
     135
     136/**
     137 * Flushes the guest TLB
     138 *
     139 * @returns VBox status code.
     140 * @param   pVM         The VM to operate on.
     141 */
     142HWACCMR0DECL(int) SVMR0FlushTLB(PVM pVM);
     143
    127144
    128145/* Convert hidden selector attribute word between VMX and SVM formats. */
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