VirtualBox

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


Ignore:
Timestamp:
Jun 22, 2009 11:36:57 AM (16 years ago)
Author:
vboxsync
Message:

Even more pgm locking

File:
1 edited

Legend:

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

    r20709 r20765  
    901901    LogFlow(("PGMHandlerPhysicalPageTempOff GCPhys=%RGp\n", GCPhys));
    902902
     903    pgmLock(pVM);
    903904    /*
    904905     * Validate the range.
     
    913914            Assert((pCur->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
    914915
    915             AssertReturn(   pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_WRITE
     916            AssertReturnStmt(   pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_WRITE
    916917                         || pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_ALL,
    917                          VERR_ACCESS_DENIED);
     918                         pgmUnlock(pVM), VERR_ACCESS_DENIED);
    918919
    919920            /*
     
    922923            PPGMPAGE pPage;
    923924            int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPage, &pPage);
    924             AssertRCReturn(rc, rc);
     925            AssertReturnStmt(RT_SUCCESS_NP(rc), pgmUnlock(pVM), rc);
    925926            PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_DISABLED);
     927            pgmUnlock(pVM);
    926928#ifndef IN_RC
    927929            HWACCMInvalidatePhysPage(pVM, GCPhysPage);
     
    929931            return VINF_SUCCESS;
    930932        }
    931 
     933        pgmUnlock(pVM);
    932934        AssertMsgFailed(("The page %#x is outside the range %#x-%#x\n",
    933935                         GCPhysPage, pCur->Core.Key, pCur->Core.KeyLast));
    934936        return VERR_INVALID_PARAMETER;
    935937    }
    936 
     938    pgmUnlock(pVM);
    937939    AssertMsgFailed(("Specified physical handler start address %#x is invalid.\n", GCPhys));
    938940    return VERR_PGM_HANDLER_NOT_FOUND;
     
    984986///    Assert(!IOMIsLockOwner(pVM)); /* We mustn't own any other locks when calling this */
    985987
     988    pgmLock(pVM);
    986989    /*
    987990     * Lookup and validate the range.
     
    993996                      &&  GCPhysPage <= pCur->Core.KeyLast))
    994997        {
    995             AssertReturn(pCur->enmType == PGMPHYSHANDLERTYPE_MMIO, VERR_ACCESS_DENIED);
    996             AssertReturn(!(pCur->Core.Key & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
    997             AssertReturn((pCur->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK, VERR_INVALID_PARAMETER);
     998            AssertReturnStmt(pCur->enmType == PGMPHYSHANDLERTYPE_MMIO, pgmUnlock(pVM), VERR_ACCESS_DENIED);
     999            AssertReturnStmt(!(pCur->Core.Key & PAGE_OFFSET_MASK), pgmUnlock(pVM), VERR_INVALID_PARAMETER);
     1000            AssertReturnStmt((pCur->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK, pgmUnlock(pVM), VERR_INVALID_PARAMETER);
    9981001
    9991002            /*
     
    10021005            PPGMPAGE pPageRemap;
    10031006            int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPageRemap, &pPageRemap);
    1004             AssertRCReturn(rc, rc);
    1005             AssertMsgReturn(PGM_PAGE_GET_TYPE(pPageRemap) == PGMPAGETYPE_MMIO2,
     1007            AssertReturnStmt(RT_SUCCESS_NP(rc), pgmUnlock(pVM), rc);
     1008            AssertMsgReturnStmt(PGM_PAGE_GET_TYPE(pPageRemap) == PGMPAGETYPE_MMIO2,
    10061009                            ("GCPhysPageRemap=%RGp %R[pgmpage]\n", GCPhysPageRemap, pPageRemap),
    1007                             VERR_PGM_PHYS_NOT_MMIO2);
     1010                            pgmUnlock(pVM), VERR_PGM_PHYS_NOT_MMIO2);
    10081011
    10091012            PPGMPAGE pPage;
    10101013            rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPage, &pPage);
    1011             AssertRCReturn(rc, rc);
     1014            AssertReturnStmt(RT_SUCCESS_NP(rc), pgmUnlock(pVM), rc);
    10121015            if (PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_MMIO)
    10131016            {
     
    10161019                                VERR_PGM_PHYS_NOT_MMIO2);
    10171020                if (PGM_PAGE_GET_HCPHYS(pPage) == PGM_PAGE_GET_HCPHYS(pPageRemap))
     1021                {
     1022                    pgmUnlock(pVM);
    10181023                    return VINF_PGM_HANDLER_ALREADY_ALIASED;
     1024                }
    10191025
    10201026                /*
     
    10411047            LogFlow(("PGMHandlerPhysicalPageAlias: => %R[pgmpage]\n", pPage));
    10421048
     1049            pgmUnlock(pVM);
    10431050#ifndef IN_RC
    10441051            HWACCMInvalidatePhysPage(pVM, GCPhysPage);
     
    10471054        }
    10481055
     1056        pgmUnlock(pVM);
    10491057        AssertMsgFailed(("The page %#x is outside the range %#x-%#x\n",
    10501058                         GCPhysPage, pCur->Core.Key, pCur->Core.KeyLast));
     
    10521060    }
    10531061
     1062    pgmUnlock(pVM);
    10541063    AssertMsgFailed(("Specified physical handler start address %#x is invalid.\n", GCPhys));
    10551064    return VERR_PGM_HANDLER_NOT_FOUND;
     
    10971106     * Lookup and validate the range.
    10981107     */
     1108    pgmLock(pVM);
    10991109    PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)RTAvlroGCPhysGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysHandlers, GCPhys);
    11001110    if (RT_LIKELY(pCur))
     
    11031113                      &&  GCPhysPage <= pCur->Core.KeyLast))
    11041114        {
    1105             AssertReturn(pCur->enmType == PGMPHYSHANDLERTYPE_MMIO, VERR_ACCESS_DENIED);
    1106             AssertReturn(!(pCur->Core.Key & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
    1107             AssertReturn((pCur->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK, VERR_INVALID_PARAMETER);
     1115            AssertReturnStmt(pCur->enmType == PGMPHYSHANDLERTYPE_MMIO, pgmUnlock(pVM), VERR_ACCESS_DENIED);
     1116            AssertReturnStmt(!(pCur->Core.Key & PAGE_OFFSET_MASK), pgmUnlock(pVM), VERR_INVALID_PARAMETER);
     1117            AssertReturnStmt((pCur->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK, pgmUnlock(pVM), VERR_INVALID_PARAMETER);
    11081118
    11091119            /*
     
    11121122            PPGMPAGE pPage;
    11131123            int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPage, &pPage);
    1114             AssertRCReturn(rc, rc);
     1124            AssertReturnStmt(RT_SUCCESS_NP(rc), pgmUnlock(pVM), rc);
    11151125            if (PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_MMIO)
    11161126            {
     1127                pgmUnlock(pVM);
    11171128                AssertMsgReturn(PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_MMIO2_ALIAS_MMIO,
    11181129                                ("GCPhysPage=%RGp %R[pgmpage]\n", GCPhysPage, pPage),
     
    11381149            PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_DISABLED);
    11391150            LogFlow(("PGMHandlerPhysicalPageAliasHC: => %R[pgmpage]\n", pPage));
    1140 
     1151            pgmUnlock(pVM);
    11411152#ifndef IN_RC
    11421153            HWACCMInvalidatePhysPage(pVM, GCPhysPage);
     
    11441155            return VINF_SUCCESS;
    11451156        }
    1146 
     1157        pgmUnlock(pVM);
    11471158        AssertMsgFailed(("The page %#x is outside the range %#x-%#x\n",
    11481159                         GCPhysPage, pCur->Core.Key, pCur->Core.KeyLast));
    11491160        return VERR_INVALID_PARAMETER;
    11501161    }
     1162    pgmUnlock(pVM);
    11511163
    11521164    AssertMsgFailed(("Specified physical handler start address %#x is invalid.\n", GCPhys));
     
    11691181     * Find the handler.
    11701182     */
     1183    pgmLock(pVM);
    11711184    PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysHandlers, GCPhys);
    11721185    if (pCur)
     
    11761189               ||   pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_ALL
    11771190               ||   pCur->enmType == PGMPHYSHANDLERTYPE_MMIO);
     1191        pgmUnlock(pVM);
    11781192        return true;
    11791193    }
    1180 
     1194    pgmUnlock(pVM);
    11811195    return false;
    11821196}
     
    11961210bool pgmHandlerPhysicalIsAll(PVM pVM, RTGCPHYS GCPhys)
    11971211{
     1212    pgmLock(pVM);
    11981213    PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysHandlers, GCPhys);
    1199     AssertReturn(pCur, true);
     1214    if (!pCur)
     1215    {
     1216        pgmUnlock(pVM);
     1217        AssertFailed();
     1218        return true;
     1219    }
    12001220    Assert(     pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_WRITE
    12011221           ||   pCur->enmType == PGMPHYSHANDLERTYPE_PHYSICAL_ALL
     
    12041224    Assert(   pCur->Core.Key     <= (GCPhys & ~(RTGCPHYS)PAGE_OFFSET_MASK)
    12051225           && pCur->Core.KeyLast >= (GCPhys | PAGE_OFFSET_MASK));
    1206     return pCur->enmType != PGMPHYSHANDLERTYPE_PHYSICAL_WRITE;
     1226
     1227    bool bRet = pCur->enmType != PGMPHYSHANDLERTYPE_PHYSICAL_WRITE;
     1228    pgmUnlock(pVM);
     1229    return bRet;
    12071230}
    12081231
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