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. register unsigned long reg2 asm("2");
  60. register unsigned long reg3 asm("3");
  61. register unsigned long reg4 asm("4");
  62. long dummy;
  63. #ifndef __s390x__
  64. if (!MACHINE_HAS_CSP) {
  65. smp_ptlb_all();
  66. return;
  67. }
  68. #endif /* __s390x__ */
  69. dummy = 0;
  70. reg2 = reg3 = 0;
  71. reg4 = ((unsigned long) &dummy) + 1;
  72. asm volatile(
  73. " csp %0,%2"
  74. : : "d" (reg2), "d" (reg3), "d" (reg4), "m" (dummy) : "cc" );
  75. }
  76. /*
  77. * We only have to do global flush of tlb if process run since last
  78. * flush on any other pu than current.
  79. * If we have threads (mm->count > 1) we always do a global flush,
  80. * since the process runs on more than one processor at the same time.
  81. */
  82. static inline void __flush_tlb_mm(struct mm_struct * mm)
  83. {
  84. cpumask_t local_cpumask;
  85. if (unlikely(cpus_empty(mm->cpu_vm_mask)))
  86. return;
  87. if (MACHINE_HAS_IDTE) {
  88. asm volatile(
  89. " .insn rrf,0xb98e0000,0,%0,%1,0"
  90. : : "a" (2048), "a" (__pa(mm->pgd)&PAGE_MASK) : "cc");
  91. return;
  92. }
  93. preempt_disable();
  94. local_cpumask = cpumask_of_cpu(smp_processor_id());
  95. if (cpus_equal(mm->cpu_vm_mask, local_cpumask))
  96. local_flush_tlb();
  97. else
  98. global_flush_tlb();
  99. preempt_enable();
  100. }
  101. static inline void flush_tlb(void)
  102. {
  103. __flush_tlb_mm(current->mm);
  104. }
  105. static inline void flush_tlb_all(void)
  106. {
  107. global_flush_tlb();
  108. }
  109. static inline void flush_tlb_mm(struct mm_struct *mm)
  110. {
  111. __flush_tlb_mm(mm);
  112. }
  113. static inline void flush_tlb_page(struct vm_area_struct *vma,
  114. unsigned long addr)
  115. {
  116. __flush_tlb_mm(vma->vm_mm);
  117. }
  118. static inline void flush_tlb_range(struct vm_area_struct *vma,
  119. unsigned long start, unsigned long end)
  120. {
  121. __flush_tlb_mm(vma->vm_mm);
  122. }
  123. #define flush_tlb_kernel_range(start, end) global_flush_tlb()
  124. #endif
  125. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  126. unsigned long start, unsigned long end)
  127. {
  128. /* S/390 does not keep any page table caches in TLB */
  129. }
  130. #endif /* _S390_TLBFLUSH_H */