Skip to content

Commit 3a0b870

Browse files
YananWang-hubMarc Zyngier
authored andcommitted
KVM: arm64: Fix handling of merging tables into a block entry
When dirty logging is enabled, we collapse block entries into tables as necessary. If dirty logging gets canceled, we can end-up merging tables back into block entries. When this happens, we must not only free the non-huge page-table pages but also invalidate all the TLB entries that can potentially cover the block. Otherwise, we end-up with multiple possible translations for the same physical page, which can legitimately result in a TLB conflict. To address this, replease the bogus invalidation by IPA with a full VM invalidation. Although this is pretty heavy handed, it happens very infrequently and saves a bunch of invalidations by IPA. Signed-off-by: Yanan Wang <[email protected]> [maz: fixup commit message] Signed-off-by: Marc Zyngier <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5c646b7 commit 3a0b870

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,13 @@ static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level,
502502
return 0;
503503

504504
kvm_set_invalid_pte(ptep);
505-
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, data->mmu, addr, 0);
505+
506+
/*
507+
* Invalidate the whole stage-2, as we may have numerous leaf
508+
* entries below us which would otherwise need invalidating
509+
* individually.
510+
*/
511+
kvm_call_hyp(__kvm_tlb_flush_vmid, data->mmu);
506512
data->anchor = ptep;
507513
return 0;
508514
}

0 commit comments

Comments
 (0)