VirtualBox

Changeset 13198

Show
Ignore:
Timestamp:
10/13/08 11:05:42 (3 months ago)
Author:
vboxsync
Message:

Recommitted 37737 & 37738 minus the dangerous changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/cpum.h

    r13174 r13198  
    806806} 
    807807 
     808/** 
     809 * Tests if the guest is running in PAE mode or not. 
     810 * 
     811 * @returns true if in PAE mode, otherwise false. 
     812 * @param   pCtx    Current CPU context 
     813 */ 
     814DECLINLINE(bool) CPUMIsGuestInPAEModeEx(PCPUMCTX pCtx) 
     815{ 
     816    return (    CPUMIsGuestInPagedProtectedModeEx(pCtx) 
     817            &&  (pCtx->cr4 & X86_CR4_PAE) 
     818            &&  !CPUMIsGuestInLongModeEx(pCtx)); 
     819} 
     820 
    808821/** @} */ 
    809822 
  • trunk/include/VBox/pgm.h

    r13197 r13198  
    336336VMMDECL(int)    PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags); 
    337337VMMDECL(int)    PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask); 
     338VMMDECL(X86PDPE) PGMGstGetPaePDPtr(PVM pVM, unsigned iPdPt); 
     339 
    338340VMMDECL(int)    PGMFlushTLB(PVM pVM, uint64_t cr3, bool fGlobal); 
    339341VMMDECL(int)    PGMUpdateCR3(PVM pVM, uint64_t cr3); 
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r13197 r13198  
    12111211} 
    12121212 
     1213/** 
     1214 * Gets the specified page directory pointer table entry. 
     1215 * 
     1216 * @returns PDP entry 
     1217 * @param   pPGM        Pointer to the PGM instance data. 
     1218 * @param   iPdpt       PDPT index 
     1219 */ 
     1220VMMDECL(X86PDPE) PGMGstGetPaePDPtr(PVM pVM, unsigned iPdpt) 
     1221{ 
     1222    Assert(iPdpt <= 3); 
     1223    return pVM->pgm.s.CTXSUFF(pGstPaePDPT)->a[iPdpt & 3]; 
     1224} 
     1225 
    12131226 
    12141227/** 
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r13197 r13198  
    5656#define VMXR0ReportWorldSwitchError(a, b, c)      do { } while (0); 
    5757#endif /* VBOX_STRICT */ 
    58 static void VMXR0SetupTLBEPT(PVM pVM); 
    59 static void VMXR0SetupTLBVPID(PVM pVM); 
    60 static void VMXR0SetupTLBDummy(PVM pVM); 
    61 static void VMXR0FlushEPT(PVM pVM, VMX_FLUSH enmFlush, RTGCPHYS GCPhys); 
    62 static void VMXR0FlushVPID(PVM pVM, VMX_FLUSH enmFlush, RTGCPTR GCPtr); 
     58static void vmxR0SetupTLBEPT(PVM pVM); 
     59static void vmxR0SetupTLBVPID(PVM pVM); 
     60static void vmxR0SetupTLBDummy(PVM pVM); 
     61static void vmxR0FlushEPT(PVM pVM, VMX_FLUSH enmFlush, RTGCPHYS GCPhys); 
     62static void vmxR0FlushVPID(PVM pVM, VMX_FLUSH enmFlush, RTGCPTR GCPtr); 
    6363 
    6464 
     
    476476    if (pVM->hwaccm.s.fNestedPaging) 
    477477    { 
    478         pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = VMXR0SetupTLBEPT; 
     478        pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = vmxR0SetupTLBEPT; 
    479479 
    480480        /* Default values for flushing. */ 
     
    496496    if (pVM->hwaccm.s.vmx.fVPID) 
    497497    { 
    498         pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = VMXR0SetupTLBVPID; 
     498        pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = vmxR0SetupTLBVPID; 
    499499 
    500500        /* Default values for flushing. */ 
     
    514514#endif /* HWACCM_VTX_WITH_VPID */ 
    515515    else 
    516         pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = VMXR0SetupTLBDummy; 
     516        pVM->hwaccm.s.vmx.pfnSetupTaggedTLB = vmxR0SetupTLBDummy; 
    517517 
    518518 
     
    818818} 
    819819 
     820/** 
     821 * Prefetch the 4 PDPT pointers (PAE and nested paging only) 
     822 * 
     823 * @param   pVM         The VM to operate on. 
     824 * @param   pCtx        Guest context 
     825 */  
     826static void vmxR0PrefetchPAEPdptrs(PVM pVM, PCPUMCTX pCtx) 
     827{ 
     828    if (CPUMIsGuestInPAEModeEx(pCtx)) 
     829    { 
     830        X86PDPE Pdpe; 
     831 
     832        for (unsigned i=0;i<4;i++) 
     833        { 
     834            Pdpe = PGMGstGetPaePDPtr(pVM, i); 
     835            int rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR0_FULL + i*2, Pdpe.u); 
     836            AssertRC(rc); 
     837        } 
     838    } 
     839} 
    820840 
    821841/** 
     
    12261246                /* Save the real guest CR3 in VMX_VMCS_GUEST_CR3 */ 
    12271247                val = pCtx->cr3; 
     1248                /* Prefetch the four PDPT entries in PAE mode. */ 
     1249                vmxR0PrefetchPAEPdptrs(pVM, pCtx); 
    12281250            } 
    12291251        } 
     
    14541476            PGMUpdateCR3(pVM, val); 
    14551477        } 
     1478        /* Prefetch the four PDPT entries in PAE mode. */ 
     1479        vmxR0PrefetchPAEPdptrs(pVM, pCtx); 
    14561480    } 
    14571481 
     
    15161540 * @param   pVM         The VM to operate on. 
    15171541 */ 
    1518 static void VMXR0SetupTLBDummy(PVM pVM) 
     1542static void vmxR0SetupTLBDummy(PVM pVM) 
    15191543{ 
    15201544    return; 
     
    15271551 * @param   pVM         The VM to operate on. 
    15281552 */ 
    1529 static void VMXR0SetupTLBEPT(PVM pVM) 
     1553static void vmxR0SetupTLBEPT(PVM pVM) 
    15301554{ 
    15311555    PHWACCM_CPUINFO pCpu; 
     
    15521576 
    15531577    if (pVM->hwaccm.s.fForceTLBFlush) 
    1554         VMXR0FlushEPT(pVM, pVM->hwaccm.s.vmx.enmFlushContext, 0); 
     1578        vmxR0FlushEPT(pVM, pVM->hwaccm.s.vmx.enmFlushContext, 0); 
    15551579 
    15561580#ifdef VBOX_WITH_STATISTICS 
     
    15691593 * @param   pVM         The VM to operate on. 
    15701594 */ 
    1571 static void VMXR0SetupTLBVPID(PVM pVM) 
     1595static void vmxR0SetupTLBVPID(PVM pVM) 
    15721596{ 
    15731597    PHWACCM_CPUINFO pCpu; 
     
    16261650 
    16271651    if (pVM->hwaccm.s.fForceTLBFlush) 
    1628         VMXR0FlushVPID(pVM, pVM->hwaccm.s.vmx.enmFlushContext, 0); 
     1652        vmxR0FlushVPID(pVM, pVM->hwaccm.s.vmx.enmFlushContext, 0); 
    16291653 
    16301654#ifdef VBOX_WITH_STATISTICS 
     
    29863010 * @param   GCPhys      Physical address of the page to flush 
    29873011 */ 
    2988 static void VMXR0FlushEPT(PVM pVM, VMX_FLUSH enmFlush, RTGCPHYS GCPhys) 
     3012static void vmxR0FlushEPT(PVM pVM, VMX_FLUSH enmFlush, RTGCPHYS GCPhys) 
    29893013{ 
    29903014    uint64_t descriptor[2]; 
    29913015 
    2992     LogFlow(("VMXR0FlushEPT %d %VGv\n", enmFlush, GCPhys)); 
     3016    LogFlow(("vmxR0FlushEPT %d %VGv\n", enmFlush, GCPhys)); 
    29933017    Assert(pVM->hwaccm.s.fNestedPaging); 
    29943018    descriptor[0] = pVM->hwaccm.s.vmx.GCPhysEPTP; 
     
    30073031 * @param   GCPtr       Virtual address of the page to flush 
    30083032 */ 
    3009 static void VMXR0FlushVPID(PVM pVM, VMX_FLUSH enmFlush, RTGCPTR GCPtr) 
     3033static void vmxR0FlushVPID(PVM pVM, VMX_FLUSH enmFlush, RTGCPTR GCPtr) 
    30103034{ 
    30113035    uint64_t descriptor[2]; 
     
    30373061    if (   !fFlushPending  
    30383062        && pVM->hwaccm.s.vmx.fVPID) 
    3039         VMXR0FlushVPID(pVM, pVM->hwaccm.s.vmx.enmFlushPage, GCVirt); 
     3063        vmxR0FlushVPID(pVM, pVM->hwaccm.s.vmx.enmFlushPage, GCVirt); 
    30403064#endif /* HWACCM_VTX_WITH_VPID */ 
    30413065 
     
    30603084    /* Skip it if a TLB flush is already pending. */ 
    30613085    if (!fFlushPending) 
    3062         VMXR0FlushEPT(pVM, pVM->hwaccm.s.vmx.enmFlushPage, GCPhys); 
     3086        vmxR0FlushEPT(pVM, pVM->hwaccm.s.vmx.enmFlushPage, GCPhys); 
    30633087 
    30643088    return VINF_SUCCESS; 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy