VirtualBox

Changeset 13991 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Nov 10, 2008 10:36:38 AM (16 years ago)
Author:
vboxsync
Message:

#1865: More PGM cleanup.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r13969 r13991  
    6969*   Internal Functions                                                         *
    7070*******************************************************************************/
     71DECLINLINE(int) pgmShwGetLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PML4E *ppPml4e, PX86PDPT *ppPdpt, PX86PDPAE *ppPD);
     72DECLINLINE(int) pgmShwSyncLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
     73DECLINLINE(int) pgmShwGetEPTPDPtr(PVM pVM, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD);
     74DECLINLINE(int) pgmShwSyncPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
     75DECLINLINE(int) pgmShwGetPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD);
     76
    7177
    7278/*
     
    808814 * @param   pGstPdpe    Guest PDPT entry
    809815 * @param   ppPD        Receives address of page directory
    810  */
    811 VMMDECL(int) PGMShwSyncPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
     816 * @remarks Unused.
     817 */
     818DECLINLINE(int) pgmShwSyncPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
    812819{
    813820    PPGM           pPGM   = &pVM->pgm.s;
     
    845852    }
    846853    /* The PD was cached or created; hook it up now. */
    847     pPdpe->u |=    pShwPage->Core.Key
    848                 | (pGstPdpe->u & ~(X86_PDPE_PG_MASK | X86_PDPE_AVL_MASK | X86_PDPE_PCD | X86_PDPE_PWT));
     854    pPdpe->u |= pShwPage->Core.Key
     855             | (pGstPdpe->u & ~(X86_PDPE_PG_MASK | X86_PDPE_AVL_MASK | X86_PDPE_PCD | X86_PDPE_PWT));
    849856
    850857    *ppPD = (PX86PDPAE)PGMPOOL_PAGE_2_PTR(pVM, pShwPage);
     
    861868 * @param   ppPdpt      Receives address of pdpt
    862869 * @param   ppPD        Receives address of page directory
    863  */
    864 VMMDECL(int) PGMShwGetPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD)
     870 * @remarks Unused.
     871 */
     872DECLINLINE(int) pgmShwGetPAEPDPtr(PVM pVM, RTGCPTR GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD)
    865873{
    866874    PPGM           pPGM   = &pVM->pgm.s;
     
    902910 * @param   ppPD        Receives address of page directory
    903911 */
    904 VMMDECL(int) PGMShwSyncLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
    905 {
    906     PPGM           pPGM   = &pVM->pgm.s;
    907     const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    908     PPGMPOOL       pPool  = pPGM->CTX_SUFF(pPool);
    909     PX86PML4E      pPml4e;
     912DECLINLINE(int) pgmShwSyncLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
     913{
     914    PPGM           pPGM          = &pVM->pgm.s;
     915    PPGMPOOL       pPool         = pPGM->CTX_SUFF(pPool);
     916    const unsigned iPml4         = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
     917    PX86PML4E      pPml4e        = pgmShwGetLongModePML4EPtr(pPGM, iPml4);
     918    bool           fNestedPaging = HWACCMIsNestedPagingActive(pVM);
    910919    PPGMPOOLPAGE   pShwPage;
    911920    X86PML4E       Pml4eGst;
    912921    int            rc;
    913     bool           fNestedPaging = HWACCMIsNestedPagingActive(pVM);
    914 
    915     Assert(pVM->pgm.s.pHCPaePML4);
    916922
    917923    /* Allocate page directory pointer table if not present. */
    918     pPml4e = &pPGM->pHCPaePML4->a[iPml4e];
    919924    if (    !pPml4e->n.u1Present
    920925        &&  !(pPml4e->u & X86_PML4E_PG_MASK))
    921926    {
    922927        Assert(!(pPml4e->u & X86_PML4E_PG_MASK));
    923 
    924928        if (!fNestedPaging)
    925929        {
     
    928932             *        are fine.) */
    929933            Assert(pVM->pgm.s.pHCShwAmd64CR3);
    930             Pml4eGst.u = pgmGstGetLongModePML4E(&pVM->pgm.s, iPml4e);
     934            Pml4eGst.u = pgmGstGetLongModePML4E(&pVM->pgm.s, iPml4);
    931935
    932936            rc = pgmPoolAlloc(pVM, Pml4eGst.u & X86_PML4E_PG_MASK,
    933                               PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e, &pShwPage);
     937                              PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4, &pShwPage);
    934938        }
    935939        else
    936940            rc = pgmPoolAlloc(pVM, GCPtr + RT_BIT_64(63) /* hack: make the address unique */,
    937                               PGMPOOLKIND_64BIT_PDPT_FOR_PHYS, PGMPOOL_IDX_NESTED_ROOT, iPml4e, &pShwPage);
     941                              PGMPOOLKIND_64BIT_PDPT_FOR_PHYS, PGMPOOL_IDX_NESTED_ROOT, iPml4, &pShwPage);
    938942
    939943        if (rc == VERR_PGM_POOL_FLUSHED)
     
    967971            /** @todo why are we looking up the guest PDPTE here?  Isn't pGstPdpe
    968972             *        trustworthy? */
    969             Pml4eGst.u = pgmGstGetLongModePML4E(&pVM->pgm.s, iPml4e);
     973            Pml4eGst.u = pgmGstGetLongModePML4E(&pVM->pgm.s, iPml4);
    970974            PX86PDPT pPdptGst;
    971975            rc = PGM_GCPHYS_2_PTR(pVM, Pml4eGst.u & X86_PML4E_PG_MASK, &pPdptGst);
     
    10031007
    10041008/**
    1005  * Gets the SHADOW page directory pointer for the specified address.
     1009 * Gets the SHADOW page directory pointer for the specified address (long mode).
    10061010 *
    10071011 * @returns VBox status.
     
    10111015 * @param   ppPD        Receives address of page directory
    10121016 */
    1013 VMMDECL(int) PGMShwGetLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD)
    1014 {
    1015     PPGM           pPGM   = &pVM->pgm.s;
    1016     const unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    1017     PPGMPOOL       pPool  = pPGM->CTX_SUFF(pPool);
    1018     PX86PML4E      pPml4e;
    1019     PPGMPOOLPAGE   pShwPage;
    1020 
    1021     AssertReturn(pVM->pgm.s.pHCPaePML4, VERR_INTERNAL_ERROR);
    1022 
    1023     pPml4e = &pPGM->pHCPaePML4->a[iPml4e];
     1017DECLINLINE(int) pgmShwGetLongModePDPtr(PVM pVM, RTGCPTR64 GCPtr, PX86PML4E *ppPml4e, PX86PDPT *ppPdpt, PX86PDPAE *ppPD)
     1018{
     1019    PPGM            pPGM = &pVM->pgm.s;
     1020    const unsigned  iPml4 = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
     1021    PCX86PML4E      pPml4e = pgmShwGetLongModePML4EPtr(pPGM, iPml4);
     1022    AssertReturn(pPml4e, VERR_INTERNAL_ERROR);
     1023    if (ppPml4e)
     1024        *ppPml4e = (PX86PML4E)pPml4e;
    10241025    if (!pPml4e->n.u1Present)
    10251026        return VERR_PAGE_MAP_LEVEL4_NOT_PRESENT;
    10261027
    1027     pShwPage = pgmPoolGetPage(pPool, pPml4e->u & X86_PML4E_PG_MASK);
     1028    PPGMPOOL        pPool = pPGM->CTX_SUFF(pPool);
     1029    PPGMPOOLPAGE    pShwPage = pgmPoolGetPage(pPool, pPml4e->u & X86_PML4E_PG_MASK);
    10281030    AssertReturn(pShwPage, VERR_INTERNAL_ERROR);
    10291031
    1030     const unsigned iPdPt = (GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64;
    1031     PX86PDPT  pPdpt = (PX86PDPT)PGMPOOL_PAGE_2_PTR(pVM, pShwPage);
    1032     PX86PDPE  pPdpe = &pPdpt->a[iPdPt];
    1033 
    1034     *ppPdpt = pPdpt;
    1035     if (!pPdpe->n.u1Present)
     1032    const unsigned  iPdPt = (GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64;
     1033    PCX86PDPT       pPdpt = *ppPdpt = (PX86PDPT)PGMPOOL_PAGE_2_PTR(pVM, pShwPage);
     1034    if (!pPdpt->a[iPdPt].n.u1Present)
    10361035        return VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT;
    10371036
    1038     pShwPage = pgmPoolGetPage(pPool, pPdpe->u & X86_PDPE_PG_MASK);
     1037    pShwPage = pgmPoolGetPage(pPool, pPdpt->a[iPdPt].u & X86_PDPE_PG_MASK);
    10391038    AssertReturn(pShwPage, VERR_INTERNAL_ERROR);
    10401039
     
    10541053 * @param   ppPD        Receives address of page directory
    10551054 */
    1056 VMMDECL(int) PGMShwGetEPTPDPtr(PVM pVM, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD)
    1057 {
    1058     PPGM           pPGM   = &pVM->pgm.s;
    1059     const unsigned iPml4e = (GCPtr >> EPT_PML4_SHIFT) & EPT_PML4_MASK;
    1060     PPGMPOOL       pPool  = pPGM->CTX_SUFF(pPool);
    1061     PEPTPML4       pPml4  = (PEPTPML4)pPGM->pHCNestedRoot;
     1055DECLINLINE(int) pgmShwGetEPTPDPtr(PVM pVM, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD)
     1056{
     1057    PPGM           pPGM  = &pVM->pgm.s;
     1058    const unsigned iPml4 = (GCPtr >> EPT_PML4_SHIFT) & EPT_PML4_MASK;
     1059    PPGMPOOL       pPool = pPGM->CTX_SUFF(pPool);
     1060    PEPTPML4       pPml4;
    10621061    PEPTPML4E      pPml4e;
    10631062    PPGMPOOLPAGE   pShwPage;
     
    10651064
    10661065    Assert(HWACCMIsNestedPagingActive(pVM));
     1066
     1067# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_R0
     1068    rc = PGM_HCPHYS_2_PTR(pVM, pPGM->HCPhysNestedRoot, &pPml4);
     1069    AssertRCReturn(rc);
     1070# else
     1071    pPml4 = (PEPTPML4)pPGM->CTX_SUFF(pShwNestedRoot);
     1072# endif
    10671073    Assert(pPml4);
    10681074
    10691075    /* Allocate page directory pointer table if not present. */
    1070     pPml4e = &pPml4->a[iPml4e];
     1076    pPml4e = &pPml4->a[iPml4];
    10711077    if (    !pPml4e->n.u1Present
    10721078        &&  !(pPml4e->u & EPT_PML4E_PG_MASK))
     
    10741080        Assert(!(pPml4e->u & EPT_PML4E_PG_MASK));
    10751081
    1076         rc = pgmPoolAlloc(pVM, (GCPtr & EPT_PML4E_PG_MASK) + RT_BIT_64(63) /* hack: make the address unique */, PGMPOOLKIND_EPT_PDPT_FOR_PHYS, PGMPOOL_IDX_NESTED_ROOT, iPml4e, &pShwPage);
     1082        rc = pgmPoolAlloc(pVM, (GCPtr & EPT_PML4E_PG_MASK) + RT_BIT_64(63) /* hack: make the address unique */, PGMPOOLKIND_EPT_PDPT_FOR_PHYS, PGMPOOL_IDX_NESTED_ROOT, iPml4, &pShwPage);
    10771083        if (rc == VERR_PGM_POOL_FLUSHED)
    10781084        {
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r13937 r13991  
    170170#   endif
    171171
    172     rc = PGMShwSyncLongModePDPtr(pVM, pvFault, pPml4eSrc, &PdpeSrc, &pPDDst);
     172    rc = pgmShwSyncLongModePDPtr(pVM, pvFault, pPml4eSrc, &PdpeSrc, &pPDDst);
    173173    if (rc != VINF_SUCCESS)
    174174    {
     
    182182    PEPTPD          pPDDst;
    183183
    184     rc = PGMShwGetEPTPDPtr(pVM, pvFault, NULL, &pPDDst);
     184    rc = pgmShwGetEPTPDPtr(pVM, pvFault, NULL, &pPDDst);
    185185    if (rc != VINF_SUCCESS)
    186186    {
     
    910910# else /* PGM_SHW_TYPE == PGM_TYPE_AMD64 */
    911911    /* PML4 */
    912     AssertReturn(pVM->pgm.s.pHCPaePML4, VERR_INTERNAL_ERROR);
    913 
    914     const unsigned  iPml4e    = (GCPtrPage >> X86_PML4_SHIFT) & X86_PML4_MASK;
     912    AssertReturn(pVM->pgm.s.pShwPaePml4R3, VERR_INTERNAL_ERROR);
     913
     914    const unsigned  iPml4     = (GCPtrPage >> X86_PML4_SHIFT) & X86_PML4_MASK;
    915915    const unsigned  iPdpte    = (GCPtrPage >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64;
    916916    const unsigned  iPDDst    = (GCPtrPage >> SHW_PD_SHIFT) & SHW_PD_MASK;
    917917    PX86PDPAE       pPDDst;
    918918    PX86PDPT        pPdptDst;
    919     PX86PML4E       pPml4eDst = &pVM->pgm.s.pHCPaePML4->a[iPml4e];
    920     rc = PGMShwGetLongModePDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     919    PX86PML4E       pPml4eDst;
     920    rc = pgmShwGetLongModePDPtr(pVM, GCPtrPage, &pPml4eDst, &pPdptDst, &pPDDst);
    921921    if (rc != VINF_SUCCESS)
    922922    {
     
    10211021        LogFlow(("InvalidatePage: Out-of-sync PML4E (P/GCPhys) at %RGv GCPhys=%RGp vs %RGp Pml4eSrc=%RX64 Pml4eDst=%RX64\n",
    10221022                 GCPtrPage, pShwPdpt->GCPhys, GCPhysPdpt, (uint64_t)pPml4eSrc->u, (uint64_t)pPml4eDst->u));
    1023         pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e);
     1023        pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4);
    10241024        pPml4eDst->u = 0;
    10251025        STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat,InvalidatePagePDNPs));
     
    10351035        LogFlow(("InvalidatePage: Out-of-sync PML4E at %RGv Pml4eSrc=%RX64 Pml4eDst=%RX64\n",
    10361036                 GCPtrPage, (uint64_t)pPml4eSrc->u, (uint64_t)pPml4eDst->u));
    1037         pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e);
     1037        pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4);
    10381038        pPml4eDst->u = 0;
    10391039        STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat,InvalidatePagePDOutOfSync));
     
    10471047        LogFlow(("InvalidatePage: Out-of-sync PML4E (A) at %RGv Pml4eSrc=%RX64 Pml4eDst=%RX64\n",
    10481048                 GCPtrPage, (uint64_t)pPml4eSrc->u, (uint64_t)pPml4eDst->u));
    1049         pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e);
     1049        pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4);
    10501050        pPml4eDst->u = 0;
    10511051        STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat,InvalidatePagePDNAs));
     
    16021602    PX86PDPT        pPdptDst;
    16031603
    1604     int rc = PGMShwGetLongModePDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     1604    int rc = pgmShwGetLongModePDPtr(pVM, GCPtrPage, NULL, &pPdptDst, &pPDDst);
    16051605    AssertRCSuccessReturn(rc, rc);
    16061606    Assert(pPDDst && pPdptDst);
     
    18671867    PX86PDPT        pPdptDst;
    18681868
    1869     int rc = PGMShwGetLongModePDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     1869    int rc = pgmShwGetLongModePDPtr(pVM, GCPtrPage, NULL, &pPdptDst, &pPDDst);
    18701870    AssertRCSuccessReturn(rc, rc);
    18711871    Assert(pPDDst && pPdptDst);
     
    18761876    EPTPDE          PdeDst;
    18771877
    1878     int rc = PGMShwGetEPTPDPtr(pVM, GCPtrPage, NULL, &pPDDst);
     1878    int rc = pgmShwGetEPTPDPtr(pVM, GCPtrPage, NULL, &pPDDst);
    18791879    if (rc != VINF_SUCCESS)
    18801880    {
     
    23232323    PX86PDPAE       pPDDst;
    23242324    PX86PDPT        pPdptDst;
    2325     rc = PGMShwGetLongModePDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     2325    rc = pgmShwGetLongModePDPtr(pVM, GCPtrPage, NULL, &pPdptDst, &pPDDst);
    23262326    AssertRCSuccessReturn(rc, rc);
    23272327    Assert(pPDDst);
     
    27082708    PX86PDPAE       pPDDst;
    27092709    PX86PDPT        pPdptDst;
    2710     rc = PGMShwGetLongModePDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     2710    rc = pgmShwGetLongModePDPtr(pVM, GCPtrPage, NULL, &pPdptDst, &pPDDst);
    27112711    AssertRCSuccessReturn(rc, rc);
    27122712    Assert(pPDDst);
     
    27212721    PEPTPDPT        pPdptDst;
    27222722
    2723     rc = PGMShwGetEPTPDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
     2723    rc = pgmShwGetEPTPDPtr(pVM, GCPtrPage, &pPdptDst, &pPDDst);
    27242724    if (rc != VINF_SUCCESS)
    27252725    {
     
    28632863#  endif
    28642864
    2865         int rc = PGMShwSyncLongModePDPtr(pVM, GCPtrPage, pPml4eSrc, &PdpeSrc, &pPDDst);
     2865        int rc = pgmShwSyncLongModePDPtr(pVM, GCPtrPage, pPml4eSrc, &PdpeSrc, &pPDDst);
    28662866        if (rc != VINF_SUCCESS)
    28672867        {
     
    29832983#  endif
    29842984
    2985     rc = PGMShwSyncLongModePDPtr(pVM, GCPtrPage, pPml4eSrc, &PdpeSrc, &pPDDst);
     2985    rc = pgmShwSyncLongModePDPtr(pVM, GCPtrPage, pPml4eSrc, &PdpeSrc, &pPDDst);
    29862986    if (rc != VINF_SUCCESS)
    29872987    {
     
    31893189    }
    31903190#  if PGM_GST_TYPE == PGM_TYPE_AMD64
    3191     for (uint64_t iPml4e = 0; iPml4e < X86_PG_PAE_ENTRIES; iPml4e++)
     3191    for (uint64_t iPml4 = 0; iPml4 < X86_PG_PAE_ENTRIES; iPml4++)
    31923192    {
    31933193        PPGMPOOLPAGE pShwPdpt = NULL;
     
    31953195        RTGCPHYS     GCPhysPdptSrc;
    31963196
    3197         pPml4eSrc     = &pVM->pgm.s.CTXSUFF(pGstPaePML4)->a[iPml4e];
    3198         pPml4eDst     = &pVM->pgm.s.CTXMID(p,PaePML4)->a[iPml4e];
     3197        pPml4eSrc     = &pVM->pgm.s.CTXSUFF(pGstPaePML4)->a[iPml4];
     3198        pPml4eDst     = &pVM->pgm.s.CTXMID(p,PaePML4)->a[iPml4];
    31993199
    32003200        /* Fetch the pgm pool shadow descriptor if the shadow pml4e is present. */
     
    32113211            /* Free it. */
    32123212            LogFlow(("SyncCR3: Out-of-sync PML4E (GCPhys) GCPtr=%RX64 %RGp vs %RGp PdpeSrc=%RX64 PdpeDst=%RX64\n",
    3213                      (uint64_t)iPml4e << X86_PML4_SHIFT, pShwPdpt->GCPhys, GCPhysPdptSrc, (uint64_t)pPml4eSrc->u, (uint64_t)pPml4eDst->u));
    3214             pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4e);
     3213                     (uint64_t)iPml4 << X86_PML4_SHIFT, pShwPdpt->GCPhys, GCPhysPdptSrc, (uint64_t)pPml4eSrc->u, (uint64_t)pPml4eDst->u));
     3214            pgmPoolFreeByPage(pPool, pShwPdpt, pVM->pgm.s.pHCShwAmd64CR3->idx, iPml4);
    32153215            pPml4eDst->u = 0;
    32163216            continue;
     
    32653265            PX86PDPAE       pPDDst;
    32663266            PX86PDEPAE      pPDEDst;
    3267             RTGCPTR         GCPtr   = (iPml4e << X86_PML4_SHIFT) || (iPdpte << X86_PDPT_SHIFT);
     3267            RTGCPTR         GCPtr   = (iPml4 << X86_PML4_SHIFT) || (iPdpte << X86_PDPT_SHIFT);
    32683268            PGSTPD          pPDSrc  = pgmGstGetLongModePDPtr(&pVM->pgm.s, GCPtr, &pPml4eSrc, &PdpeSrc, &iPDSrc);
    32693269
    3270             int rc = PGMShwGetLongModePDPtr(pVM, GCPtr, &pPdptDst, &pPDDst);
     3270            int rc = pgmShwGetLongModePDPtr(pVM, GCPtr, NULL, &pPdptDst, &pPDDst);
    32713271            if (rc != VINF_SUCCESS)
    32723272            {
     
    32963296                /* Free it. */
    32973297                LogFlow(("SyncCR3: Out-of-sync PDPE (GCPhys) GCPtr=%RX64 %RGp vs %RGp PdpeSrc=%RX64 PdpeDst=%RX64\n",
    3298                         ((uint64_t)iPml4e << X86_PML4_SHIFT) + ((uint64_t)iPdpte << X86_PDPT_SHIFT), pShwPde->GCPhys, GCPhysPdeSrc, (uint64_t)PdpeSrc.u, (uint64_t)pPdpeDst->u));
     3298                        ((uint64_t)iPml4 << X86_PML4_SHIFT) + ((uint64_t)iPdpte << X86_PDPT_SHIFT), pShwPde->GCPhys, GCPhysPdeSrc, (uint64_t)PdpeSrc.u, (uint64_t)pPdpeDst->u));
    32993299
    33003300                /* Mark it as not present if there's no hypervisor mapping present. (bit flipped at the top of Trap0eHandler) */
     
    37003700
    37013701# if PGM_GST_TYPE == PGM_TYPE_AMD64
    3702     unsigned iPml4e = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    3703 
    3704     for (; iPml4e < X86_PG_PAE_ENTRIES; iPml4e++)
     3702    unsigned iPml4 = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
     3703
     3704    for (; iPml4 < X86_PG_PAE_ENTRIES; iPml4++)
    37053705    {
    37063706        PPGMPOOLPAGE    pShwPdpt = NULL;
     
    37093709        RTGCPHYS        GCPhysPdptSrc;
    37103710
    3711         pPml4eSrc     = pgmGstGetLongModePML4EPtr(&pVM->pgm.s, iPml4e);
    3712         pPml4eDst     = &pVM->pgm.s.CTXMID(p,PaePML4)->a[iPml4e];
     3711        pPml4eSrc     = pgmGstGetLongModePML4EPtr(&pVM->pgm.s, iPml4);
     3712        pPml4eDst     = pgmShwGetLongModePML4EPtr(&pVM->pgm.s, iPml4);
    37133713
    37143714        /* Fetch the pgm pool shadow descriptor if the shadow pml4e is present. */
     
    37363736        if (GCPhysPdptSrc != pShwPdpt->GCPhys)
    37373737        {
    3738             AssertMsgFailed(("Physical address doesn't match! iPml4e %d pPml4eDst.u=%#RX64 pPml4eSrc.u=%RX64 Phys %RX64 vs %RX64\n", iPml4e, pPml4eDst->u, pPml4eSrc->u, pShwPdpt->GCPhys, GCPhysPdptSrc));
     3738            AssertMsgFailed(("Physical address doesn't match! iPml4 %d pPml4eDst.u=%#RX64 pPml4eSrc.u=%RX64 Phys %RX64 vs %RX64\n", iPml4, pPml4eDst->u, pPml4eSrc->u, pShwPdpt->GCPhys, GCPhysPdptSrc));
    37393739            GCPtr += _2M * UINT64_C(512) * UINT64_C(512);
    37403740            cErrors++;
     
    37793779            PGSTPD          pPDSrc    = pgmGstGetLongModePDPtr(&pVM->pgm.s, GCPtr, &pPml4eSrc, &PdpeSrc, &iPDSrc);
    37803780
    3781             rc = PGMShwGetLongModePDPtr(pVM, GCPtr, &pPdptDst, &pPDDst);
     3781            rc = pgmShwGetLongModePDPtr(pVM, GCPtr, NULL, &pPdptDst, &pPDDst);
    37823782            if (rc != VINF_SUCCESS)
    37833783            {
     
    38123812            {
    38133813#  if PGM_GST_TYPE == PGM_TYPE_AMD64
    3814                 AssertMsgFailed(("Physical address doesn't match! iPml4e %d iPdpte %d pPdpeDst.u=%#RX64 pPdpeSrc.u=%RX64 Phys %RX64 vs %RX64\n", iPml4e, iPdpte, pPdpeDst->u, PdpeSrc.u, pShwPde->GCPhys, GCPhysPdeSrc));
     3814                AssertMsgFailed(("Physical address doesn't match! iPml4 %d iPdpte %d pPdpeDst.u=%#RX64 pPdpeSrc.u=%RX64 Phys %RX64 vs %RX64\n", iPml4, iPdpte, pPdpeDst->u, PdpeSrc.u, pShwPde->GCPhys, GCPhysPdeSrc));
    38153815#  else
    38163816                AssertMsgFailed(("Physical address doesn't match! iPdpte %d pPdpeDst.u=%#RX64 pPdpeSrc.u=%RX64 Phys %RX64 vs %RX64\n", iPdpte, pPdpeDst->u, PdpeSrc.u, pShwPde->GCPhys, GCPhysPdeSrc));
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r13937 r13991  
    520520                        pgmPoolFreeByPage(pPool, pVM->pgm.s.pHCShwAmd64CR3, PGMPOOL_IDX_AMD64_CR3, pVM->pgm.s.pHCShwAmd64CR3->GCPhys >> PAGE_SHIFT);
    521521                    pVM->pgm.s.pHCShwAmd64CR3 = 0;
    522                     pVM->pgm.s.pHCPaePML4     = 0;
     522                    pVM->pgm.s.pShwPaePml4R3  = 0;
     523#  ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
     524                    pVM->pgm.s.pShwPaePml4R0  = 0;
     525#  endif
    523526                    pVM->pgm.s.HCPhysPaePML4  = 0;
    524527                }
     
    535538                    goto l_try_again;
    536539                }
    537                 pVM->pgm.s.pHCPaePML4    = (PX86PML4)PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pVM->pgm.s.pHCShwAmd64CR3);
     540                pVM->pgm.s.pShwPaePml4R3 = (R3PTRTYPE(PX86PML4))PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pVM->pgm.s.pHCShwAmd64CR3);
     541#  ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
     542                pVM->pgm.s.pShwPaePml4R0 = (R0PTRTYPE(PX86PML4))PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pVM->pgm.s.pHCShwAmd64CR3);
     543#  endif
    538544                pVM->pgm.s.HCPhysPaePML4 = pVM->pgm.s.pHCShwAmd64CR3->Core.Key;
    539545            }
     
    595601    if (!HWACCMIsNestedPagingActive(pVM))
    596602    {
    597         pVM->pgm.s.pHCPaePML4    = 0;
     603        pVM->pgm.s.pShwPaePml4R3 = 0;
     604# ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
     605        pVM->pgm.s.pShwPaePml4R0 = 0;
     606# endif
    598607        pVM->pgm.s.HCPhysPaePML4 = 0;
    599608        if (pVM->pgm.s.pHCShwAmd64CR3)
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r13823 r13991  
    149149
    150150    /* PML4 */
    151     const unsigned  iPml4  = ((RTGCUINTPTR64)GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    152     X86PML4E Pml4e = CTXMID(pVM->pgm.s.p,PaePML4)->a[iPml4];
     151    X86PML4E        Pml4e;
     152    Pml4e.u = pgmShwGetLongModePML4E(&pVM->pgm.s, GCPtr);
    153153    if (!Pml4e.n.u1Present)
    154154        return VERR_PAGE_TABLE_NOT_PRESENT;
     
    189189    EPTPDE          Pde;
    190190
    191     int rc = PGMShwGetEPTPDPtr(pVM, GCPtr, NULL, &pPDDst);
     191    int rc = pgmShwGetEPTPDPtr(pVM, GCPtr, NULL, &pPDDst);
    192192    if (rc != VINF_SUCCESS)
    193193    {
     
    296296        X86PDEPAE       Pde;
    297297        /* PML4 */
    298         const unsigned  iPml4  = ((RTGCUINTPTR64)GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    299         X86PML4E        Pml4e = CTXMID(pVM->pgm.s.p,PaePML4)->a[iPml4];
     298        X86PML4E        Pml4e;
     299        Pml4e.u = pgmShwGetLongModePML4E(&pVM->pgm.s, GCPtr);
    300300        if (!Pml4e.n.u1Present)
    301301            return VERR_PAGE_TABLE_NOT_PRESENT;
     
    329329        EPTPDE          Pde;
    330330
    331         rc = PGMShwGetEPTPDPtr(pVM, GCPtr, NULL, &pPDDst);
     331        rc = pgmShwGetEPTPDPtr(pVM, GCPtr, NULL, &pPDDst);
    332332        if (rc != VINF_SUCCESS)
    333333        {
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