Changeset 87426 in vbox for trunk/src/VBox/Devices/Bus
- Timestamp:
- Jan 26, 2021 4:56:25 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142432
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r87415 r87426 216 216 /** LRU list anchor for IOTLB entries. */ 217 217 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. */ 219 221 uint32_t cCachedIotlbes; 220 /** Padding. */221 uint32_t uPadding1;222 222 #endif 223 223 … … 643 643 */ 644 644 PIOTLBE pIotlbe; 645 if (pThis-> cCachedIotlbes== IOMMU_IOTLBE_MAX)645 if (pThis->idxUnusedIotlbe == IOMMU_IOTLBE_MAX) 646 646 { 647 647 pIotlbe = RTListRemoveFirst(&pThis->LstLruIotlbe, IOTLBE, NdLru); 648 648 Assert(pIotlbe); 649 649 RTAvlrU64Remove(&pThis->TreeIotlbe, pIotlbe->Core.Key); 650 Assert(pThis->cCachedIotlbes > 0); 650 651 --pThis->cCachedIotlbes; 651 652 } 652 653 else 653 654 { 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; 657 657 } 658 658 … … 668 668 /* Add the entry to the cache. */ 669 669 RTAvlrU64Insert(&pThis->TreeIotlbe, &pIotlbe->Core); 670 ++pThis->cCachedIotlbes; 670 671 671 672 /* Mark the entry as the most recently used one. */ … … 683 684 RTListInit(&pThis->LstLruIotlbe); 684 685 RTAvlrU64Destroy(&pThis->TreeIotlbe, iommuAmdDestroyIotlbe, NULL /* pvParam */); 685 pThis->cCachedIotlbes = 0; 686 pThis->cCachedIotlbes = 0; 687 pThis->idxUnusedIotlbe = 0; 686 688 size_t const cbIotlbes = sizeof(IOTLBE) * IOMMU_IOTLBE_MAX; 687 689 RT_BZERO(pThis->paIotlbes, cbIotlbes); … … 714 716 * We remove all ranges (in our tree) containing the range of I/O virtual addresses requesting 715 717 * 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 requests717 * 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. 719 721 */ 720 722 uint64_t const uIovaLast = uIova + RT_BIT_64(cShift) - 1; … … 725 727 if (pIotlbe) 726 728 { 729 --pThis->cCachedIotlbes; 727 730 uint64_t const uRangeIovaLast = pIotlbe->Core.KeyLast; 728 731 RTListNodeRemove(&pIotlbe->NdLru); 729 --pThis->cCachedIotlbes;732 RTListPrepend(&pThis->LstLruIotlbe, &pIotlbe->NdLru); 730 733 RT_ZERO(*pIotlbe); 731 734 if (uIovaLast > uRangeIovaLast)
Note:
See TracChangeset
for help on using the changeset viewer.