VirtualBox

Ignore:
Timestamp:
Nov 28, 2008 1:21:42 AM (16 years ago)
Author:
vboxsync
Message:

#1865: PGMAllPool: Fixes for non-contiguous mapping of the fake 2048 entry PAE PD (R0 darwin only).

File:
1 edited

Legend:

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

    r14749 r14751  
    308308            PX86PML4    pPML4;
    309309        } uShw;
    310         uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    311310
    312311        switch (pPage->enmKind)
     
    314313            case PGMPOOLKIND_32BIT_PT_FOR_32BIT_PT:
    315314            {
     315                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    316316                const unsigned iShw = off / sizeof(X86PTE);
    317317                if (uShw.pPT->a[iShw].n.u1Present)
     
    331331            /* page/2 sized */
    332332            case PGMPOOLKIND_PAE_PT_FOR_32BIT_PT:
     333                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    333334                if (!((off ^ pPage->GCPhys) & (PAGE_SIZE / 2)))
    334335                {
     
    350351            case PGMPOOLKIND_PAE_PT_FOR_PAE_PT:
    351352            {
     353                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    352354                const unsigned iShw = off / sizeof(X86PTEPAE);
    353355                if (uShw.pPTPae->a[iShw].n.u1Present)
     
    389391            case PGMPOOLKIND_ROOT_32BIT_PD:
    390392            {
     393                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    391394                const unsigned iShw = off / sizeof(X86PTE);         // ASSUMING 32-bit guest paging!
    392395                if (uShw.pPD->a[iShw].u & PGM_PDFLAGS_MAPPING)
     
    428431            case PGMPOOLKIND_ROOT_PAE_PD:
    429432            {
    430                 unsigned iShw = (off / sizeof(X86PTE)) * 2;   // ASSUMING 32-bit guest paging!
     433                unsigned iGst     = off / sizeof(X86PTE);           // ASSUMING 32-bit guest paging!
     434                unsigned iShwPdpt = iGst & 3;
     435                unsigned iShw     = iGst / 4;
     436                Assert(pPage->idx == PGMPOOL_IDX_PAE_PD);
     437                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage + 1 + iShwPdpt);
    431438                for (unsigned i = 0; i < 2; i++, iShw++)
    432439                {
     
    435442                        Assert(pgmMapAreMappingsEnabled(&pPool->CTX_SUFF(pVM)->pgm.s));
    436443                        VM_FF_SET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3);
    437                         LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShw=%#x!\n", iShw));
     444                        LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShwPdpt=%#x iShw=%#x!\n", iShwPdpt, iShw));
    438445                    }
    439446                    /* paranoia / a bit assumptive. */
     
    443450                    {
    444451                        const unsigned iShw2 = iShw + 2;
    445                         if (    iShw2 < RT_ELEMENTS(uShw.pPDPae->a)
     452                        if (    iShw2 < RT_ELEMENTS(uShw.pPDPae->a) /** @todo was completely wrong, it's better now after #1865 but still wrong from cross PD. */
    446453                            &&  (uShw.pPDPae->a[iShw2].u & (PGM_PDFLAGS_MAPPING | X86_PDE_P)) == (PGM_PDFLAGS_MAPPING | X86_PDE_P))
    447454                        {
    448455                            Assert(pgmMapAreMappingsEnabled(&pPool->CTX_SUFF(pVM)->pgm.s));
    449456                            VM_FF_SET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3);
    450                             LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShw2=%#x!\n", iShw2));
     457                            LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShwPdpt=%#x iShw2=%#x!\n", iShwPdpt, iShw2));
    451458                        }
    452459                    }
     
    455462                        &&  !VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3))
    456463                    {
    457                         LogFlow(("pgmPoolMonitorChainChanging: iShw=%#x: %RX64 -> freeing it!\n", iShw, uShw.pPDPae->a[iShw].u));
     464                        LogFlow(("pgmPoolMonitorChainChanging: iShwPdpt=%#x iShw=%#x: %RX64 -> freeing it!\n", iShwPdpt, iShw, uShw.pPDPae->a[iShw].u));
    458465# ifdef IN_RC           /* TLB load - we're pushing things a bit... */
    459466                        ASMProbeReadByte(pvAddress);
    460467# endif
    461                         pgmPoolFree(pPool->CTX_SUFF(pVM), uShw.pPDPae->a[iShw].u & X86_PDE_PAE_PG_MASK, pPage->idx, iShw);
     468                        pgmPoolFree(pPool->CTX_SUFF(pVM), uShw.pPDPae->a[iShw].u & X86_PDE_PAE_PG_MASK, pPage->idx, iShw + iShwPdpt * X86_PG_PAE_ENTRIES);
    462469                        uShw.pPDPae->a[iShw].u = 0;
    463470                    }
     
    469476            case PGMPOOLKIND_PAE_PD_FOR_PAE_PD:
    470477            {
     478                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    471479                const unsigned iShw = off / sizeof(X86PDEPAE);
    472480                if (uShw.pPDPae->a[iShw].u & PGM_PDFLAGS_MAPPING)
     
    534542                 * - messing with the bits of pd pointers without changing the physical address
    535543                 */
     544                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    536545                const unsigned iShw = off / sizeof(X86PDPE);
    537546                if (iShw < X86_PG_PAE_PDPE_ENTRIES)          /* don't use RT_ELEMENTS(uShw.pPDPT->a), because that's for long mode only */
     
    567576                Assert(pPage->enmKind == PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD);
    568577
     578                uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    569579                const unsigned iShw = off / sizeof(X86PDEPAE);
    570580                if (uShw.pPDPae->a[iShw].u & PGM_PDFLAGS_MAPPING)
     
    623633                if (!VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3))
    624634                {
     635                    uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    625636                    const unsigned iShw = off / sizeof(X86PDPE);
    626637                    if (uShw.pPDPT->a[iShw].n.u1Present)
     
    655666                if (!VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3))
    656667                {
     668                    uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);
    657669                    const unsigned iShw = off / sizeof(X86PDPE);
    658670                    if (uShw.pPML4->a[iShw].n.u1Present)
     
    27122724    Assert(pUser->iUser != NIL_PGMPOOL_IDX);
    27132725    Assert(pUser->iUser < pPool->cCurPages);
     2726    uint32_t iUserTable = pUser->iUserTable;
    27142727
    27152728    /*
     
    27172730     */
    27182731    PPGMPOOLPAGE pUserPage = &pPool->aPages[pUser->iUser];
     2732#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
     2733    if (pUserPage->enmKind == PGMPOOLKIND_ROOT_PAE_PD)
     2734    {
     2735        /* Must translate the fake 2048 entry PD to a 512 PD one since the R0 mapping is not linear. */
     2736        Assert(pUser->iUser == PGMPOOL_IDX_PAE_PD);
     2737        uint32_t iPdpt = iUserTable / X86_PG_PAE_ENTRIES;
     2738        iUserTable    %= X86_PG_PAE_ENTRIES;
     2739        pUserPage      = &pPool->aPages[PGMPOOL_IDX_PAE_PD_0 + iPdpt];
     2740        Assert(pUserPage->enmKind == PGMPOOLKIND_PAE_PD_FOR_PAE_PD);
     2741    }
     2742#endif
    27192743    union
    27202744    {
     
    27342758    {
    27352759        case PGMPOOLKIND_ROOT_32BIT_PD:
    2736             Assert(pUser->iUserTable < X86_PG_ENTRIES);
    2737             Assert(!(u.pau32[pUser->iUserTable] & PGM_PDFLAGS_MAPPING));
     2760            Assert(iUserTable < X86_PG_ENTRIES);
     2761            Assert(!(u.pau32[iUserTable] & PGM_PDFLAGS_MAPPING));
    27382762            break;
     2763# ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    27392764        case PGMPOOLKIND_ROOT_PAE_PD:
    2740             Assert(pUser->iUserTable < 2048 && pUser->iUser == PGMPOOL_IDX_PAE_PD);
    2741             AssertMsg(!(u.pau64[pUser->iUserTable] & PGM_PDFLAGS_MAPPING), ("%llx %d\n", u.pau64[pUser->iUserTable], pUser->iUserTable));
     2765            Assert(iUserTable < 2048 && pUser->iUser == PGMPOOL_IDX_PAE_PD);
     2766            AssertMsg(!(u.pau64[iUserTable] & PGM_PDFLAGS_MAPPING), ("%llx %d\n", u.pau64[iUserTable], iUserTable));
    27422767            break;
     2768# endif
    27432769        case PGMPOOLKIND_ROOT_PDPT:
    2744             Assert(pUser->iUserTable < 4);
    2745             Assert(!(u.pau64[pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));
     2770            Assert(iUserTable < 4);
     2771            Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT));
    27462772            break;
    27472773        case PGMPOOLKIND_PAE_PD_FOR_32BIT_PD:
    27482774        case PGMPOOLKIND_PAE_PD_FOR_PAE_PD:
    2749             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
     2775            Assert(iUserTable < X86_PG_PAE_ENTRIES);
    27502776            break;
    27512777        case PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD:
    2752             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
    2753             Assert(!(u.pau64[pUser->iUserTable] & PGM_PDFLAGS_MAPPING));
     2778            Assert(iUserTable < X86_PG_PAE_ENTRIES);
     2779            Assert(!(u.pau64[iUserTable] & PGM_PDFLAGS_MAPPING));
    27542780            break;
    27552781        case PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT:
    2756             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
    2757             Assert(!(u.pau64[pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));
     2782            Assert(iUserTable < X86_PG_PAE_ENTRIES);
     2783            Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT));
    27582784            break;
    27592785        case PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4:
    2760             Assert(!(u.pau64[pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));
     2786            Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT));
    27612787            /* GCPhys >> PAGE_SHIFT is the index here */
    27622788            break;
    27632789        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    27642790        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
    2765             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
     2791            Assert(iUserTable < X86_PG_PAE_ENTRIES);
    27662792            break;
    27672793
    27682794        case PGMPOOLKIND_EPT_PDPT_FOR_PHYS:
    27692795        case PGMPOOLKIND_EPT_PD_FOR_PHYS:
    2770             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
     2796            Assert(iUserTable < X86_PG_PAE_ENTRIES);
    27712797            break;
    27722798
    27732799        case PGMPOOLKIND_ROOT_NESTED:
    2774             Assert(pUser->iUserTable < X86_PG_PAE_ENTRIES);
     2800            Assert(iUserTable < X86_PG_PAE_ENTRIES);
    27752801            break;
    27762802
     
    27882814        /* 32-bit entries */
    27892815        case PGMPOOLKIND_ROOT_32BIT_PD:
    2790             u.pau32[pUser->iUserTable] = 0;
     2816            u.pau32[iUserTable] = 0;
    27912817            break;
    27922818
     
    27992825        case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS:
    28002826        case PGMPOOLKIND_64BIT_PD_FOR_PHYS:
     2827#ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    28012828        case PGMPOOLKIND_ROOT_PAE_PD:
     2829#endif
    28022830        case PGMPOOLKIND_ROOT_PDPT:
    28032831        case PGMPOOLKIND_ROOT_NESTED:
    28042832        case PGMPOOLKIND_EPT_PDPT_FOR_PHYS:
    28052833        case PGMPOOLKIND_EPT_PD_FOR_PHYS:
    2806             u.pau64[pUser->iUserTable] = 0;
     2834            u.pau64[iUserTable] = 0;
    28072835            break;
    28082836
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