[PATCH 0/5] Improve the invalidation path in AMD

Jason Gunthorpe
2026-03-27T15:24:04Z

Auditing this path reveals some unnecessary complexity and some
confusion around end/size/last and types that may cause issues at the
ULONG_MAX limit.

First, fix up the call chains so that the gather start/last is
retained faithfully throughout. This avoids converting to a
start/size, and avoids various type conversions along this path. Fix
everything so the theoretical cases like start=0 last=U64_MAX work
correctly.

Simplify all the calculations for alignment/etc to use trivial bit
maths instead of the complicated versions. These are all intended to
be no functional change.

Finally, add support for PDE=0, deriving it from the gather. PDE=0
allows the HW to avoid scanning the page directory cache and
supporting it should improve performance.

Jason Gunthorpe (5):
iommu/amd: Simplify build_inv_address()
iommu/amd: Pass last in through to build_inv_address()
iommu/amd: Have amd_iommu_domain_flush_pages() use last
iommu/amd: Make CMD_INV_IOMMU_ALL_PAGES_ADDRESS match the spec
iommu/amd: Control INVALIDATE_IOMMU_PAGES PDE from the gather

drivers/iommu/amd/amd_iommu.h | 4 +-
drivers/iommu/amd/amd_iommu_types.h | 2 +-
drivers/iommu/amd/iommu.c | 175 +++++++++++++---------------
drivers/iommu/amd/pasid.c | 2 +-
4 files changed, 87 insertions(+), 96 deletions(-)

base-commit: 6c8f61b36b7efec0f8bc284142f998d30f0a28ba
--
2.43.0