VirtualBox

Changeset 69721 in vbox for trunk


Ignore:
Timestamp:
Nov 16, 2017 7:52:07 PM (7 years ago)
Author:
vboxsync
Message:

Devices/USB: bugref:9022 Update the possibly cached data when writing back endpoint or transfer descriptors. Otherwise a ED/TD might get serviced twice because of the URB completion handler racing the frame processing thread and the frame processing thread operating on stale data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DevOHCI.cpp

    r69500 r69721  
    14271427}
    14281428
     1429
     1430/**
     1431 * Updates the data in the given page cache if the given guest physical address is currently contained
     1432 * in the cache.
     1433 *
     1434 * @returns nothing.
     1435 * @param   pPageCache  The page cache to update.
     1436 * @param   GCPhys      The guest physical address needing the update.
     1437 * @param   pvBuf       Pointer to the buffer to update the page cache with.
     1438 * @param   cbBuf       Number of bytes to update.
     1439 */
     1440static void ohciPhysCacheUpdate(POHCIPAGECACHE pPageCache, RTGCPHYS GCPhys, const void *pvBuf, size_t cbBuf)
     1441{
     1442    const RTGCPHYS GCPhysPage = PAGE_ADDRESS(GCPhys);
     1443
     1444    if (GCPhysPage == pPageCache->GCPhysReadCacheAddr)
     1445    {
     1446        uint32_t offPage = GCPhys & PAGE_OFFSET_MASK;
     1447        memcpy(&pPageCache->au8PhysReadCache[offPage], pvBuf, RT_MIN(PAGE_SIZE - offPage, cbBuf));
     1448    }
     1449}
     1450
    14291451static void ohciReadEdCached(POHCI pThis, uint32_t EdAddr, POHCIED pEd)
    14301452{
     
    14351457{
    14361458    ohciPhysReadCacheRead(pThis, pThis->pCacheTD, TdAddr, pTd, sizeof(*pTd));
     1459}
     1460
     1461
     1462/**
     1463 * Update any cached ED data with the given endpoint descriptor at the given address.
     1464 *
     1465 * @returns nothing.
     1466 * @param   pThis       The OHCI instance data.
     1467 * @param   EdAddr      Endpoint descriptor address.
     1468 * @param   pEd         The endpoint descriptor which got updated.
     1469 */
     1470DECLINLINE(void) ohciCacheEdUpdate(POHCI pThis, RTGCPHYS32 EdAddr, PCOHCIED pEd)
     1471{
     1472    ohciPhysCacheUpdate(pThis->pCacheED, EdAddr, pEd, sizeof(*pEd));
     1473}
     1474
     1475
     1476/**
     1477 * Update any cached TD data with the given transfer descriptor at the given address.
     1478 *
     1479 * @returns nothing.
     1480 * @param   pThis       The OHCI instance data.
     1481 * @param   TdAddr      Transfer descriptor address.
     1482 * @param   pTd         The transfer descriptor which got updated.
     1483 */
     1484DECLINLINE(void) ohciCacheTdUpdate(POHCI pThis, RTGCPHYS32 TdAddr, PCOHCITD pTd)
     1485{
     1486    ohciPhysCacheUpdate(pThis->pCacheTD, TdAddr, pTd, sizeof(*pTd));
    14371487}
    14381488
     
    15711621
    15721622    ohciPutDWords(pThis, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2);
     1623#ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE
     1624    ohciCacheEdUpdate(pThis, EdAddr, pEd);
     1625#endif
    15731626}
    15741627
     
    16021655# endif
    16031656    ohciPutDWords(pThis, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2);
     1657#ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE
     1658    ohciCacheTdUpdate(pThis, TdAddr, pTd);
     1659#endif
    16041660}
    16051661
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