ANDROID: KVM: arm64: iommu: Fix upper bound of PT walk

The second argument of the kvm_pgtable_walker callback was
misinterpreted as the end of the current entry, where in fact it is
the end of the walked memory region. Fix this by computing the end of
the current entry from the start and the level.

This did not affect correctness, as the code iterates linarly over
the entire address space, but it did affect boot time.

Bug: 190463801
Bug: 218012133
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I6d189b87645f47cd215a783c1bc9e1f032ff8c62
(cherry picked from commit 58f8121600)
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
David Brazdil
2022-04-06 16:19:58 +01:00
committed by Quentin Perret
parent a3aa8872df
commit 8fda1979fd

View File

@@ -174,12 +174,13 @@ static bool is_mmio_range(phys_addr_t base, size_t size)
return true;
}
static int __snapshot_host_stage2(u64 start, u64 end, u32 level,
static int __snapshot_host_stage2(u64 start, u64 pa_max, u32 level,
kvm_pte_t *ptep,
enum kvm_pgtable_walk_flags flags,
void * const arg)
{
struct pkvm_iommu_driver * const drv = arg;
u64 end = start + kvm_granule_size(level);
enum kvm_pgtable_prot prot;
kvm_pte_t pte = *ptep;