tlbflush.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #ifndef _S390_TLBFLUSH_H
  2. #define _S390_TLBFLUSH_H
  3. #include <linux/mm.h>
  4. #include <asm/processor.h>
  5. /*
  6. * TLB flushing:
  7. *
  8. * - flush_tlb() flushes the current mm struct TLBs
  9. * - flush_tlb_all() flushes all processes TLBs
  10. * - flush_tlb_mm(mm) flushes the specified mm context TLB's
  11. * - flush_tlb_page(vma, vmaddr) flushes one page
  12. * - flush_tlb_range(vma, start, end) flushes a range of pages
  13. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  14. * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
  15. */
  16. /*
  17. * S/390 has three ways of flushing TLBs
  18. * 'ptlb' does a flush of the local processor
  19. * 'csp' flushes the TLBs on all PUs of a SMP
  20. * 'ipte' invalidates a pte in a page table and flushes that out of
  21. * the TLBs of all PUs of a SMP
  22. */
  23. #define local_flush_tlb() \
  24. do { __asm__ __volatile__("ptlb": : :"memory"); } while (0)
  25. #ifndef CONFIG_SMP
  26. /*
  27. * We always need to flush, since s390 does not flush tlb
  28. * on each context switch
  29. */
  30. static inline void flush_tlb(void)
  31. {
  32. local_flush_tlb();
  33. }
  34. static inline void flush_tlb_all(void)
  35. {
  36. local_flush_tlb();
  37. }
  38. static inline void flush_tlb_mm(struct mm_struct *mm)
  39. {
  40. local_flush_tlb();
  41. }
  42. static inline void flush_tlb_page(struct vm_area_struct *vma,
  43. unsigned long addr)
  44. {
  45. local_flush_tlb();
  46. }
  47. static inline void flush_tlb_range(struct vm_area_struct *vma,
  48. unsigned long start, unsigned long end)
  49. {
  50. local_flush_tlb();
  51. }
  52. #define flush_tlb_kernel_range(start, end) \
  53. local_flush_tlb();
  54. #else
  55. #include <asm/smp.h>
  56. extern void smp_ptlb_all(void);
  57. static inline void global_flush_tlb(void)
  58. {
  59. #ifndef __s390x__
  60. if (!MACHINE_HAS_CSP) {
  61. smp_ptlb_all();
  62. return;
  63. }
  64. #endif /* __s390x__ */
  65. {
  66. register unsigned long addr asm("4");
  67. long dummy;
  68. dummy = 0;
  69. addr = ((unsigned long) &dummy) + 1;
  70. __asm__ __volatile__ (
  71. " slr 2,2\n"
  72. " slr 3,3\n"
  73. " csp 2,%0"
  74. : : "a" (addr), "m" (dummy) : "cc", "2", "3" );
  75. }
  76. }
  77. /*
  78. * We only have to do global flush of tlb if process run since last
  79. * flush on any other pu than current.
  80. * If we have threads (mm->count > 1) we always do a global flush,
  81. * since the process runs on more than one processor at the same time.
  82. */
  83. static inline void __flush_tlb_mm(struct mm_struct * mm)
  84. {
  85. cpumask_t local_cpumask;
  86. if (unlikely(cpus_empty(mm->cpu_vm_mask)))
  87. return;
  88. if (MACHINE_HAS_IDTE) {
  89. asm volatile (".insn rrf,0xb98e0000,0,%0,%1,0"
  90. : : "a" (2048),
  91. "a" (__pa(mm->pgd)&PAGE_MASK) : "cc" );
  92. return;
  93. }
  94. preempt_disable();
  95. local_cpumask = cpumask_of_cpu(smp_processor_id());
  96. if (cpus_equal(mm->cpu_vm_mask, local_cpumask))
  97. local_flush_tlb();
  98. else
  99. global_flush_tlb();
  100. preempt_enable();
  101. }
  102. static inline void flush_tlb(void)
  103. {
  104. __flush_tlb_mm(current->mm);
  105. }
  106. static inline void flush_tlb_all(void)
  107. {
  108. global_flush_tlb();
  109. }
  110. static inline void flush_tlb_mm(struct mm_struct *mm)
  111. {
  112. __flush_tlb_mm(mm);
  113. }
  114. static inline void flush_tlb_page(struct vm_area_struct *vma,
  115. unsigned long addr)
  116. {
  117. __flush_tlb_mm(vma->vm_mm);
  118. }
  119. static inline void flush_tlb_range(struct vm_area_struct *vma,
  120. unsigned long start, unsigned long end)
  121. {
  122. __flush_tlb_mm(vma->vm_mm);
  123. }
  124. #define flush_tlb_kernel_range(start, end) global_flush_tlb()
  125. #endif
  126. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  127. unsigned long start, unsigned long end)
  128. {
  129. /* S/390 does not keep any page table caches in TLB */
  130. }
  131. #endif /* _S390_TLBFLUSH_H */