1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/sched.h>
8 void flush_tlb_all(void)
10 sbi_remote_sfence_vma(NULL
, 0, -1);
14 * This function must not be called with cmask being null.
15 * Kernel may panic if cmask is NULL.
17 static void __sbi_tlb_flush_range(struct cpumask
*cmask
, unsigned long start
,
23 if (cpumask_empty(cmask
))
28 if (cpumask_any_but(cmask
, cpuid
) >= nr_cpu_ids
) {
29 /* local cpu is the only cpu present in cpumask */
30 if (size
<= PAGE_SIZE
)
31 local_flush_tlb_page(start
);
33 local_flush_tlb_all();
35 riscv_cpuid_to_hartid_mask(cmask
, &hmask
);
36 sbi_remote_sfence_vma(cpumask_bits(&hmask
), start
, size
);
42 void flush_tlb_mm(struct mm_struct
*mm
)
44 __sbi_tlb_flush_range(mm_cpumask(mm
), 0, -1);
47 void flush_tlb_page(struct vm_area_struct
*vma
, unsigned long addr
)
49 __sbi_tlb_flush_range(mm_cpumask(vma
->vm_mm
), addr
, PAGE_SIZE
);
52 void flush_tlb_range(struct vm_area_struct
*vma
, unsigned long start
,
55 __sbi_tlb_flush_range(mm_cpumask(vma
->vm_mm
), start
, end
- start
);