tlbflush.h 1.8 KB

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