tlbflush.h 3.4 KB

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