VirtualBox

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


Ignore:
Timestamp:
Jul 1, 2008 9:57:49 AM (16 years ago)
Author:
vboxsync
Message:

AMD64 updates for nested paging.

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

Legend:

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

    r10032 r10063  
    13801380    /** Shw: 64-bit PML4;   Gst: 64-bit PML4. */
    13811381    PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4,
    1382     /** Shw: 64-bit PML4; Gst: no paging  */
    1383     PGMPOOLKIND_64BIT_PML4_FOR_PHYS,
    13841382
    13851383    /** Shw: Root 32-bit page directory. */
     
    33603358    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    33613359
     3360    Assert(pPGM->pGstPaePML4HC);
    33623361    *ppPml4e = &pPGM->pGstPaePML4HC->a[iPml4e];
    33633362    if ((*ppPml4e)->n.u1Present)
     
    33903389    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    33913390
     3391    Assert(pPGM->pGstPaePML4HC);
    33923392    *ppPml4e = &pPGM->pGstPaePML4HC->a[iPml4e];
    33933393    if ((*ppPml4e)->n.u1Present)
     
    34323432    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    34333433
     3434    Assert(pPGM->pGstPaePML4HC);
    34343435    if (pPGM->pGstPaePML4HC->a[iPml4e].n.u1Present)
    34353436    {
     
    34723473    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    34733474
     3475    Assert(pPGM->pGstPaePML4HC);
    34743476    if (pPGM->pGstPaePML4HC->a[iPml4e].n.u1Present)
    34753477    {
     
    35163518    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    35173519
     3520    Assert(pPGM->pGstPaePML4HC);
    35183521    *ppPml4e = &pPGM->pGstPaePML4HC->a[iPml4e];
    35193522    if ((*ppPml4e)->n.u1Present)
     
    35613564    const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    35623565
     3566    Assert(pPGM->pGstPaePML4HC);
    35633567    pPml4e = &pPGM->pGstPaePML4HC->a[iPml4e];
    35643568    if (pPml4e->n.u1Present)
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r10032 r10063  
    823823    PPGMPOOLPAGE   pShwPage;
    824824    int            rc;
    825     PGMPOOLKIND    enmPdpt, enmPd;
    826     unsigned       idxTopLevel;
    827 
    828     AssertReturn(pVM->pgm.s.pHCPaePML4, VERR_INTERNAL_ERROR);
    829     if (HWACCMIsNestedPagingActive(pVM))
    830     {
    831         enmPdpt     = PGMPOOLKIND_64BIT_PDPT_FOR_PHYS;
    832         enmPd       = PGMPOOLKIND_64BIT_PD_FOR_PHYS;
    833         idxTopLevel = PGMPOOL_IDX_NESTED_ROOT;
    834     }
    835     else
    836     {
    837         AssertReturn(pVM->pgm.s.pHCShwAmd64CR3, VERR_INTERNAL_ERROR);
    838 
    839         enmPdpt     = PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT;
    840         enmPd       = PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD;
    841         idxTopLevel = pVM->pgm.s.pHCShwAmd64CR3->idx;
    842     }
     825    bool           fNestedPaging = HWACCMIsNestedPagingActive(pVM);
    843826
    844827    Assert(pVM->pgm.s.pHCPaePML4);
     828
    845829    /* Allocate page directory pointer table if not present. */
    846830    pPml4e = &pPGM->pHCPaePML4->a[iPml4e];
     
    848832        &&  !(pPml4e->u & X86_PML4E_PG_MASK))
    849833    {
    850         PX86PML4E pPml4eGst = &pPGM->pGstPaePML4HC->a[iPml4e];
    851 
    852834        Assert(!(pPml4e->u & X86_PML4E_PG_MASK));
    853         rc = pgmPoolAlloc(pVM, pPml4eGst->u & X86_PML4E_PG_MASK, enmPdpt, idxTopLevel, iPml4e, &pShwPage);
     835
     836        if (!fNestedPaging)
     837        {
     838            Assert(pVM->pgm.s.pHCShwAmd64CR3);
     839            Assert(pPGM->pGstPaePML4HC);
     840
     841            PX86PML4E pPml4eGst = &pPGM->pGstPaePML4HC->a[iPml4e];
     842
     843            rc = pgmPoolAlloc(pVM, pPml4eGst->u & X86_PML4E_PG_MASK, PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e, &pShwPage);
     844        }
     845        else
     846            rc = pgmPoolAlloc(pVM, GCPtr + RT_BIT_64(63) /* hack: make the address unique */, PGMPOOLKIND_64BIT_PDPT_FOR_PHYS, PGMPOOL_IDX_NESTED_ROOT, iPml4e, &pShwPage);
     847
    854848        if (rc == VERR_PGM_POOL_FLUSHED)
    855849            return VINF_PGM_SYNC_CR3;
     
    874868        &&  !(pPdpe->u & X86_PDPE_PG_MASK))
    875869    {
    876         PX86PML4E pPml4eGst = &pPGM->pGstPaePML4HC->a[iPml4e];
    877         PX86PDPT  pPdptGst;
    878         rc = PGM_GCPHYS_2_PTR(pVM, pPml4eGst->u & X86_PML4E_PG_MASK, &pPdptGst);
    879         AssertRCReturn(rc, rc);
    880 
    881         Assert(!(pPdpe->u & X86_PDPE_PG_MASK));
    882         /* Create a reference back to the PDPT by using the index in its shadow page. */
    883         rc = pgmPoolAlloc(pVM, pPdptGst->a[iPdPt].u & X86_PDPE_PG_MASK, enmPd, pShwPage->idx, iPdPt, &pShwPage);
     870        if (!fNestedPaging)
     871        {
     872            Assert(pPGM->pGstPaePML4HC);
     873
     874            PX86PML4E pPml4eGst = &pPGM->pGstPaePML4HC->a[iPml4e];
     875            PX86PDPT  pPdptGst;
     876            rc = PGM_GCPHYS_2_PTR(pVM, pPml4eGst->u & X86_PML4E_PG_MASK, &pPdptGst);
     877            AssertRCReturn(rc, rc);
     878
     879            Assert(!(pPdpe->u & X86_PDPE_PG_MASK));
     880            /* Create a reference back to the PDPT by using the index in its shadow page. */
     881            rc = pgmPoolAlloc(pVM, pPdptGst->a[iPdPt].u & X86_PDPE_PG_MASK, PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD, pShwPage->idx, iPdPt, &pShwPage);
     882        }
     883        else
     884            rc = pgmPoolAlloc(pVM, GCPtr + RT_BIT_64(62) /* hack: make the address unique */, PGMPOOLKIND_64BIT_PD_FOR_PHYS, pShwPage->idx, iPdPt, &pShwPage);
     885
    884886        if (rc == VERR_PGM_POOL_FLUSHED)
    885887            return VINF_PGM_SYNC_CR3;
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r10013 r10063  
    26572657
    26582658    /* Virtual address = physical address */
    2659     GCPhys = GCPtrPage & X86_PAGE_4K_BASE_MASK_32;
     2659    GCPhys = GCPtrPage & X86_PAGE_4K_BASE_MASK;
    26602660# if PGM_SHW_TYPE == PGM_TYPE_AMD64
    26612661    rc = pgmPoolAlloc(pVM, GCPhys, BTH_PGMPOOLKIND_PT_FOR_PT, pShwPde->idx,    iPDDst, &pShwPage);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r10032 r10063  
    10561056        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    10571057        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1058         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    10591058            return true;
    10601059
     
    10791078                case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    10801079                case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1081                 case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    10821080                    return true;
    10831081                default:
     
    11051103                case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    11061104                case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1107                 case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    11081105                    return true;
    11091106                default:
     
    13301327                case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    13311328                case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1332                 case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    13331329                case PGMPOOLKIND_ROOT_NESTED:
    13341330                    break;
     
    13801376        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    13811377        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1382         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    13831378        case PGMPOOLKIND_ROOT_NESTED:
    13841379            /* Nothing to monitor here. */
     
    14661461        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    14671462        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    1468         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    14691463        case PGMPOOLKIND_ROOT_NESTED:
    14701464            /* Nothing to monitor here. */
     
    21592153        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    21602154        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    2161         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    21622155            return 8;
    21632156
     
    22032196        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    22042197        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    2205         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    22062198        case PGMPOOLKIND_ROOT_NESTED:
    22072199            /** @todo can we return 0? (nobody is calling this...) */
     
    32103202
    32113203        case PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4:
    3212         case PGMPOOLKIND_64BIT_PML4_FOR_PHYS:
    32133204            pgmPoolTrackDerefPML464Bit(pPool, pPage, (PX86PML4)pvShw);
    32143205            break;
     
    34833474     * Quietly reject any attempts at flushing the currently active shadow CR3 mapping
    34843475     */
    3485     if (    (   pPage->enmKind == PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4
    3486              || pPage->enmKind == PGMPOOLKIND_64BIT_PML4_FOR_PHYS)
     3476    if (    pPage->enmKind == PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4
    34873477        &&  PGMGetHyperCR3(CTXSUFF(pPool->pVM)) == pPage->Core.Key)
    34883478    {
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