Changeset 20722 in vbox
- Timestamp:
- Jun 19, 2009 12:34:21 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48835
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/IOM.cpp
r20700 r20722 1535 1535 * Find the MMIO range and check that the input matches. 1536 1536 */ 1537 iomLock(pVM); 1537 1538 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhysStart); 1538 AssertReturn (pRange, VERR_IOM_MMIO_RANGE_NOT_FOUND);1539 AssertReturn (pRange->pDevInsR3 == pDevIns, VERR_IOM_NOT_MMIO_RANGE_OWNER);1540 AssertReturn (pRange->GCPhys == GCPhysStart, VERR_IOM_INVALID_MMIO_RANGE);1541 AssertReturn (pRange->cb == cbRange, VERR_IOM_INVALID_MMIO_RANGE);1539 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1540 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); 1541 AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1542 AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1542 1543 1543 1544 pRange->pvUserRC = pvUser; … … 1546 1547 pRange->pfnFillCallbackRC = pfnFillCallback; 1547 1548 pRange->pDevInsRC = MMHyperCCToRC(pVM, pDevIns); 1549 iomUnlock(pVM); 1548 1550 1549 1551 return VINF_SUCCESS; … … 1589 1591 * Find the MMIO range and check that the input matches. 1590 1592 */ 1593 iomLock(pVM); 1591 1594 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhysStart); 1592 AssertReturn (pRange, VERR_IOM_MMIO_RANGE_NOT_FOUND);1593 AssertReturn (pRange->pDevInsR3 == pDevIns, VERR_IOM_NOT_MMIO_RANGE_OWNER);1594 AssertReturn (pRange->GCPhys == GCPhysStart, VERR_IOM_INVALID_MMIO_RANGE);1595 AssertReturn (pRange->cb == cbRange, VERR_IOM_INVALID_MMIO_RANGE);1595 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1596 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); 1597 AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1598 AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1596 1599 1597 1600 pRange->pvUserR0 = pvUser; … … 1600 1603 pRange->pfnFillCallbackR0 = pfnFillCallback; 1601 1604 pRange->pDevInsR0 = MMHyperCCToR0(pVM, pDevIns); 1605 iomUnlock(pVM); 1602 1606 1603 1607 return VINF_SUCCESS; -
trunk/src/VBox/VMM/IOMInternal.h
r20700 r20722 473 473 DECLINLINE(CTX_SUFF(PIOMIOPORTRANGE)) iomIOPortGetRange(PIOM pIOM, RTIOPORT Port) 474 474 { 475 #ifdef IN_RING3 476 if (PDMCritSectIsInitialized(&pIOM->EmtLock)) 477 #endif 478 Assert(IOMIsLockOwner(IOM2VM(pIOM))); 475 479 CTX_SUFF(PIOMIOPORTRANGE) pRange = (CTX_SUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->CTX_SUFF(IOPortTree), Port); 476 480 return pRange; … … 489 493 DECLINLINE(PIOMIOPORTRANGER3) iomIOPortGetRangeR3(PIOM pIOM, RTIOPORT Port) 490 494 { 495 #ifdef IN_RING3 496 if (PDMCritSectIsInitialized(&pIOM->EmtLock)) 497 #endif 498 Assert(IOMIsLockOwner(IOM2VM(pIOM))); 491 499 PIOMIOPORTRANGER3 pRange = (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->IOPortTreeR3, Port); 492 500 return pRange; … … 505 513 DECLINLINE(PIOMMMIORANGE) iomMMIOGetRange(PIOM pIOM, RTGCPHYS GCPhys) 506 514 { 515 #ifdef IN_RING3 516 if (PDMCritSectIsInitialized(&pIOM->EmtLock)) 517 #endif 518 Assert(IOMIsLockOwner(IOM2VM(pIOM))); 507 519 PIOMMMIORANGE pRange = pIOM->CTX_SUFF(pMMIORangeLast); 508 520 if ( !pRange … … 511 523 return pRange; 512 524 } 525 526 #ifdef VBOX_STRICT 527 /** 528 * Gets the MMIO range for the specified physical address in the current context. 529 * 530 * @returns Pointer to MMIO range. 531 * @returns NULL if address not in a MMIO range. 532 * 533 * @param pIOM IOM instance data. 534 * @param GCPhys Physical address to lookup. 535 */ 536 DECLINLINE(PIOMMMIORANGE) iomMMIOGetRangeUnsafe(PIOM pIOM, RTGCPHYS GCPhys) 537 { 538 PIOMMMIORANGE pRange = pIOM->CTX_SUFF(pMMIORangeLast); 539 if ( !pRange 540 || GCPhys - pRange->GCPhys >= pRange->cb) 541 pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys); 542 return pRange; 543 } 544 #endif 513 545 514 546 -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r20569 r20722 1273 1273 VMMDECL(int) IOMMMIOPhysHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault) 1274 1274 { 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; 1276 1284 } 1277 1285 … … 1865 1873 VMMDECL(int) IOMMMIOMapMMIO2Page(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags) 1866 1874 { 1875 /* Currently only called from the VGA device during MMIO. */ 1876 Assert(IOMIsLockOwner(pVM)); 1867 1877 Log(("IOMMMIOMapMMIO2Page %RGp -> %RGp flags=%RX64\n", GCPhys, GCPhysRemapped, fPageFlags)); 1868 1878 … … 1882 1892 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys); 1883 1893 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 1886 1896 Assert((pRange->GCPhys & PAGE_OFFSET_MASK) == 0); 1887 1897 Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK); … … 1930 1940 VMMDECL(int) IOMMMIOMapMMIOHCPage(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint64_t fPageFlags) 1931 1941 { 1942 /* Currently only called from VT-x code during a page fault. */ 1932 1943 Log(("IOMMMIOMapMMIOHCPage %RGp -> %RGp flags=%RX64\n", GCPhys, HCPhys, fPageFlags)); 1933 1944 … … 1940 1951 * Lookup the context range node the page belongs to. 1941 1952 */ 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); 1943 1956 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); 1946 1958 Assert((pRange->GCPhys & PAGE_OFFSET_MASK) == 0); 1947 1959 Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK); 1960 #endif 1948 1961 1949 1962 /* … … 1953 1966 HCPhys &= ~(RTHCPHYS)PAGE_OFFSET_MASK; 1954 1967 1955 int rc = PGMHandlerPhysicalPageAliasHC(pVM, pRange->GCPhys, GCPhys, HCPhys);1968 int rc = PGMHandlerPhysicalPageAliasHC(pVM, GCPhys, GCPhys, HCPhys); 1956 1969 AssertRCReturn(rc, rc); 1957 1970 … … 1990 2003 * Lookup the context range node the page belongs to. 1991 2004 */ 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); 1993 2008 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 1996 2013 1997 2014 /* … … 2001 2018 * a page pool flush pending (unlikely). 2002 2019 */ 2003 int rc = PGMHandlerPhysicalReset(pVM, pRange->GCPhys);2020 int rc = PGMHandlerPhysicalReset(pVM, GCPhys); 2004 2021 AssertRC(rc); 2005 2022
Note:
See TracChangeset
for help on using the changeset viewer.