VirtualBox

Changeset 8948 in vbox for trunk


Ignore:
Timestamp:
May 20, 2008 11:09:40 AM (17 years ago)
Author:
vboxsync
Message:

Nested paging updates

Location:
trunk
Files:
2 edited

Legend:

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

    r8943 r8948  
    565565        SVM_EVENT   EventInject;
    566566        /** Offset 0xB0 - Host CR3 for nested paging. */
    567         uint64_t    u64HostCR3;
     567        uint64_t    u64NestedPagingCR3;
    568568        /** Offset 0xB8 - LBR Virtualization. */
    569569        uint64_t    u64LBRVirt;
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r8945 r8948  
    255255    /* Note: CR8 reads will refer to V_TPR, so no need to catch them. */
    256256    /** @note CR0 & CR4 can be safely read when guest and shadow copies are identical. */
    257     pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4);
     257    if (!pVM->hwaccm.s.svm.fNestedPaging)
     258        pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4);
     259    else   
     260        pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0);
    258261
    259262    /*
    260263     * CR0/3/4 writes must be intercepted for obvious reasons.
    261264     */
    262     pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4) | RT_BIT(8);
     265    if (!pVM->hwaccm.s.svm.fNestedPaging)
     266        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4) | RT_BIT(8);
     267    else
     268        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(8);
    263269
    264270    /* Intercept all DRx reads and writes. */
     
    583589        val &= ~(X86_CR0_CD|X86_CR0_NW);
    584590
    585         val |= X86_CR0_PG;          /* Paging is always enabled; even when the guest is running in real mode or PE without paging. */
    586         val |= X86_CR0_WP;          /* Must set this as we rely on protect various pages and supervisor writes must be caught. */
     591        /* Note: WP is not relevant in nested paging mode as we catch accesses on the (host) physical level. */
     592        /* Note: In nested paging mode the guest is allowed to run with paging disabled; the guest physical to host physical translation is still active. */
     593        if (!pVM->hwaccm.s.svm.fNestedPaging)
     594        {
     595            val |= X86_CR0_PG;          /* Paging is always enabled; even when the guest is running in real mode or PE without paging. */
     596            val |= X86_CR0_WP;          /* Must set this as we rely on protect various pages and supervisor writes must be caught. */
     597        }
    587598        pVMCB->guest.u64CR0 = val;
    588599    }
     
    593604    {
    594605        /* Save our shadow CR3 register. */
    595         pVMCB->guest.u64CR3 = PGMGetHyperCR3(pVM);
     606        if (!pVM->hwaccm.s.svm.fNestedPaging)
     607            pVMCB->guest.u64CR3 = PGMGetHyperCR3(pVM);
     608        else
     609            pVMCB->guest.u64CR3 = pCtx->cr3;
    596610    }
    597611
     
    599613    {
    600614        val = pCtx->cr4;
    601         switch(pVM->hwaccm.s.enmShadowMode)
    602         {
    603         case PGMMODE_REAL:
    604         case PGMMODE_PROTECTED:     /* Protected mode, no paging. */
    605             AssertFailed();
    606             return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
    607 
    608         case PGMMODE_32_BIT:        /* 32-bit paging. */
    609             break;
    610 
    611         case PGMMODE_PAE:           /* PAE paging. */
    612         case PGMMODE_PAE_NX:        /* PAE paging with NX enabled. */
    613             /** @todo use normal 32 bits paging */
    614             val |= X86_CR4_PAE;
    615             break;
    616 
    617         case PGMMODE_AMD64:         /* 64-bit AMD paging (long mode). */
    618         case PGMMODE_AMD64_NX:      /* 64-bit AMD paging (long mode) with NX enabled. */
    619             AssertFailed();
    620             return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
    621 
    622         default:                   /* shut up gcc */
    623             AssertFailed();
    624             return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
     615        if (!pVM->hwaccm.s.svm.fNestedPaging)
     616        {
     617            switch(pVM->hwaccm.s.enmShadowMode)
     618            {
     619            case PGMMODE_REAL:
     620            case PGMMODE_PROTECTED:     /* Protected mode, no paging. */
     621                AssertFailed();
     622                return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
     623
     624            case PGMMODE_32_BIT:        /* 32-bit paging. */
     625                break;
     626
     627            case PGMMODE_PAE:           /* PAE paging. */
     628            case PGMMODE_PAE_NX:        /* PAE paging with NX enabled. */
     629                /** @todo use normal 32 bits paging */
     630                val |= X86_CR4_PAE;
     631                break;
     632
     633            case PGMMODE_AMD64:         /* 64-bit AMD paging (long mode). */
     634            case PGMMODE_AMD64_NX:      /* 64-bit AMD paging (long mode) with NX enabled. */
     635                AssertFailed();
     636                return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
     637
     638            default:                   /* shut up gcc */
     639                AssertFailed();
     640                return VERR_PGM_UNSUPPORTED_HOST_PAGING_MODE;
     641            }
    625642        }
    626643        pVMCB->guest.u64CR4 = val;
     
    703720    unsigned    cResume = 0;
    704721
     722    Assert(!pVM->hwaccm.s.svm.fNestedPaging);
     723
    705724    STAM_PROFILE_ADV_START(&pVM->hwaccm.s.StatEntry, x);
    706725
     
    788807    STAM_PROFILE_ADV_START(&pVM->hwaccm.s.StatInGC, x);
    789808
    790     /* Enable nested paging (disabled each time after #VMEXIT). */
     809    /* Enable nested paging if necessary (disabled each time after #VMEXIT). */
    791810    pVMCB->ctrl.NestedPaging.n.u1NestedPaging = pVM->hwaccm.s.svm.fNestedPaging;
    792811
     
    922941        Log(("ctrl.EventInject.u32ErrorCode     %x\n",      pVMCB->ctrl.EventInject.n.u32ErrorCode));
    923942
    924         Log(("ctrl.u64HostCR3                   %VX64\n",   pVMCB->ctrl.u64HostCR3));
     943        Log(("ctrl.u64NestedPagingCR3           %VX64\n",   pVMCB->ctrl.u64NestedPagingCR3));
    925944        Log(("ctrl.u64LBRVirt                   %VX64\n",   pVMCB->ctrl.u64LBRVirt));
    926945
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