linux/drivers/iommu/generic_pt
Jason Gunthorpe 58829512ad iommupt: Fix the end_index calculation in __map_range_leaf()
Sashiko noticed a mismatch of units in this math: num_leaves is
actually the number of leaf *entries* (so a 16-item contiguous leaf
is one num_leaves), while index is in items. The mismatch in maths
causes __map_range_leaf() to exit early instead of efficiently
filling a larger range of contiguous PTEs.

The early exit is caught by the functions above and then
__map_range_leaf() is re-invoked, so there is no functional issue.

Correct the misuse of units by adjusting num_leaves with the leaf
size and avoid the performance cost of looping externally.

There are also some mismatched types for num_leaves; simplify
things to remove the duplicated calculations.

Fixes: d6c65b0fd6 ("iommupt: Avoid rewalking during map")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Samiullah Khawaja <skhawaja@google.com>
Reviewd-by: Pranjal Shrivastava <praan@google.com>
Tested-by: Josua Mayer <josua@solid-run.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2026-05-15 07:29:16 +02:00
..
fmt Merge branches 'fixes', 'arm/smmu/updates', 'arm/smmu/bindings', 'riscv', 'intel/vt-d', 'amd/amd-vi' and 'core' into next 2026-04-09 13:18:27 +01:00
.kunitconfig iommupt: Add the RISC-V page table format 2026-03-17 13:14:21 +01:00
iommu_pt.h iommupt: Fix the end_index calculation in __map_range_leaf() 2026-05-15 07:29:16 +02:00
Kconfig iommupt: Add the RISC-V page table format 2026-03-17 13:14:21 +01:00
kunit_generic_pt.h iommupt: Avoid rewalking during map 2026-03-17 13:57:40 +01:00
kunit_iommu_pt.h iommupt: Add a kunit test for the IOMMU implementation 2025-11-05 09:08:58 +01:00
kunit_iommu.h iommu/iommupt: Fix build error in genericpt unit-tests 2025-11-07 16:06:19 +01:00
pt_common.h iommupt: Actually correct pt_test_sw_bit_{acquire_release}() parameter description 2025-11-17 09:46:22 +01:00
pt_defs.h iommupt: Make pt_feature() always_inline 2026-01-10 10:50:45 +01:00
pt_fmt_defaults.h iommupt: Add basic support for SW bits in the page table 2025-11-05 09:47:44 +01:00
pt_iter.h iommupt: Avoid rewalking during map 2026-03-17 13:57:40 +01:00
pt_log2.h