xref: /openbmc/linux/arch/riscv/mm/tlbflush.c (revision ecd25094)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/mm.h>
4 #include <linux/smp.h>
5 #include <asm/sbi.h>
6 
7 void flush_tlb_all(void)
8 {
9 	sbi_remote_sfence_vma(NULL, 0, -1);
10 }
11 
12 static void __sbi_tlb_flush_range(struct cpumask *cmask, unsigned long start,
13 				  unsigned long size)
14 {
15 	struct cpumask hmask;
16 
17 	riscv_cpuid_to_hartid_mask(cmask, &hmask);
18 	sbi_remote_sfence_vma(hmask.bits, start, size);
19 }
20 
21 void flush_tlb_mm(struct mm_struct *mm)
22 {
23 	__sbi_tlb_flush_range(mm_cpumask(mm), 0, -1);
24 }
25 
26 void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
27 {
28 	__sbi_tlb_flush_range(mm_cpumask(vma->vm_mm), addr, PAGE_SIZE);
29 }
30 
31 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
32 		     unsigned long end)
33 {
34 	__sbi_tlb_flush_range(mm_cpumask(vma->vm_mm), start, end - start);
35 }
36