VirtualBox

Ignore:
Timestamp:
Aug 14, 2019 11:25:13 AM (5 years ago)
Author:
vboxsync
Message:

VMM: Refactoring VMMAll/* to use VMCC & VMMCPUCC. bugref:9217

File:
1 edited

Legend:

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

    r80182 r80268  
    2020*   Header Files                                                                                                                 *
    2121*********************************************************************************************************************************/
     22#define VBOX_BUGREF_9217_PART_I
    2223#define LOG_GROUP LOG_GROUP_PGM_POOL
    2324#include <VBox/vmm/pgm.h>
     
    2627#include <VBox/vmm/cpum.h>
    2728#include "PGMInternal.h"
    28 #include <VBox/vmm/vm.h>
     29#include <VBox/vmm/vmcc.h>
    2930#include "PGMInline.h"
    3031#include <VBox/disopcode.h>
     
    142143 * @param   cb          Size of data to read
    143144 */
    144 DECLINLINE(int) pgmPoolPhysSimpleReadGCPhys(PVM pVM, void *pvDst, void const *pvSrc, RTGCPHYS GCPhysSrc, size_t cb)
     145DECLINLINE(int) pgmPoolPhysSimpleReadGCPhys(PVMCC pVM, void *pvDst, void const *pvSrc, RTGCPHYS GCPhysSrc, size_t cb)
    145146{
    146147#if defined(IN_RING3)
     
    175176    AssertMsg(pPage->iMonitoredPrev == NIL_PGMPOOL_IDX, ("%u (idx=%u)\n", pPage->iMonitoredPrev, pPage->idx));
    176177    const unsigned  off = GCPhysFault & PAGE_OFFSET_MASK;
    177     PVM             pVM = pPool->CTX_SUFF(pVM);
     178    PVMCC           pVM = pPool->CTX_SUFF(pVM);
    178179    NOREF(pVCpu);
    179180
     
    641642 * @remark  The REP prefix check is left to the caller because of STOSD/W.
    642643 */
    643 DECLINLINE(bool) pgmRZPoolMonitorIsReused(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pDis, RTGCPTR pvFault,
     644DECLINLINE(bool) pgmRZPoolMonitorIsReused(PVMCC pVM, PVMCPUCC pVCpu, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pDis, RTGCPTR pvFault,
    644645                                          PPGMPOOLPAGE pPage)
    645646{
     
    808809 * @param   pvFault     The fault address.
    809810 */
    810 DECLINLINE(int) pgmRZPoolAccessPfHandlerSTOSD(PVM pVM, PPGMPOOL pPool, PPGMPOOLPAGE pPage, PDISCPUSTATE pDis,
     811DECLINLINE(int) pgmRZPoolAccessPfHandlerSTOSD(PVMCC pVM, PPGMPOOL pPool, PPGMPOOLPAGE pPage, PDISCPUSTATE pDis,
    811812                                              PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, RTGCPTR pvFault)
    812813{
     
    839840     * write situation, meaning that it's safe to write here.
    840841     */
    841     PVMCPU      pVCpu = VMMGetCpu(pPool->CTX_SUFF(pVM));
     842    PVMCPUCC    pVCpu = VMMGetCpu(pPool->CTX_SUFF(pVM));
    842843    RTGCUINTPTR pu32 = (RTGCUINTPTR)pvFault;
    843844    while (pRegFrame->rcx)
     
    877878 * @param   pfReused    Reused state (in/out)
    878879 */
    879 DECLINLINE(int) pgmRZPoolAccessPfHandlerSimple(PVM pVM, PVMCPU pVCpu, PPGMPOOL pPool, PPGMPOOLPAGE pPage, PDISCPUSTATE pDis,
     880DECLINLINE(int) pgmRZPoolAccessPfHandlerSimple(PVMCC pVM, PVMCPU pVCpu, PPGMPOOL pPool, PPGMPOOLPAGE pPage, PDISCPUSTATE pDis,
    880881                                               PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, RTGCPTR pvFault, bool *pfReused)
    881882{
     
    972973 * @remarks The @a pvUser argument points to the PGMPOOLPAGE.
    973974 */
    974 DECLEXPORT(VBOXSTRICTRC) pgmRZPoolAccessPfHandler(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
     975DECLEXPORT(VBOXSTRICTRC) pgmRZPoolAccessPfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
    975976                                                  RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
    976977{
     
    12761277 */
    12771278PGM_ALL_CB2_DECL(VBOXSTRICTRC)
    1278 pgmPoolAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
     1279pgmPoolAccessHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
    12791280                     PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
    12801281{
     
    13921393    unsigned LastPTE    = ~0U;          /* initialized to shut up gcc */
    13931394    RTHCPHYS LastHCPhys = NIL_RTHCPHYS; /* initialized to shut up gcc */
    1394     PVM      pVM        = pPool->CTX_SUFF(pVM);
     1395    PVMCC    pVM        = pPool->CTX_SUFF(pVM);
    13951396
    13961397#  ifdef VBOX_STRICT
     
    14581459    unsigned LastPTE    = ~0U;          /* initialized to shut up gcc */
    14591460    RTHCPHYS LastHCPhys = NIL_RTHCPHYS; /* initialized to shut up gcc */
    1460     PVM      pVM        = pPool->CTX_SUFF(pVM);
     1461    PVMCC    pVM        = pPool->CTX_SUFF(pVM);
    14611462
    14621463#  ifdef VBOX_STRICT
     
    16551656 * @param   fAllowRemoval   Allow a reused page table to be removed
    16561657 */
    1657 static void pgmPoolFlushDirtyPage(PVM pVM, PPGMPOOL pPool, unsigned idxSlot, bool fAllowRemoval = false)
     1658static void pgmPoolFlushDirtyPage(PVMCC pVM, PPGMPOOL pPool, unsigned idxSlot, bool fAllowRemoval = false)
    16581659{
    16591660    AssertCompile(RT_ELEMENTS(pPool->aidxDirtyPages) == RT_ELEMENTS(pPool->aDirtyPages));
     
    17511752 * @param   pPage       The page.
    17521753 */
    1753 void pgmPoolAddDirtyPage(PVM pVM, PPGMPOOL pPool, PPGMPOOLPAGE pPage)
     1754void pgmPoolAddDirtyPage(PVMCC pVM, PPGMPOOL pPool, PPGMPOOLPAGE pPage)
    17541755{
    17551756    PGM_LOCK_ASSERT_OWNER(pVM);
     
    18571858 * @param   pVM             The cross context VM structure.
    18581859 */
    1859 void pgmPoolResetDirtyPages(PVM pVM)
     1860void pgmPoolResetDirtyPages(PVMCC pVM)
    18601861{
    18611862    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     
    19201921 * @param   GCPhysPT        Physical address of the page table
    19211922 */
    1922 void pgmPoolInvalidateDirtyPage(PVM pVM, RTGCPHYS GCPhysPT)
     1923void pgmPoolInvalidateDirtyPage(PVMCC pVM, RTGCPHYS GCPhysPT)
    19231924{
    19241925    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     
    20292030static int pgmPoolCacheFreeOne(PPGMPOOL pPool, uint16_t iUser)
    20302031{
    2031     const PVM pVM = pPool->CTX_SUFF(pVM);
     2032    const PVMCC pVM = pPool->CTX_SUFF(pVM);
    20322033    Assert(pPool->iAgeHead != pPool->iAgeTail); /* We shouldn't be here if there < 2 cached entries! */
    20332034    STAM_COUNTER_INC(&pPool->StatCacheFreeUpOne);
     
    25092510    {
    25102511        Assert(pPage->iMonitoredNext == NIL_PGMPOOL_IDX); Assert(pPage->iMonitoredPrev == NIL_PGMPOOL_IDX);
    2511         PVM pVM = pPool->CTX_SUFF(pVM);
     2512        PVMCC pVM = pPool->CTX_SUFF(pVM);
    25122513        const RTGCPHYS GCPhysPage = pPage->GCPhys & ~(RTGCPHYS)PAGE_OFFSET_MASK;
    25132514        rc = PGMHandlerPhysicalRegister(pVM, GCPhysPage, GCPhysPage + PAGE_OFFSET_MASK, pPool->hAccessHandlerType,
     
    25812582     * Remove the page from the monitored list or uninstall it if last.
    25822583     */
    2583     const PVM pVM = pPool->CTX_SUFF(pVM);
     2584    const PVMCC pVM = pPool->CTX_SUFF(pVM);
    25842585    int rc;
    25852586    if (    pPage->iMonitoredNext != NIL_PGMPOOL_IDX
     
    26982699 * @param   pVM     The cross context VM structure.
    26992700 */
    2700 static void pgmPoolMonitorModifiedClearAll(PVM pVM)
     2701static void pgmPoolMonitorModifiedClearAll(PVMCC pVM)
    27012702{
    27022703    pgmLock(pVM);
     
    27372738 *          the PGMPOOL_WITH_MONITORING \#ifdef.
    27382739 */
    2739 int pgmPoolSyncCR3(PVMCPU pVCpu)
    2740 {
    2741     PVM pVM = pVCpu->CTX_SUFF(pVM);
     2740int pgmPoolSyncCR3(PVMCPUCC pVCpu)
     2741{
     2742    PVMCC pVM = pVCpu->CTX_SUFF(pVM);
    27422743    LogFlow(("pgmPoolSyncCR3 fSyncFlags=%x\n", pVCpu->pgm.s.fSyncFlags));
    27432744
     
    34913492 *                      The caller MUST initialized this to @a false.
    34923493 */
    3493 int pgmPoolTrackUpdateGCPhys(PVM pVM, RTGCPHYS GCPhysPage, PPGMPAGE pPhysPage, bool fFlushPTEs, bool *pfFlushTLBs)
    3494 {
    3495     PVMCPU pVCpu = VMMGetCpu(pVM);
     3494int pgmPoolTrackUpdateGCPhys(PVMCC pVM, RTGCPHYS GCPhysPage, PPGMPAGE pPhysPage, bool fFlushPTEs, bool *pfFlushTLBs)
     3495{
     3496    PVMCPUCC pVCpu = VMMGetCpu(pVM);
    34963497    pgmLock(pVM);
    34973498    int rc = VINF_SUCCESS;
     
    41224123void pgmPoolTrackPhysExtDerefGCPhys(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PPGMPAGE pPhysPage, uint16_t iPte)
    41234124{
    4124     PVM            pVM = pPool->CTX_SUFF(pVM);
     4125    PVMCC          pVM = pPool->CTX_SUFF(pVM);
    41254126    const unsigned cRefs = PGM_PAGE_GET_TD_CREFS(pPhysPage);
    41264127    AssertFatalMsg(cRefs == PGMPOOL_TD_CREFS_PHYSEXT, ("cRefs=%d pPhysPage=%R[pgmpage] pPage=%p:{.idx=%d}\n", cRefs, pPhysPage, pPage, pPage->idx));
     
    42164217     * Lookup the page and check if it checks out before derefing it.
    42174218     */
    4218     PVM      pVM       = pPool->CTX_SUFF(pVM);
     4219    PVMCC    pVM       = pPool->CTX_SUFF(pVM);
    42194220    PPGMPAGE pPhysPage = pgmPhysGetPage(pVM, GCPhys);
    42204221    if (pPhysPage)
     
    42594260     */
    42604261    RTHCPHYS HCPhysHinted;
    4261     PVM      pVM       = pPool->CTX_SUFF(pVM);
     4262    PVMCC    pVM       = pPool->CTX_SUFF(pVM);
    42624263    PPGMPAGE pPhysPage = pgmPhysGetPage(pVM, GCPhysHint);
    42634264    if (pPhysPage)
     
    46834684     * Map the shadow page and take action according to the page kind.
    46844685     */
    4685     PVM  pVM   = pPool->CTX_SUFF(pVM);
     4686    PVMCC pVM   = pPool->CTX_SUFF(pVM);
    46864687    void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage);
    46874688    switch (pPage->enmKind)
     
    48094810int pgmPoolFlushPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, bool fFlush)
    48104811{
    4811     PVM     pVM = pPool->CTX_SUFF(pVM);
     4812    PVMCC   pVM = pPool->CTX_SUFF(pVM);
    48124813    bool    fFlushRequired = false;
    48134814
     
    49344935void pgmPoolFreeByPage(PPGMPOOL pPool, PPGMPOOLPAGE pPage, uint16_t iUser, uint32_t iUserTable)
    49354936{
    4936     PVM pVM = pPool->CTX_SUFF(pVM);
     4937    PVMCC pVM = pPool->CTX_SUFF(pVM);
    49374938
    49384939    STAM_PROFILE_START(&pPool->StatFree, a);
     
    49634964static int pgmPoolMakeMoreFreePages(PPGMPOOL pPool, PGMPOOLKIND enmKind, uint16_t iUser)
    49644965{
    4965     PVM pVM = pPool->CTX_SUFF(pVM);
     4966    PVMCC pVM = pPool->CTX_SUFF(pVM);
    49664967    LogFlow(("pgmPoolMakeMoreFreePages: enmKind=%d iUser=%d\n", enmKind, iUser));
    49674968    NOREF(enmKind);
     
    53215322     * including the root page.
    53225323     */
    5323     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    5324         pgmR3ExitShadowModeBeforePoolFlush(&pVM->aCpus[i]);
     5324    VMCC_FOR_EACH_VMCPU(pVM)
     5325        pgmR3ExitShadowModeBeforePoolFlush(pVCpu);
     5326    VMCC_FOR_EACH_VMCPU_END(pVM);
     5327
    53255328
    53265329    /*
     
    54365439     * Reinsert active pages into the hash and ensure monitoring chains are correct.
    54375440     */
    5438     for (VMCPUID i = 0; i < pVM->cCpus; i++)
     5441    VMCC_FOR_EACH_VMCPU(pVM)
    54395442    {
    54405443        /*
    54415444         * Re-enter the shadowing mode and assert Sync CR3 FF.
    54425445         */
    5443         PVMCPU pVCpu = &pVM->aCpus[i];
    54445446        pgmR3ReEnterShadowModeAfterPoolFlush(pVM, pVCpu);
    54455447        VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    54465448        VMCPU_FF_SET(pVCpu, VMCPU_FF_TLB_FLUSH);
    54475449    }
     5450    VMCC_FOR_EACH_VMCPU_END(pVM);
    54485451
    54495452    STAM_PROFILE_STOP(&pPool->StatR3Reset, a);
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