Skip to content

Commit f17a0e1

Browse files
committed
KVM: arm64: Ensure target address is granule-aligned for range TLBI
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-427.33.1.el9_4 commit-author Will Deacon <will@kernel.org> commit 4c36a15 When zapping a table entry in stage2_try_break_pte(), we issue range TLB invalidation for the region that was mapped by the table. However, we neglect to align the base address down to the granule size and so if we ended up reaching the table entry via a misaligned address then we will accidentally skip invalidation for some prefix of the affected address range. Align 'ctx->addr' down to the granule size when performing TLB invalidation for an unmapped table in stage2_try_break_pte(). Cc: Raghavendra Rao Ananta <rananta@google.com> Cc: Gavin Shan <gshan@redhat.com> Cc: Shaoqin Huang <shahuang@redhat.com> Cc: Quentin Perret <qperret@google.com> Fixes: defc8cc ("KVM: arm64: Invalidate the table entries upon a range") Signed-off-by: Will Deacon <will@kernel.org> Reviewed-by: Shaoqin Huang <shahuang@redhat.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20240327124853.11206-5-will@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev> (cherry picked from commit 4c36a15) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 567ec7d commit f17a0e1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,15 @@ static bool stage2_try_break_pte(const struct kvm_pgtable_visit_ctx *ctx,
805805
* Perform the appropriate TLB invalidation based on the
806806
* evicted pte value (if any).
807807
*/
808-
if (kvm_pte_table(ctx->old, ctx->level))
809-
kvm_tlb_flush_vmid_range(mmu, ctx->addr,
810-
kvm_granule_size(ctx->level));
811-
else if (kvm_pte_valid(ctx->old))
808+
if (kvm_pte_table(ctx->old, ctx->level)) {
809+
u64 size = kvm_granule_size(ctx->level);
810+
u64 addr = ALIGN_DOWN(ctx->addr, size);
811+
812+
kvm_tlb_flush_vmid_range(mmu, addr, size);
813+
} else if (kvm_pte_valid(ctx->old)) {
812814
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu,
813815
ctx->addr, ctx->level);
816+
}
814817
}
815818

816819
if (stage2_pte_is_counted(ctx->old))

0 commit comments

Comments
 (0)