Skip to content

Commit 52218fc

Browse files
Zhenyu Yewilldeacon
authored andcommitted
arm64: tlb: fix the TTL value of tlb_get_level
The TTL field indicates the level of page table walk holding the *leaf* entry for the address being invalidated. But currently, the TTL field may be set to an incorrent value in the following stack: pte_free_tlb __pte_free_tlb tlb_remove_table tlb_table_invalidate tlb_flush_mmu_tlbonly tlb_flush In this case, we just want to flush a PTE page, but the tlb->cleared_pmds is set and we get tlb_level = 2 in the tlb_get_level() function. This may cause some unexpected problems. This patch set the TTL field to 0 if tlb->freed_tables is set. The tlb->freed_tables indicates page table pages are freed, not the leaf entry. Cc: <stable@vger.kernel.org> # 5.9.x Fixes: c4ab2cb ("arm64: tlb: Set the TTL field in flush_tlb_range") Acked-by: Catalin Marinas <catalin.marinas@arm.com> Reported-by: ZhuRui <zhurui3@huawei.com> Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com> Link: https://lore.kernel.org/r/b80ead47-1f88-3a00-18e1-cacc22f54cc4@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 2062d44 commit 52218fc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • arch/arm64/include/asm

arch/arm64/include/asm/tlb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather *tlb);
2828
*/
2929
static inline int tlb_get_level(struct mmu_gather *tlb)
3030
{
31+
/* The TTL field is only valid for the leaf entry. */
32+
if (tlb->freed_tables)
33+
return 0;
34+
3135
if (tlb->cleared_ptes && !(tlb->cleared_pmds ||
3236
tlb->cleared_puds ||
3337
tlb->cleared_p4ds))

0 commit comments

Comments
 (0)