VirtualBox

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


Ignore:
Timestamp:
Jun 19, 2009 12:34:21 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48835
Message:

More IOM locking and checks.

File:
1 edited

Legend:

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

    r20569 r20722  
    12731273VMMDECL(int) IOMMMIOPhysHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault)
    12741274{
    1275     return iomMMIOHandler(pVM, uErrorCode, pCtxCore, GCPhysFault, iomMMIOGetRange(&pVM->iom.s, GCPhysFault));
     1275    int rc;
     1276    rc = iomLock(pVM);
     1277#ifndef IN_RING3
     1278    if (rc == VERR_SEM_BUSY)
     1279        return (uErrorCode & X86_TRAP_PF_RW) ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ;
     1280#endif
     1281    rc = iomMMIOHandler(pVM, uErrorCode, pCtxCore, GCPhysFault, iomMMIOGetRange(&pVM->iom.s, GCPhysFault));
     1282    iomUnlock(pVM);
     1283    return rc;
    12761284}
    12771285
     
    18651873VMMDECL(int) IOMMMIOMapMMIO2Page(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags)
    18661874{
     1875    /* Currently only called from the VGA device during MMIO. */
     1876    Assert(IOMIsLockOwner(pVM));
    18671877    Log(("IOMMMIOMapMMIO2Page %RGp -> %RGp flags=%RX64\n", GCPhys, GCPhysRemapped, fPageFlags));
    18681878
     
    18821892    PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
    18831893    AssertMsgReturn(pRange,
    1884                     ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys),
    1885                     VERR_IOM_MMIO_RANGE_NOT_FOUND);
     1894            ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     1895
    18861896    Assert((pRange->GCPhys       & PAGE_OFFSET_MASK) == 0);
    18871897    Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
     
    19301940VMMDECL(int) IOMMMIOMapMMIOHCPage(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint64_t fPageFlags)
    19311941{
     1942    /* Currently only called from VT-x code during a page fault. */
    19321943    Log(("IOMMMIOMapMMIOHCPage %RGp -> %RGp flags=%RX64\n", GCPhys, HCPhys, fPageFlags));
    19331944
     
    19401951     * Lookup the context range node the page belongs to.
    19411952     */
    1942     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     1953#ifdef VBOX_STRICT
     1954    /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
     1955    PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(&pVM->iom.s, GCPhys);
    19431956    AssertMsgReturn(pRange,
    1944                     ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys),
    1945                     VERR_IOM_MMIO_RANGE_NOT_FOUND);
     1957            ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
    19461958    Assert((pRange->GCPhys       & PAGE_OFFSET_MASK) == 0);
    19471959    Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
     1960#endif
    19481961
    19491962    /*
     
    19531966    HCPhys &= ~(RTHCPHYS)PAGE_OFFSET_MASK;
    19541967
    1955     int rc = PGMHandlerPhysicalPageAliasHC(pVM, pRange->GCPhys, GCPhys, HCPhys);
     1968    int rc = PGMHandlerPhysicalPageAliasHC(pVM, GCPhys, GCPhys, HCPhys);
    19561969    AssertRCReturn(rc, rc);
    19571970
     
    19902003     * Lookup the context range node the page belongs to.
    19912004     */
    1992     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     2005#ifdef VBOX_STRICT
     2006    /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
     2007    PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(&pVM->iom.s, GCPhys);
    19932008    AssertMsgReturn(pRange,
    1994                     ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys),
    1995                     VERR_IOM_MMIO_RANGE_NOT_FOUND);
     2009            ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     2010    Assert((pRange->GCPhys       & PAGE_OFFSET_MASK) == 0);
     2011    Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
     2012#endif
    19962013
    19972014    /*
     
    20012018     * a page pool flush pending (unlikely).
    20022019     */
    2003     int rc = PGMHandlerPhysicalReset(pVM, pRange->GCPhys);
     2020    int rc = PGMHandlerPhysicalReset(pVM, GCPhys);
    20042021    AssertRC(rc);
    20052022
Note: See TracChangeset for help on using the changeset viewer.

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