arm64: tlbflush: Ensure start/end of address range are aligned to stride
authorWill Deacon <[email protected]>
Tue, 11 Jun 2019 11:47:34 +0000 (12:47 +0100)
committerWill Deacon <[email protected]>
Wed, 12 Jun 2019 15:19:45 +0000 (16:19 +0100)
Since commit 3d65b6bbc01e ("arm64: tlbi: Set MAX_TLBI_OPS to
PTRS_PER_PTE"), we resort to per-ASID invalidation when attempting to
perform more than PTRS_PER_PTE invalidation instructions in a single
call to __flush_tlb_range(). Whilst this is beneficial, the mmu_gather
code does not ensure that the end address of the range is rounded-up
to the stride when freeing intermediate page tables in pXX_free_tlb(),
which defeats our range checking.

Align the bounds passed into __flush_tlb_range().

Cc: Catalin Marinas <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Reported-by: Hanjun Guo <[email protected]>
Tested-by: Hanjun Guo <[email protected]>
Reviewed-by: Hanjun Guo <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
arch/arm64/include/asm/tlbflush.h

index 3a18702289469450e37532a0c989ea527fd96c5a..dff8f9ea5754f97ac92346094aff563d706cc052 100644 (file)
@@ -195,6 +195,9 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
        unsigned long asid = ASID(vma->vm_mm);
        unsigned long addr;
 
+       start = round_down(start, stride);
+       end = round_up(end, stride);
+
        if ((end - start) >= (MAX_TLBI_OPS * stride)) {
                flush_tlb_mm(vma->vm_mm);
                return;