VirtualBox

Changeset 87426 in vbox for trunk/src/VBox/Devices/Bus


Ignore:
Timestamp:
Jan 26, 2021 4:56:25 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142432
Message:

AMD IOMMU: bugref:9654 IOTLB cache bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp

    r87415 r87426  
    216216    /** LRU list anchor for IOTLB entries. */
    217217    RTLISTANCHOR                LstLruIotlbe;
    218     /** Number of cached IOTLBEs. */
     218    /** Index of the next unused IOTLB. */
     219    uint32_t                    idxUnusedIotlbe;
     220    /** Number of cached IOTLB entries in the tree. */
    219221    uint32_t                    cCachedIotlbes;
    220     /** Padding. */
    221     uint32_t                    uPadding1;
    222222#endif
    223223
     
    643643     */
    644644    PIOTLBE pIotlbe;
    645     if (pThis->cCachedIotlbes == IOMMU_IOTLBE_MAX)
     645    if (pThis->idxUnusedIotlbe == IOMMU_IOTLBE_MAX)
    646646    {
    647647        pIotlbe = RTListRemoveFirst(&pThis->LstLruIotlbe, IOTLBE, NdLru);
    648648        Assert(pIotlbe);
    649649        RTAvlrU64Remove(&pThis->TreeIotlbe, pIotlbe->Core.Key);
     650        Assert(pThis->cCachedIotlbes > 0);
    650651        --pThis->cCachedIotlbes;
    651652    }
    652653    else
    653654    {
    654         pIotlbe = &pThis->paIotlbes[pThis->cCachedIotlbes];
    655         ++pThis->cCachedIotlbes;
    656         /* IOTLB entries have alredy been zero'ed during allocation. */
     655        pIotlbe = &pThis->paIotlbes[pThis->idxUnusedIotlbe];
     656        ++pThis->idxUnusedIotlbe;
    657657    }
    658658
     
    668668    /* Add the entry to the cache. */
    669669    RTAvlrU64Insert(&pThis->TreeIotlbe, &pIotlbe->Core);
     670    ++pThis->cCachedIotlbes;
    670671
    671672    /* Mark the entry as the most recently used one. */
     
    683684    RTListInit(&pThis->LstLruIotlbe);
    684685    RTAvlrU64Destroy(&pThis->TreeIotlbe, iommuAmdDestroyIotlbe, NULL /* pvParam */);
    685     pThis->cCachedIotlbes = 0;
     686    pThis->cCachedIotlbes  = 0;
     687    pThis->idxUnusedIotlbe = 0;
    686688    size_t const cbIotlbes = sizeof(IOTLBE) * IOMMU_IOTLBE_MAX;
    687689    RT_BZERO(pThis->paIotlbes, cbIotlbes);
     
    714716         * We remove all ranges (in our tree) containing the range of I/O virtual addresses requesting
    715717         * to be invalidated. E.g., if the guest is using 1M pages but requests to invalidate only 8K
    716          * we invalidate the entire 1M page. On the other hand, we must handle cross-boundary requests
    717          * that spans multiple pages. E.g., if the guest is using 4K pages but requests to invalid 8K,
    718          * we would need to invalid two 4K pages.
     718         * we must invalidate the entire 1M page. On the other hand, we must handle cross-boundary
     719         * requests that spans multiple pages. E.g., if the guest is using 4K pages but requests to
     720         * invalid 8K, we would need to invalid two 4K pages.
    719721         */
    720722        uint64_t const uIovaLast = uIova + RT_BIT_64(cShift) - 1;
     
    725727            if (pIotlbe)
    726728            {
     729                --pThis->cCachedIotlbes;
    727730                uint64_t const uRangeIovaLast = pIotlbe->Core.KeyLast;
    728731                RTListNodeRemove(&pIotlbe->NdLru);
    729                 --pThis->cCachedIotlbes;
     732                RTListPrepend(&pThis->LstLruIotlbe, &pIotlbe->NdLru);
    730733                RT_ZERO(*pIotlbe);
    731734                if (uIovaLast > uRangeIovaLast)
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