VirtualBox

Changeset 8965 in vbox for trunk


Ignore:
Timestamp:
May 20, 2008 3:41:55 PM (17 years ago)
Author:
vboxsync
Message:

Nested paging updates

Location:
trunk
Files:
4 edited

Legend:

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

    r8626 r8965  
    451451 */
    452452PGMR0DECL(int)  PGMR0PhysAllocateHandyPages(PVM pVM);
     453PGMR0DECL(int)  PGMR0Trap0eHandlerNestedPaging(PVM pVM, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
    453454/** @} */
    454455#endif /* IN_RING0 */
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r8533 r8965  
    277277}
    278278
    279 
    280279/**
    281280 * Prefetch a page
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r8952 r8965  
    266266        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4) | RT_BIT(8);
    267267    else
    268         pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(8);
     268        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(4) | RT_BIT(8);
    269269
    270270    /* Intercept all DRx reads and writes. */
     
    727727    unsigned    cResume = 0;
    728728
     729    STAM_PROFILE_ADV_START(&pVM->hwaccm.s.StatEntry, x);
     730
    729731    Assert(!pVM->hwaccm.s.svm.fNestedPaging);
    730 
    731     STAM_PROFILE_ADV_START(&pVM->hwaccm.s.StatEntry, x);
    732 
    733732    AssertReturn(pCpu->fSVMConfigured, VERR_EM_INTERNAL_ERROR);
    734733
     
    12791278
    12801279    case SVM_EXIT_NPF:
     1280    {
    12811281        /* EXITINFO1 contains fault errorcode; EXITINFO2 contains the guest physical address causing the fault. */
     1282        uint32_t    errCode        = pVMCB->ctrl.u64ExitInfo1;     /* EXITINFO1 = error code */
     1283        RTGCPHYS    uFaultAddress  = pVMCB->ctrl.u64ExitInfo2;     /* EXITINFO2 = fault address */
     1284
    12821285        Assert(pVM->hwaccm.s.svm.fNestedPaging);
     1286
     1287        Log2(("Page fault at %VGp cr2=%VGv error code %x\n", pCtx->eip, uFaultAddress, errCode));
     1288        /* Exit qualification contains the linear address of the page fault. */
     1289        TRPMAssertTrap(pVM, X86_XCPT_PF, TRPM_TRAP);
     1290        TRPMSetErrorCode(pVM, errCode);
     1291        TRPMSetFaultAddress(pVM, uFaultAddress);
     1292
     1293        /* Handle the pagefault trap for the nested shadow table. */
     1294        rc = PGMR0Trap0eHandlerNestedPaging(pVM, PGMGetShadowMode(pVM), errCode, CPUMCTX2CORE(pCtx), uFaultAddress);
     1295        Log2(("PGMR0Trap0eHandlerNestedPaging %VGv returned %Vrc\n", pCtx->eip, rc));
     1296        if (rc == VINF_SUCCESS)
     1297        {   /* We've successfully synced our shadow pages, so let's just continue execution. */
     1298            Log2(("Shadow page fault at %VGv cr2=%VGp error code %x\n", pCtx->eip, uFaultAddress, errCode));
     1299            STAM_COUNTER_INC(&pVM->hwaccm.s.StatExitShadowPF);
     1300
     1301            TRPMResetTrap(pVM);
     1302
     1303            STAM_PROFILE_ADV_STOP(&pVM->hwaccm.s.StatExit, x);
     1304            goto ResumeExecution;
     1305        }
     1306
     1307#ifdef VBOX_STRICT
     1308        if (rc != VINF_EM_RAW_EMULATE_INSTR)
     1309            LogFlow(("PGMTrap0eHandlerNestedPaging failed with %d\n", rc));
     1310#endif
     1311        /* Need to go back to the recompiler to emulate the instruction. */
     1312        TRPMResetTrap(pVM);
    12831313        break;
     1314    }
    12841315
    12851316    case SVM_EXIT_VINTR:
     
    13831414            break;
    13841415        case 4:
    1385             Assert(!pVM->hwaccm.s.svm.fNestedPaging);
    13861416            pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR4;
    13871417            break;
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r8155 r8965  
    3030#include <iprt/assert.h>
    3131
     32__BEGIN_DECLS
     33#define PGM_BTH_NAME(name)          PGM_BTH_NAME_32BIT_PROT(name)
     34#include "PGMR0Bth.h"
     35
     36#define PGM_BTH_NAME(name)          PGM_BTH_NAME_PAE_PROT(name)
     37#include "PGMR0Bth.h"
     38/*
     39#define PGM_BTH_NAME(name)          PGM_BTH_NAME_AMD64_PROT(name)
     40#include "PGMR0Bth.h"
     41*/
     42__END_DECLS
    3243
    3344
     
    4556PGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM)
    4657{
    47 
    4858    return VERR_NOT_IMPLEMENTED;
    4959}
    5060
    5161
     62/**
     63 * #PF Handler for nested paging.
     64 *
     65 * @returns VBox status code (appropriate for trap handling and GC return).
     66 * @param   pVM                 VM Handle.
     67 * @param   enmShwPagingMode    Paging mode for the nested page tables
     68 * @param   uErr                The trap error code.
     69 * @param   pRegFrame           Trap register frame.
     70 * @param   pvFault             The fault address.
     71 */
     72PGMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault)
     73{
     74    int rc;
     75
     76    LogFlow(("PGMTrap0eHandler: uErr=%#x pvFault=%VGp eip=%VGv\n", uErr, pvFault, pRegFrame->eip));
     77    STAM_PROFILE_START(&pVM->pgm.s.StatGCTrap0e, a);
     78    STAM_STATS({ pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution) = NULL; } );
     79
     80    /* AMD uses the host's paging mode; Intel's version is on the todo list */
     81    Assert(enmShwPagingMode == PGMMODE_32_BIT || enmShwPagingMode == PGMMODE_PAE); // || enmShwPagingMode == PGMMODE_AMD64);
     82
     83#ifdef VBOX_WITH_STATISTICS
     84    /*
     85     * Error code stats.
     86     */
     87    if (uErr & X86_TRAP_PF_US)
     88    {
     89        if (!(uErr & X86_TRAP_PF_P))
     90        {
     91            if (uErr & X86_TRAP_PF_RW)
     92                STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNotPresentWrite);
     93            else
     94                STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNotPresentRead);
     95        }
     96        else if (uErr & X86_TRAP_PF_RW)
     97            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSWrite);
     98        else if (uErr & X86_TRAP_PF_RSVD)
     99            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSReserved);
     100        else if (uErr & X86_TRAP_PF_ID)
     101            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNXE);
     102        else
     103            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSRead);
     104    }
     105    else
     106    {   /* Supervisor */
     107        if (!(uErr & X86_TRAP_PF_P))
     108        {
     109            if (uErr & X86_TRAP_PF_RW)
     110                STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVNotPresentWrite);
     111            else
     112                STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVNotPresentRead);
     113        }
     114        else if (uErr & X86_TRAP_PF_RW)
     115            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVWrite);
     116        else if (uErr & X86_TRAP_PF_ID)
     117            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSNXE);
     118        else if (uErr & X86_TRAP_PF_RSVD)
     119            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVReserved);
     120    }
     121#endif
     122
     123    /*
     124     * Call the worker.
     125     */
     126    switch(enmShwPagingMode)
     127    {
     128    case PGMMODE_32_BIT:
     129        rc = PGM_BTH_NAME_32BIT_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
     130        break;
     131    case PGMMODE_PAE:
     132        rc = PGM_BTH_NAME_PAE_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
     133        break;
     134        /*
     135    case PGMMODE_AMD64:
     136        rc = PGM_BTH_NAME_AMD64_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
     137        break;
     138        */
     139    }
     140    if (rc == VINF_PGM_SYNCPAGE_MODIFIED_PDE)
     141        rc = VINF_SUCCESS;
     142    STAM_STATS({ if (!pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution))
     143                    pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution) = &pVM->pgm.s.StatTrap0eMisc; });
     144    STAM_PROFILE_STOP_EX(&pVM->pgm.s.StatGCTrap0e, pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution), a);
     145    return rc;
     146}
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