18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com> 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Regents of the University of California 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ASM_RISCV_TLBFLUSH_H 88c2ecf20Sopenharmony_ci#define _ASM_RISCV_TLBFLUSH_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 118c2ecf20Sopenharmony_ci#include <asm/smp.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifdef CONFIG_MMU 148c2ecf20Sopenharmony_cistatic inline void local_flush_tlb_all(void) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sfence.vma" : : : "memory"); 178c2ecf20Sopenharmony_ci} 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Flush one page from local TLB */ 208c2ecf20Sopenharmony_cistatic inline void local_flush_tlb_page(unsigned long addr) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"); 238c2ecf20Sopenharmony_ci} 248c2ecf20Sopenharmony_ci#else /* CONFIG_MMU */ 258c2ecf20Sopenharmony_ci#define local_flush_tlb_all() do { } while (0) 268c2ecf20Sopenharmony_ci#define local_flush_tlb_page(addr) do { } while (0) 278c2ecf20Sopenharmony_ci#endif /* CONFIG_MMU */ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#if defined(CONFIG_SMP) && defined(CONFIG_MMU) 308c2ecf20Sopenharmony_civoid flush_tlb_all(void); 318c2ecf20Sopenharmony_civoid flush_tlb_mm(struct mm_struct *mm); 328c2ecf20Sopenharmony_civoid flush_tlb_page(struct vm_area_struct *vma, unsigned long addr); 338c2ecf20Sopenharmony_civoid flush_tlb_range(struct vm_area_struct *vma, unsigned long start, 348c2ecf20Sopenharmony_ci unsigned long end); 358c2ecf20Sopenharmony_ci#else /* CONFIG_SMP && CONFIG_MMU */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define flush_tlb_all() local_flush_tlb_all() 388c2ecf20Sopenharmony_ci#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic inline void flush_tlb_range(struct vm_area_struct *vma, 418c2ecf20Sopenharmony_ci unsigned long start, unsigned long end) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci local_flush_tlb_all(); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define flush_tlb_mm(mm) flush_tlb_all() 478c2ecf20Sopenharmony_ci#endif /* !CONFIG_SMP || !CONFIG_MMU */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* Flush a range of kernel pages */ 508c2ecf20Sopenharmony_cistatic inline void flush_tlb_kernel_range(unsigned long start, 518c2ecf20Sopenharmony_ci unsigned long end) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci flush_tlb_all(); 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#endif /* _ASM_RISCV_TLBFLUSH_H */ 57