Skip to content

Commit 60d90e1

Browse files
willdeacongregkh
authored andcommitted
KVM: arm64: Don't pass a TLBI level hint when zapping table entries
commit 36e0083 upstream. The TLBI level hints are for leaf entries only, so take care not to pass them incorrectly after clearing a table entry. Cc: Gavin Shan <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Quentin Perret <[email protected]> Fixes: 82bb024 ("KVM: arm64: Implement kvm_pgtable_hyp_unmap() at EL2") Fixes: 6d9d211 ("KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table") Signed-off-by: Will Deacon <[email protected]> Reviewed-by: Shaoqin Huang <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]> Cc: <[email protected]> # 6.6.y only [will@: Use '0' instead of TLBI_TTL_UNKNOWN to indicate "no level"] Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2c77008 commit 60d90e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int hyp_unmap_walker(const struct kvm_pgtable_visit_ctx *ctx,
523523

524524
kvm_clear_pte(ctx->ptep);
525525
dsb(ishst);
526-
__tlbi_level(vae2is, __TLBI_VADDR(ctx->addr, 0), ctx->level);
526+
__tlbi_level(vae2is, __TLBI_VADDR(ctx->addr, 0), 0);
527527
} else {
528528
if (ctx->end - ctx->addr < granule)
529529
return -EINVAL;
@@ -861,10 +861,12 @@ static void stage2_unmap_put_pte(const struct kvm_pgtable_visit_ctx *ctx,
861861
if (kvm_pte_valid(ctx->old)) {
862862
kvm_clear_pte(ctx->ptep);
863863

864-
if (!stage2_unmap_defer_tlb_flush(pgt) ||
865-
kvm_pte_table(ctx->old, ctx->level)) {
866-
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu,
867-
ctx->addr, ctx->level);
864+
if (kvm_pte_table(ctx->old, ctx->level)) {
865+
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, ctx->addr,
866+
0);
867+
} else if (!stage2_unmap_defer_tlb_flush(pgt)) {
868+
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, ctx->addr,
869+
ctx->level);
868870
}
869871
}
870872

0 commit comments

Comments
 (0)