1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
4 * Copyright (C) 2012 Regents of the University of California
7 #ifndef _ASM_RISCV_TLBFLUSH_H
8 #define _ASM_RISCV_TLBFLUSH_H
10 #include <linux/mm_types.h>
12 #include <asm/errata_list.h>
15 extern unsigned long asid_mask;
17 static inline void local_flush_tlb_all(void)
19 __asm__ __volatile__ ("sfence.vma" : : : "memory");
22 /* Flush one page from local TLB */
23 static inline void local_flush_tlb_page(unsigned long addr)
25 ALT_FLUSH_TLB_PAGE(__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"));
27 #else /* CONFIG_MMU */
28 #define local_flush_tlb_all() do { } while (0)
29 #define local_flush_tlb_page(addr) do { } while (0)
30 #endif /* CONFIG_MMU */
32 #if defined(CONFIG_SMP) && defined(CONFIG_MMU)
33 void flush_tlb_all(void);
34 void flush_tlb_mm(struct mm_struct *mm);
35 void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr);
36 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
38 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
39 #define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
40 void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
43 #else /* CONFIG_SMP && CONFIG_MMU */
45 #define flush_tlb_all() local_flush_tlb_all()
46 #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
48 static inline void flush_tlb_range(struct vm_area_struct *vma,
49 unsigned long start, unsigned long end)
51 local_flush_tlb_all();
54 #define flush_tlb_mm(mm) flush_tlb_all()
55 #endif /* !CONFIG_SMP || !CONFIG_MMU */
57 /* Flush a range of kernel pages */
58 static inline void flush_tlb_kernel_range(unsigned long start,
64 #endif /* _ASM_RISCV_TLBFLUSH_H */