tlbflush.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ALPHA_TLBFLUSH_H
  3. #define _ALPHA_TLBFLUSH_H
  4. #include <linux/mm.h>
  5. #include <linux/sched.h>
  6. #include <asm/compiler.h>
  7. #ifndef __EXTERN_INLINE
  8. #define __EXTERN_INLINE extern inline
  9. #define __MMU_EXTERN_INLINE
  10. #endif
  11. extern void __load_new_mm_context(struct mm_struct *);
  12. __EXTERN_INLINE void
  13. ev5_flush_tlb_current(struct mm_struct *mm)
  14. {
  15. __load_new_mm_context(mm);
  16. }
  17. /* Flush just one page in the current TLB set. We need to be very
  18. careful about the icache here, there is no way to invalidate a
  19. specific icache page. */
  20. __EXTERN_INLINE void
  21. ev5_flush_tlb_current_page(struct mm_struct * mm,
  22. struct vm_area_struct *vma,
  23. unsigned long addr)
  24. {
  25. if (vma->vm_flags & VM_EXEC)
  26. __load_new_mm_context(mm);
  27. else
  28. tbi(2, addr);
  29. }
  30. #define flush_tlb_current ev5_flush_tlb_current
  31. #define flush_tlb_current_page ev5_flush_tlb_current_page
  32. #ifdef __MMU_EXTERN_INLINE
  33. #undef __EXTERN_INLINE
  34. #undef __MMU_EXTERN_INLINE
  35. #endif
  36. /* Flush current user mapping. */
  37. static inline void
  38. flush_tlb(void)
  39. {
  40. flush_tlb_current(current->active_mm);
  41. }
  42. /* Flush someone else's user mapping. */
  43. static inline void
  44. flush_tlb_other(struct mm_struct *mm)
  45. {
  46. unsigned long *mmc = &mm->context[smp_processor_id()];
  47. /* Check it's not zero first to avoid cacheline ping pong
  48. when possible. */
  49. if (READ_ONCE(*mmc))
  50. WRITE_ONCE(*mmc, 0);
  51. }
  52. #ifndef CONFIG_SMP
  53. /* Flush everything (kernel mapping may also have changed
  54. due to vmalloc/vfree). */
  55. static inline void flush_tlb_all(void)
  56. {
  57. tbia();
  58. }
  59. /* Flush a specified user mapping. */
  60. static inline void
  61. flush_tlb_mm(struct mm_struct *mm)
  62. {
  63. if (mm == current->active_mm)
  64. flush_tlb_current(mm);
  65. else
  66. flush_tlb_other(mm);
  67. }
  68. /* Page-granular tlb flush. */
  69. static inline void
  70. flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
  71. {
  72. struct mm_struct *mm = vma->vm_mm;
  73. if (mm == current->active_mm)
  74. flush_tlb_current_page(mm, vma, addr);
  75. else
  76. flush_tlb_other(mm);
  77. }
  78. /* Flush a specified range of user mapping. On the Alpha we flush
  79. the whole user tlb. */
  80. static inline void
  81. flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  82. unsigned long end)
  83. {
  84. flush_tlb_mm(vma->vm_mm);
  85. }
  86. #else /* CONFIG_SMP */
  87. extern void flush_tlb_all(void);
  88. extern void flush_tlb_mm(struct mm_struct *);
  89. extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
  90. extern void flush_tlb_range(struct vm_area_struct *, unsigned long,
  91. unsigned long);
  92. #endif /* CONFIG_SMP */
  93. static inline void flush_tlb_kernel_range(unsigned long start,
  94. unsigned long end)
  95. {
  96. flush_tlb_all();
  97. }
  98. #endif /* _ALPHA_TLBFLUSH_H */