VirtualBox

Changeset 17517 in vbox for trunk/src


Ignore:
Timestamp:
Mar 7, 2009 6:16:56 AM (16 years ago)
Author:
vboxsync
Message:

PGM: Fixed PGMVIRTHANDLERTYPE_ALL regression from the other day - it seems like there are a few users of this type after all. Implemented PGMPhysRead support for it. Enforce page-sized-ness of this type just a for PGMPHYSHANDLERTYPE_ALL/MMIO.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGMHandler.cpp

    r17432 r17517  
    298298    {
    299299        case PGMVIRTHANDLERTYPE_ALL:
    300             AssertReleaseMsgFailedReturn(("PGMVIRTHANDLERTYPE_ALL: not implemented\n"), VERR_NOT_IMPLEMENTED);
     300            AssertReleaseMsgReturn(   (GCPtr     & PAGE_OFFSET_MASK) == 0
     301                                   && (GCPtrLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK,
     302                                   ("PGMVIRTHANDLERTYPE_ALL: GCPtr=%RGv GCPtrLast=%RGv\n", GCPtr, GCPtrLast),
     303                                   VERR_NOT_IMPLEMENTED);
    301304            break;
    302305        case PGMVIRTHANDLERTYPE_WRITE:
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r17512 r17517  
    14091409    /*
    14101410     * The most frequent access here is MMIO and shadowed ROM.
    1411      *
    1412      * The current code ASSUMES all these access handlers are page sized
    1413      * and that we do NOT use any virtual ones.
    1414      */
    1415     if (    PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) == PGM_PAGE_HNDL_PHYS_STATE_ALL
    1416         &&  PGM_PAGE_GET_HNDL_VIRT_STATE(pPage) != PGM_PAGE_HNDL_VIRT_STATE_ALL)
     1411     * The current code ASSUMES all these access handlers covers full pages!
     1412     */
     1413
     1414    /*
     1415     * Whatever we do we need the source page, map it first.
     1416     */
     1417    const void *pvSrc = NULL;
     1418    int         rc    = pgmPhysGCPhys2CCPtrInternalReadOnly(pVM, pPage, GCPhys, &pvSrc);
     1419    if (RT_FAILURE(rc))
     1420    {
     1421        AssertLogRelMsgFailed(("pgmPhysGCPhys2CCPtrInternalReadOnly failed on %RGp / %R[pgmpage] -> %Rrc\n",
     1422                               GCPhys, pPage, rc));
     1423        memset(pvBuf, 0xff, cb);
     1424        return;
     1425    }
     1426    rc = VINF_PGM_HANDLER_DO_DEFAULT;
     1427
     1428    /*
     1429     * Deal with any physical handlers.
     1430     */
     1431    PPGMPHYSHANDLER pPhys = NULL;
     1432    if (PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) == PGM_PAGE_HNDL_PHYS_STATE_ALL)
    14171433    {
    14181434#ifdef IN_RING3
    1419         PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysHandlers, GCPhys);
    1420         AssertReleaseMsg(pCur, ("GCPhys=%RGp cb=%#x\n", GCPhys, cb));
    1421         Assert(GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast);
    1422         Assert(pCur->CTX_SUFF(pfnHandler));
    1423 
    1424         const void *pvSrc;
    1425         int rc = pgmPhysGCPhys2CCPtrInternalReadOnly(pVM, pPage, GCPhys, &pvSrc);
    1426         if (RT_SUCCESS(rc))
    1427         {
    1428             STAM_PROFILE_START(&pCur->Stat, h);
    1429             int rc = pCur->CTX_SUFF(pfnHandler)(pVM, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, pCur->CTX_SUFF(pvUser));
    1430             STAM_PROFILE_STOP(&pCur->Stat, h);
    1431             if (rc == VINF_PGM_HANDLER_DO_DEFAULT)
    1432                 memcpy(pvBuf, pvSrc, cb);
    1433             else
    1434                 AssertLogRelMsg(rc == VINF_SUCCESS, ("rc=%Rrc GCPhys=%RGp\n", rc, GCPhys));
    1435         }
    1436         else
    1437         {
    1438             AssertLogRelMsgFailed(("pgmPhysGCPhys2CCPtrInternalReadOnly failed on %RGp / %R[pgmpage] -> %Rrc\n",
    1439                                    GCPhys, pPage, rc));
    1440             memset(pvBuf, 0xff, cb);
    1441         }
     1435        PPGMPHYSHANDLER pPhys = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.CTX_SUFF(pTrees)->PhysHandlers, GCPhys);
     1436        AssertReleaseMsg(pPhys, ("GCPhys=%RGp cb=%#x\n", GCPhys, cb));
     1437        Assert(GCPhys >= pPhys->Core.Key && GCPhys <= pPhys->Core.KeyLast);
     1438        Assert((pPhys->Core.Key     & PAGE_OFFSET_MASK) == 0);
     1439        Assert((pPhys->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
     1440        Assert(pPhys->CTX_SUFF(pfnHandler));
     1441
     1442        Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cb, pPage, R3STRING(pPhys->pszDesc) ));
     1443        STAM_PROFILE_START(&pPhys->Stat, h);
     1444        rc = pPhys->CTX_SUFF(pfnHandler)(pVM, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, pPhys->CTX_SUFF(pvUser));
     1445        STAM_PROFILE_STOP(&pPhys->Stat, h);
     1446        AssertLogRelMsg(rc == VINF_SUCCESS || rc == VINF_PGM_HANDLER_DO_DEFAULT, ("rc=%Rrc GCPhys=%RGp\n", rc, GCPhys));
    14421447#else
    14431448        AssertReleaseMsgFailed(("Wrong API! GCPhys=%RGp cb=%#x\n", GCPhys, cb));
    14441449#endif
    14451450    }
    1446     else
    1447         AssertReleaseMsgFailed(("ALL access virtual handlers are not implemented here\n"));
     1451
     1452    /*
     1453     * Deal with any virtual handlers.
     1454     */
     1455    if (PGM_PAGE_GET_HNDL_VIRT_STATE(pPage) == PGM_PAGE_HNDL_VIRT_STATE_ALL)
     1456    {
     1457        unsigned        iPage;
     1458        PPGMVIRTHANDLER pVirt;
     1459
     1460        int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pVirt, &iPage);
     1461        AssertReleaseMsg(RT_SUCCESS(rc2), ("GCPhys=%RGp cb=%#x rc2=%Rrc\n", GCPhys, cb, rc2));
     1462        Assert((pVirt->Core.Key     & PAGE_OFFSET_MASK) == 0);
     1463        Assert((pVirt->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
     1464        Assert(GCPhys >= pVirt->aPhysToVirt[iPage].Core.Key && GCPhys <= pVirt->aPhysToVirt[iPage].Core.KeyLast);
     1465
     1466#ifdef IN_RING3
     1467        rc = VINF_PGM_HANDLER_DO_DEFAULT;
     1468        if (pVirt->pfnHandlerR3)
     1469        {
     1470            if (PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) != PGM_PAGE_HNDL_PHYS_STATE_ALL)
     1471                Log5(("pgmPhysWriteHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] virt %s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc) ));
     1472            else
     1473                Log(("pgmPhysWriteHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys/virt %s/%s\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc), R3STRING(pPhys->pszDesc) ));
     1474            RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirt->Core.Key & PAGE_BASE_GC_MASK)
     1475                              + (iPage << PAGE_SHIFT)
     1476                              + (GCPhys & PAGE_OFFSET_MASK);
     1477
     1478            STAM_PROFILE_START(&pVirt->Stat, h);
     1479            rc2 = pVirt->CTX_SUFF(pfnHandler)(pVM, GCPtr, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, /*pVirt->CTX_SUFF(pvUser)*/ NULL);
     1480            STAM_PROFILE_STOP(&pVirt->Stat, h);
     1481            if (rc2 == VINF_SUCCESS)
     1482                rc = VINF_SUCCESS;
     1483            AssertLogRelMsg(rc == VINF_SUCCESS || rc == VINF_PGM_HANDLER_DO_DEFAULT, ("rc=%Rrc GCPhys=%RGp pPage=%R[pgmpage] %s\n", rc, GCPhys, pPage, pVirt->pszDesc));
     1484        }
     1485        else
     1486            Log5(("pgmPhysWriteHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] virt %s [no handler]\n", GCPhys, cb, pPage, R3STRING(pVirt->pszDesc) ));
     1487#else
     1488        AssertReleaseMsgFailed(("Wrong API! GCPhys=%RGp cb=%#x\n", GCPhys, cb));
     1489#endif
     1490    }
     1491
     1492    /*
     1493     * Take the default action.
     1494     */
     1495    if (rc == VINF_PGM_HANDLER_DO_DEFAULT)
     1496        memcpy(pvBuf, pvSrc, cb);
    14481497}
    14491498
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