VirtualBox

Ignore:
Timestamp:
May 21, 2015 6:14:21 PM (10 years ago)
Author:
vboxsync
Message:

Physical access handler cleanups.

File:
1 edited

Legend:

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

    r55972 r56017  
    17331733}
    17341734
    1735 /**
    1736  * \#PF Handler callback for MMIO ranges.
    1737  *
    1738  * @returns VBox status code (appropriate for GC return).
    1739  * @param   pVM         Pointer to the VM.
    1740  * @param   pVCpu       Pointer to the cross context CPU context for the
    1741  *                      calling EMT.
    1742  * @param   uErrorCode  CPU Error code.
    1743  * @param   pCtxCore    Trap register frame.
    1744  * @param   pvFault     The fault address (cr2).
    1745  * @param   GCPhysFault The GC physical address corresponding to pvFault.
    1746  * @param   pvUser      Pointer to the MMIO ring-3 range entry.
     1735
     1736/**
     1737 * @callback_method_impl{FNPGMRZPHYSPFHANDLER,
     1738 *      \#PF access handler callback for MMIO pages.}
     1739 *
     1740 * @remarks The @a pvUser argument points to the IOMMMIORANGE.
    17471741 */
    17481742DECLEXPORT(VBOXSTRICTRC) iomMmioPfHandler(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPTR pvFault,
     
    17531747    return iomMMIOHandler(pVM, pVCpu, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, pvUser);
    17541748}
     1749
    17551750
    17561751/**
     
    17911786
    17921787/**
    1793  * \#PF Handler callback for MMIO ranges.
    1794  *
    1795  * @returns VINF_SUCCESS if the handler have carried out the operation.
    1796  * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
    1797  * @param   pVM             Pointer to the VM.
    1798  * @param   pVCpu           The cross context CPU structure for the calling EMT.
    1799  * @param   GCPhys          The physical address the guest is writing to.
    1800  * @param   pvPhys          The HC mapping of that address.
    1801  * @param   pvBuf           What the guest is reading/writing.
    1802  * @param   cbBuf           How much it's reading/writing.
    1803  * @param   enmAccessType   The access type.
    1804  * @param   enmOrigin       Who is making the access.
    1805  * @param   pvUser          Pointer to the MMIO range entry.
     1788 * @callback_method_impl{FNPGMPHYSHANDLER, MMIO page accesses}
     1789 *
     1790 * @remarks The @a pvUser argument points to the MMIO range entry.
    18061791 */
    18071792PGM_ALL_CB2_DECL(VBOXSTRICTRC) iomMmioHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf,
     
    18281813    PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns);
    18291814    IOM_UNLOCK_SHARED(pVM);
    1830     rc = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_R3_MMIO_READ_WRITE);
    1831     if (rc != VINF_SUCCESS)
    1832     {
     1815    VBOXSTRICTRC rcStrict = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_R3_MMIO_READ_WRITE);
     1816    if (rcStrict == VINF_SUCCESS)
     1817    {
     1818        /*
     1819         * Perform the access.
     1820         */
     1821        if (enmAccessType == PGMACCESSTYPE_READ)
     1822            rcStrict = iomMMIODoRead(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
     1823        else
     1824            rcStrict = iomMMIODoWrite(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
     1825
     1826        /* Check the return code. */
     1827#ifdef IN_RING3
     1828        AssertMsg(rcStrict == VINF_SUCCESS, ("%Rrc - %RGp - %s\n", VBOXSTRICTRC_VAL(rcStrict), GCPhysFault, pRange->pszDesc));
     1829#else
     1830        AssertMsg(   rcStrict == VINF_SUCCESS
     1831                  || rcStrict == (enmAccessType == PGMACCESSTYPE_READ ? VINF_IOM_R3_MMIO_READ :  VINF_IOM_R3_MMIO_WRITE)
     1832                  || rcStrict == VINF_IOM_R3_MMIO_READ_WRITE
     1833                  || rcStrict == VINF_EM_DBG_STOP
     1834                  || rcStrict == VINF_EM_DBG_BREAKPOINT
     1835                  || rcStrict == VINF_EM_OFF
     1836                  || rcStrict == VINF_EM_SUSPEND
     1837                  || rcStrict == VINF_EM_RESET
     1838                  //|| rcStrict == VINF_EM_HALT       /* ?? */
     1839                  //|| rcStrict == VINF_EM_NO_MEMORY  /* ?? */
     1840                  , ("%Rrc - %RGp - %p\n", VBOXSTRICTRC_VAL(rcStrict), GCPhysFault, pDevIns));
     1841#endif
     1842
    18331843        iomMmioReleaseRange(pVM, pRange);
    1834         return rc;
    1835     }
    1836 
    1837     /*
    1838      * Perform the access.
    1839      */
    1840     VBOXSTRICTRC rcStrict;
    1841     if (enmAccessType == PGMACCESSTYPE_READ)
    1842         rcStrict = iomMMIODoRead(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
     1844        PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo));
     1845    }
    18431846    else
    1844         rcStrict = iomMMIODoWrite(pVM, pVCpu, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
    1845     AssertMsgRC(rcStrict, ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
    1846 
    1847     iomMmioReleaseRange(pVM, pRange);
    1848     PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo));
     1847        iomMmioReleaseRange(pVM, pRange);
    18491848    return rcStrict;
    18501849}
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