tlbflush.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 (*mmc) *mmc = 0;
  50. }
  51. #ifndef CONFIG_SMP
  52. /* Flush everything (kernel mapping may also have changed
  53. due to vmalloc/vfree). */
  54. static inline void flush_tlb_all(void)
  55. {
  56. tbia();
  57. }
  58. /* Flush a specified user mapping. */
  59. static inline void
  60. flush_tlb_mm(struct mm_struct *mm)
  61. {
  62. if (mm == current->active_mm)
  63. flush_tlb_current(mm);
  64. else
  65. flush_tlb_other(mm);
  66. }
  67. /* Page-granular tlb flush. */
  68. static inline void
  69. flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
  70. {
  71. struct mm_struct *mm = vma->vm_mm;
  72. if (mm == current->active_mm)
  73. flush_tlb_current_page(mm, vma, addr);
  74. else
  75. flush_tlb_other(mm);
  76. }
  77. /* Flush a specified range of user mapping. On the Alpha we flush
  78. the whole user tlb. */
  79. static inline void
  80. flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  81. unsigned long end)
  82. {
  83. flush_tlb_mm(vma->vm_mm);
  84. }
  85. #else /* CONFIG_SMP */
  86. extern void flush_tlb_all(void);
  87. extern void flush_tlb_mm(struct mm_struct *);
  88. extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
  89. extern void flush_tlb_range(struct vm_area_struct *, unsigned long,
  90. unsigned long);
  91. #endif /* CONFIG_SMP */
  92. static inline void flush_tlb_kernel_range(unsigned long start,
  93. unsigned long end)
  94. {
  95. flush_tlb_all();
  96. }
  97. #endif /* _ALPHA_TLBFLUSH_H */