3 * Copyright (C) 2012 Regents of the University of California
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef _ASM_RISCV_TLBFLUSH_H
16 #define _ASM_RISCV_TLBFLUSH_H
20 /* Flush entire local TLB */
21 static inline void local_flush_tlb_all(void)
23 __asm__ __volatile__ ("sfence.vma" : : : "memory");
26 /* Flush one page from local TLB */
27 static inline void local_flush_tlb_page(unsigned long addr)
29 __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory");
34 #define flush_tlb_all() local_flush_tlb_all()
35 #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
36 #define flush_tlb_range(vma, start, end) local_flush_tlb_all()
38 #else /* CONFIG_SMP */
42 #define flush_tlb_all() sbi_remote_sfence_vma(0, 0, -1)
43 #define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
44 #define flush_tlb_range(vma, start, end) \
45 sbi_remote_sfence_vma(0, start, (end) - (start))
47 #endif /* CONFIG_SMP */
49 /* Flush the TLB entries of the specified mm context */
50 static inline void flush_tlb_mm(struct mm_struct *mm)
55 /* Flush a range of kernel pages */
56 static inline void flush_tlb_kernel_range(unsigned long start,
62 #endif /* CONFIG_MMU */
64 #endif /* _ASM_RISCV_TLBFLUSH_H */