tlbflush.h 1.8 KB

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