Skip to content

Commit eed6bfa

Browse files
Ryan Robertswilldeacon
authored andcommitted
arm64: hugetlb: Fix flush_hugetlb_tlb_range() invalidation level
commit c910f2b ("arm64/mm: Update tlb invalidation routines for FEAT_LPA2") changed the "invalidation level unknown" hint from 0 to TLBI_TTL_UNKNOWN (INT_MAX). But the fallback "unknown level" path in flush_hugetlb_tlb_range() was not updated. So as it stands, when trying to invalidate CONT_PMD_SIZE or CONT_PTE_SIZE hugetlb mappings, we will spuriously try to invalidate at level 0 on LPA2-enabled systems. Fix this so that the fallback passes TLBI_TTL_UNKNOWN, and while we are at it, explicitly use the correct stride and level for CONT_PMD_SIZE and CONT_PTE_SIZE, which should provide a minor optimization. Cc: [email protected] Fixes: c910f2b ("arm64/mm: Update tlb invalidation routines for FEAT_LPA2") Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Ryan Roberts <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 49c87f7 commit eed6bfa

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

arch/arm64/include/asm/hugetlb.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,22 @@ static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma,
7676
{
7777
unsigned long stride = huge_page_size(hstate_vma(vma));
7878

79-
if (stride == PMD_SIZE)
80-
__flush_tlb_range(vma, start, end, stride, false, 2);
81-
else if (stride == PUD_SIZE)
82-
__flush_tlb_range(vma, start, end, stride, false, 1);
83-
else
84-
__flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0);
79+
switch (stride) {
80+
#ifndef __PAGETABLE_PMD_FOLDED
81+
case PUD_SIZE:
82+
__flush_tlb_range(vma, start, end, PUD_SIZE, false, 1);
83+
break;
84+
#endif
85+
case CONT_PMD_SIZE:
86+
case PMD_SIZE:
87+
__flush_tlb_range(vma, start, end, PMD_SIZE, false, 2);
88+
break;
89+
case CONT_PTE_SIZE:
90+
__flush_tlb_range(vma, start, end, PAGE_SIZE, false, 3);
91+
break;
92+
default:
93+
__flush_tlb_range(vma, start, end, PAGE_SIZE, false, TLBI_TTL_UNKNOWN);
94+
}
8595
}
8696

8797
#endif /* __ASM_HUGETLB_H */

0 commit comments

Comments
 (0)