VirtualBox

儲存庫 vbox 的更動 16840


忽略:
時間撮記:
2009-2-17 下午01:26:14 (16 年 以前)
作者:
vboxsync
訊息:

VBOX_WITH_PGMPOOL_PAGING_ONLY: updates for raw mode

位置:
trunk/src/VBox/VMM
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/VMM/PGMInternal.h

    r16626 r16840  
    29792979
    29802980#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    2981 void            pgmMapClearShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iOldPDE);
     2981void            pgmMapClearShadowPDEs(PVM pVM, PPGMPOOLPAGE pShwPageCR3, PPGMMAPPING pMap, unsigned iOldPDE);
    29822982void            pgmMapSetShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iNewPDE);
     2983int             pgmMapDeactivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3);
    29832984#endif
    29842985
     
    42904291}
    42914292
     4293/**
     4294 * Gets the shadow page directory for the specified address, PAE.
     4295 *
     4296 * @returns Pointer to the shadow PD.
     4297 * @param   pPGM        Pointer to the PGM instance data.
     4298 * @param   GCPtr       The address.
     4299 */
     4300DECLINLINE(PX86PDPAE) pgmShwGetPaePDPtr(PPGM pPGM, PX86PDPT pPdpt, RTGCPTR GCPtr)
     4301{
     4302#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     4303    const unsigned  iPdpt = (GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE;
     4304
     4305    if (!pPdpt->a[iPdpt].n.u1Present)
     4306        return NULL;
     4307
     4308    /* Fetch the pgm pool shadow descriptor. */
     4309    PPGMPOOLPAGE    pShwPde = pgmPoolGetPageByHCPhys(PGM2VM(pPGM), pPdpt->a[iPdpt].u & X86_PDPE_PG_MASK);
     4310    AssertReturn(pShwPde, NULL);
     4311
     4312    return (PX86PDPAE)PGMPOOL_PAGE_2_PTR_BY_PGM(pPGM, pShwPde);
     4313#else
     4314    AssertFailed();
     4315    return NULL;
     4316#endif
     4317}
    42924318
    42934319/**
  • trunk/src/VBox/VMM/PGMMap.cpp

    r16413 r16840  
    929929
    930930#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    931     pgmMapClearShadowPDEs(pVM, pMap, iOldPDE);
     931    pgmMapClearShadowPDEs(pVM, pVM->pgm.s.CTX_SUFF(pShwPageCR3), pMap, iOldPDE);
    932932#endif
    933933
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r16800 r16840  
    46334633     * Update the shadow root page as well since that's not fixed.
    46344634     */
    4635     PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
    4636     if (pVM->pgm.s.CTX_SUFF(pShwPageCR3))
    4637     {
    4638         /* Remove the hypervisor mappings from the shadow page table. */
    4639         PGMMapDeactivateAll(pVM);
    4640 
    4641         /* It might have been freed already by a pool flush (see e.g. PGMR3MappingsUnfix). */
    4642         /** @todo Coordinate this better with the pool. */
    4643         if (pVM->pgm.s.CTX_SUFF(pShwPageCR3)->enmKind != PGMPOOLKIND_FREE)
    4644             pgmPoolFreeByPage(pPool, pVM->pgm.s.CTX_SUFF(pShwPageCR3), pVM->pgm.s.iShwUser, pVM->pgm.s.iShwUserTable);
    4645         pVM->pgm.s.pShwPageCR3R3 = 0;
    4646         pVM->pgm.s.pShwPageCR3RC = 0;
    4647         pVM->pgm.s.pShwPageCR3R0 = 0;
    4648         pVM->pgm.s.pShwRootR3    = 0;
    4649 #  ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
    4650         pVM->pgm.s.pShwRootR0    = 0;
    4651 #  endif
    4652         pVM->pgm.s.HCPhysShwCR3  = 0;
    4653         pVM->pgm.s.iShwUser      = 0;
    4654         pVM->pgm.s.iShwUserTable = 0;
    4655     }
     4635    PPGMPOOL     pPool             = pVM->pgm.s.CTX_SUFF(pPool);
     4636    PPGMPOOLPAGE pOldShwPageCR3    = pVM->pgm.s.CTX_SUFF(pShwPageCR3);
     4637    uint32_t     iOldShwUserTable  = pVM->pgm.s.iShwUserTable;
     4638    uint32_t     iOldShwUser       = pVM->pgm.s.iShwUser;
    46564639
    46574640    Assert(!(GCPhysCR3 >> (PAGE_SHIFT + 32)));
    4658     pVM->pgm.s.iShwUser      = SHW_POOL_ROOT_IDX;
    4659     pVM->pgm.s.iShwUserTable = GCPhysCR3 >> PAGE_SHIFT;
    4660     rc = pgmPoolAlloc(pVM, GCPhysCR3 & GST_CR3_PAGE_MASK, BTH_PGMPOOLKIND_ROOT, pVM->pgm.s.iShwUser, pVM->pgm.s.iShwUserTable, &pVM->pgm.s.CTX_SUFF(pShwPageCR3));
     4641    rc = pgmPoolAlloc(pVM, GCPhysCR3 & GST_CR3_PAGE_MASK, BTH_PGMPOOLKIND_ROOT, SHW_POOL_ROOT_IDX, GCPhysCR3 >> PAGE_SHIFT, &pVM->pgm.s.CTX_SUFF(pShwPageCR3));
    46614642    if (rc == VERR_PGM_POOL_FLUSHED)
    46624643    {
     
    46664647    }
    46674648    AssertRCReturn(rc, rc);
     4649    pVM->pgm.s.iShwUser      = SHW_POOL_ROOT_IDX;
     4650    pVM->pgm.s.iShwUserTable = GCPhysCR3 >> PAGE_SHIFT;
    46684651#  ifdef IN_RING0
    46694652    pVM->pgm.s.pShwPageCR3R3 = MMHyperCCToR3(pVM, pVM->pgm.s.CTX_SUFF(pShwPageCR3));
     
    46834666    pVM->pgm.s.HCPhysShwCR3  = pVM->pgm.s.CTX_SUFF(pShwPageCR3)->Core.Key;
    46844667
     4668#  ifndef PGM_WITHOUT_MAPPINGS
    46854669    /* Apply all hypervisor mappings to the new CR3. */
    46864670    rc = PGMMapActivateAll(pVM);
     4671    AssertRC(rc);
     4672#  endif
     4673    /* Clean up the old CR3 root. */
     4674    if (pOldShwPageCR3)
     4675    {
     4676#  ifndef PGM_WITHOUT_MAPPINGS
     4677        /* Remove the hypervisor mappings from the shadow page table. */
     4678        pgmMapDeactivateCR3(pVM, pOldShwPageCR3);
     4679#  endif
     4680        /* It might have been freed already by a pool flush (see e.g. PGMR3MappingsUnfix). */
     4681        /** @todo Coordinate this better with the pool. */
     4682        if (pOldShwPageCR3->enmKind != PGMPOOLKIND_FREE)
     4683            pgmPoolFreeByPage(pPool, pOldShwPageCR3, iOldShwUser, iOldShwUserTable);
     4684    }
     4685
    46874686# endif
    46884687#endif /* VBOX_WITH_PGMPOOL_PAGING_ONLY */
     
    47544753#endif
    47554754
    4756 #ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     4755#if defined(VBOX_WITH_PGMPOOL_PAGING_ONLY) && !defined(IN_RC) /* In RC we rely on MapCR3 to do the shadow part for us at a safe time */
    47574756    /* Update shadow paging info. */
    4758 # if  (   (   PGM_SHW_TYPE == PGM_TYPE_32BIT \
     4757# if  (   (   PGM_SHW_TYPE == PGM_TYPE_32BIT  \
    47594758           || PGM_SHW_TYPE == PGM_TYPE_PAE    \
    47604759           || PGM_SHW_TYPE == PGM_TYPE_AMD64) \
     
    47644763    Assert(!HWACCMIsNestedPagingActive(pVM));
    47654764
    4766     /* @todo: dangerous as it's the current CR3! */
     4765# ifndef PGM_WITHOUT_MAPPINGS
    47674766    /* Remove the hypervisor mappings from the shadow page table. */
    47684767    PGMMapDeactivateAll(pVM);
     4768# endif
    47694769
    47704770    pVM->pgm.s.pShwRootR3 = 0;
     
    47834783    }
    47844784# endif
    4785 #endif /* VBOX_WITH_PGMPOOL_PAGING_ONLY */
     4785#endif /* VBOX_WITH_PGMPOOL_PAGING_ONLY && !IN_RC*/
    47864786
    47874787    return rc;
  • trunk/src/VBox/VMM/VMMAll/PGMAllMap.cpp

    r16797 r16840  
    209209
    210210
     211#ifndef IN_RING0
    211212/**
    212213 * Sets all PDEs involved with the mapping in the shadow page table.
     
    313314 *
    314315 * @param   pVM         The VM handle.
     316 * @param   pShwPageCR3 CR3 root page
    315317 * @param   pMap        Pointer to the mapping in question.
    316318 * @param   iOldPDE     The index of the 32-bit PDE corresponding to the base of the mapping.
    317319 */
    318 void pgmMapClearShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iOldPDE)
    319 {
    320     unsigned i = pMap->cPTs;
    321     PGMMODE  enmShadowMode = PGMGetShadowMode(pVM);
     320void pgmMapClearShadowPDEs(PVM pVM, PPGMPOOLPAGE pShwPageCR3, PPGMMAPPING pMap, unsigned iOldPDE)
     321{
     322    Assert(pShwPageCR3);
    322323
    323324    if (!pgmMapAreMappingsEnabled(&pVM->pgm.s))
     
    329330#endif
    330331
     332    unsigned i = pMap->cPTs;
     333    PGMMODE  enmShadowMode = PGMGetShadowMode(pVM);
     334
    331335    iOldPDE += i;
    332336    while (i-- > 0)
     
    338342            case PGMMODE_32_BIT:
    339343            {
    340                 PX86PD pShw32BitPd = pgmShwGet32BitPDPtr(&pVM->pgm.s);
     344                PX86PD pShw32BitPd = (PX86PD)PGMPOOL_PAGE_2_PTR_BY_PGM(&pVM->pgm.s, pShwPageCR3);
    341345                AssertFatal(pShw32BitPd);
    342346
     
    353357                const unsigned iPD = iOldPDE / 256;         /* iOldPDE * 2 / 512; iOldPDE is in 4 MB pages */
    354358                unsigned iPDE = iOldPDE * 2 % 512;
    355                 pPdpt     = pgmShwGetPaePDPTPtr(&pVM->pgm.s);
    356                 pShwPaePd = pgmShwGetPaePDPtr(&pVM->pgm.s, (iPD << X86_PDPT_SHIFT));
     359                pPdpt     = (PX86PDPT)PGMPOOL_PAGE_2_PTR_BY_PGM(&pVM->pgm.s, pShwPageCR3);
     360                pShwPaePd = pgmShwGetPaePDPtr(&pVM->pgm.s, pPdpt, (iPD << X86_PDPT_SHIFT));
    357361                AssertFatal(pShwPaePd);
    358362
     
    374378    }
    375379}
     380#endif /* !IN_RING0 */
    376381
    377382/**
     
    389394        return VINF_SUCCESS;
    390395
    391 #ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     396#ifdef IN_RING0
     397    AssertFailed();
     398    return VERR_INTERNAL_ERROR;
     399#else
     400# ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    392401    Assert(pVM->pgm.s.CTX_SUFF(pShwPageCR3));
    393 #endif
     402# endif
    394403
    395404    /*
     
    402411        pgmMapSetShadowPDEs(pVM, pCur, iPDE);
    403412    }
    404 
    405413    return VINF_SUCCESS;
     414#endif /* IN_RING0 */
    406415}
    407416
     
    420429        return VINF_SUCCESS;
    421430
    422 #ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     431#ifdef IN_RING0
     432    AssertFailed();
     433    return VERR_INTERNAL_ERROR;
     434#else
     435# ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
    423436    Assert(pVM->pgm.s.CTX_SUFF(pShwPageCR3));
    424 #endif
     437# endif
    425438
    426439    /*
     
    431444        unsigned iPDE = pCur->GCPtr >> X86_PD_SHIFT;
    432445
    433         pgmMapClearShadowPDEs(pVM, pCur, iPDE);
     446        pgmMapClearShadowPDEs(pVM, pVM->pgm.s.CTX_SUFF(pShwPageCR3), pCur, iPDE);
    434447    }
    435448    return VINF_SUCCESS;
    436 }
     449#endif /* IN_RING0 */
     450}
     451
     452
     453/**
     454 * Remove the hypervisor mappings from the specified CR3
     455 *
     456 * @returns VBox status.
     457 * @param   pVM         The virtual machine.
     458 * @param   pShwPageCR3 CR3 root page
     459 */
     460int pgmMapDeactivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3)
     461{
     462    /*
     463     * Can skip this if mappings are safely fixed.
     464     */
     465    if (pVM->pgm.s.fMappingsFixed)
     466        return VINF_SUCCESS;
     467
     468#ifdef IN_RING0
     469    AssertFailed();
     470    return VERR_INTERNAL_ERROR;
     471#else
     472# ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     473    Assert(pVM->pgm.s.CTX_SUFF(pShwPageCR3));
     474# endif
     475
     476    /*
     477     * Iterate mappings.
     478     */
     479    for (PPGMMAPPING pCur = pVM->pgm.s.CTX_SUFF(pMappings); pCur; pCur = pCur->CTX_SUFF(pNext))
     480    {
     481        unsigned iPDE = pCur->GCPtr >> X86_PD_SHIFT;
     482
     483        pgmMapClearShadowPDEs(pVM, pShwPageCR3, pCur, iPDE);
     484    }
     485    return VINF_SUCCESS;
     486#endif /* IN_RING0 */
     487}
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette