Changeset 87712 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 11, 2021 6:14:13 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142756
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r87711 r87712 902 902 903 903 /** 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 in907 * 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 /**925 904 * Destroys an IOTLB entry. 926 905 * … … 939 918 940 919 /** 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 */ 927 static 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 /** 941 945 * Looks up an IOTLB from the cache. 942 946 * … … 950 954 uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(uDomainId, uIova); 951 955 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; 968 966 } 969 967 … … 996 994 /* If the entry is in the cache, remove it. */ 997 995 if (pIotlbe->Core.Key != IOMMU_IOTLB_KEY_NIL) 998 {999 if (pIotlbe->fEvictPending)1000 STAM_COUNTER_INC(&pThis->StatIotlbeLazyEvictReuse);1001 996 iommuAmdIotlbEntryRemove(pThis, pIotlbe->Core.Key); 1002 iommuAmdIotlbEntryDestroy(pIotlbe);1003 }1004 997 1005 998 /* Initialize and insert the IOTLB entry into the cache. */ … … 1072 1065 PIOTLBE pIotlbe = iommuAmdIotlbEntryRemove(pThis, uKey); 1073 1066 if (pIotlbe) 1074 {1075 iommuAmdIotlbEntryDestroy(pIotlbe);1076 1067 iommuAmdIotlbEntryMoveToLru(pThis, pIotlbe); 1077 }1078 1068 uIova += X86_PAGE_4K_SIZE; 1079 1069 cbInvalidate -= X86_PAGE_4K_SIZE;
Note:
See TracChangeset
for help on using the changeset viewer.