1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com> 4 * Copyright (C) 2012 Regents of the University of California 5 */ 6 7 #ifndef _ASM_RISCV_TLBFLUSH_H 8 #define _ASM_RISCV_TLBFLUSH_H 9 10 #include <linux/mm_types.h> 11 #include <asm/smp.h> 12 13 static inline void local_flush_tlb_all(void) 14 { 15 __asm__ __volatile__ ("sfence.vma" : : : "memory"); 16 } 17 18 /* Flush one page from local TLB */ 19 static inline void local_flush_tlb_page(unsigned long addr) 20 { 21 __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"); 22 } 23 24 #ifdef CONFIG_SMP 25 void flush_tlb_all(void); 26 void flush_tlb_mm(struct mm_struct *mm); 27 void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr); 28 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, 29 unsigned long end); 30 #else /* CONFIG_SMP */ 31 #define flush_tlb_all() local_flush_tlb_all() 32 #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) 33 34 static inline void flush_tlb_range(struct vm_area_struct *vma, 35 unsigned long start, unsigned long end) 36 { 37 local_flush_tlb_all(); 38 } 39 40 #define flush_tlb_mm(mm) flush_tlb_all() 41 #endif /* CONFIG_SMP */ 42 43 /* Flush a range of kernel pages */ 44 static inline void flush_tlb_kernel_range(unsigned long start, 45 unsigned long end) 46 { 47 flush_tlb_all(); 48 } 49 50 #endif /* _ASM_RISCV_TLBFLUSH_H */ 51