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>
14 static inline void local_flush_tlb_all(void)
16 __asm__
__volatile__ ("sfence.vma" : : : "memory");
19 /* Flush one page from local TLB */
20 static inline void local_flush_tlb_page(unsigned long addr
)
22 __asm__
__volatile__ ("sfence.vma %0" : : "r" (addr
) : "memory");
24 #else /* CONFIG_MMU */
25 #define local_flush_tlb_all() do { } while (0)
26 #define local_flush_tlb_page(addr) do { } while (0)
27 #endif /* CONFIG_MMU */
29 #if defined(CONFIG_SMP) && defined(CONFIG_MMU)
30 void flush_tlb_all(void);
31 void flush_tlb_mm(struct mm_struct
*mm
);
32 void flush_tlb_page(struct vm_area_struct
*vma
, unsigned long addr
);
33 void flush_tlb_range(struct vm_area_struct
*vma
, unsigned long start
,
35 #else /* CONFIG_SMP && CONFIG_MMU */
37 #define flush_tlb_all() local_flush_tlb_all()
38 #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
40 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
41 unsigned long start
, unsigned long end
)
43 local_flush_tlb_all();
46 #define flush_tlb_mm(mm) flush_tlb_all()
47 #endif /* !CONFIG_SMP || !CONFIG_MMU */
49 /* Flush a range of kernel pages */
50 static inline void flush_tlb_kernel_range(unsigned long start
,
56 #endif /* _ASM_RISCV_TLBFLUSH_H */