VirtualBox

Changeset 87712 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Feb 11, 2021 6:14:13 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142756
Message:

AMD IOMMU: bugref:9654 IOTLB cache bits.

File:
1 edited

Legend:

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

    r87711 r87712  
    902902
    903903/**
    904  * Removes an IOTLB entry from the cache for the given key.
    905  *
    906  * @returns Pointer to the removed IOTLB entry, NULL if the entry wasn't found in
    907  *          the tree.
    908  * @param   pThis   The IOMMU device state.
    909  * @param   uKey    The key of the IOTLB entry to remove.
    910  */
    911 static PIOTLBE iommuAmdIotlbEntryRemove(PIOMMU pThis, AVLU64KEY uKey)
    912 {
    913     PIOTLBE pIotlbe = (PIOTLBE)RTAvlU64Remove(&pThis->TreeIotlbe, uKey);
    914     if (pIotlbe)
    915     {
    916         Assert(pThis->cCachedIotlbes > 0);
    917         --pThis->cCachedIotlbes;
    918         STAM_COUNTER_DEC(&pThis->StatIotlbeCached);
    919     }
    920     return pIotlbe;
    921 }
    922 
    923 
    924 /**
    925904 * Destroys an IOTLB entry.
    926905 *
     
    939918
    940919/**
     920 * Removes an IOTLB entry from the cache for the given key.
     921 *
     922 * @returns Pointer to the removed IOTLB entry, NULL if the entry wasn't found in
     923 *          the tree.
     924 * @param   pThis   The IOMMU device state.
     925 * @param   uKey    The key of the IOTLB entry to remove.
     926 */
     927static PIOTLBE iommuAmdIotlbEntryRemove(PIOMMU pThis, AVLU64KEY uKey)
     928{
     929    PIOTLBE pIotlbe = (PIOTLBE)RTAvlU64Remove(&pThis->TreeIotlbe, uKey);
     930    if (pIotlbe)
     931    {
     932        if (pIotlbe->fEvictPending)
     933            STAM_COUNTER_INC(&pThis->StatIotlbeLazyEvictReuse);
     934        iommuAmdIotlbEntryDestroy(pIotlbe);
     935        Assert(!pIotlbe->fEvictPending);
     936        Assert(pThis->cCachedIotlbes > 0);
     937        --pThis->cCachedIotlbes;
     938        STAM_COUNTER_DEC(&pThis->StatIotlbeCached);
     939    }
     940    return pIotlbe;
     941}
     942
     943
     944/**
    941945 * Looks up an IOTLB from the cache.
    942946 *
     
    950954    uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(uDomainId, uIova);
    951955    PIOTLBE pIotlbe = (PIOTLBE)RTAvlU64Get(&pThis->TreeIotlbe, uKey);
    952     if (   pIotlbe
    953         && pIotlbe->fEvictPending)
    954     {
    955         /*
    956          * Domain Id wildcard invalidations only marks entries for eviction later but doesn't remove
    957          * them from the cache immediately. Here we found one such entry, so remove it and move it to
    958          * the LRU list and return that the lookup failed as it should.
    959          */
    960         iommuAmdIotlbEntryRemove(pThis, pIotlbe->Core.Key);
    961         iommuAmdIotlbEntryDestroy(pIotlbe);
    962         Assert(!pIotlbe->fEvictPending);
    963         STAM_COUNTER_INC(&pThis->StatIotlbeLazyEvictReuse);
    964         iommuAmdIotlbEntryMoveToLru(pThis, pIotlbe);
    965         return NULL;
    966     }
    967     return pIotlbe;
     956    if (    pIotlbe
     957        && !pIotlbe->fEvictPending)
     958        return pIotlbe;
     959
     960    /*
     961     * Domain Id wildcard invalidations only marks entries for eviction later but doesn't remove
     962     * them from the cache immediately. We found an entry pending eviction, just return that
     963     * nothing was found (rather than evicting now).
     964     */
     965    return NULL;
    968966}
    969967
     
    996994        /* If the entry is in the cache, remove it. */
    997995        if (pIotlbe->Core.Key != IOMMU_IOTLB_KEY_NIL)
    998         {
    999             if (pIotlbe->fEvictPending)
    1000                 STAM_COUNTER_INC(&pThis->StatIotlbeLazyEvictReuse);
    1001996            iommuAmdIotlbEntryRemove(pThis, pIotlbe->Core.Key);
    1002             iommuAmdIotlbEntryDestroy(pIotlbe);
    1003         }
    1004997
    1005998        /* Initialize and insert the IOTLB entry into the cache. */
     
    10721065        PIOTLBE pIotlbe = iommuAmdIotlbEntryRemove(pThis, uKey);
    10731066        if (pIotlbe)
    1074         {
    1075             iommuAmdIotlbEntryDestroy(pIotlbe);
    10761067            iommuAmdIotlbEntryMoveToLru(pThis, pIotlbe);
    1077         }
    10781068        uIova        += X86_PAGE_4K_SIZE;
    10791069        cbInvalidate -= X86_PAGE_4K_SIZE;
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