tlbflush.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef _ASM_POWERPC_TLBFLUSH_H
  2. #define _ASM_POWERPC_TLBFLUSH_H
  3. /*
  4. * TLB flushing:
  5. *
  6. * - flush_tlb_mm(mm) flushes the specified mm context TLB's
  7. * - flush_tlb_page(vma, vmaddr) flushes one page
  8. * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
  9. * - flush_tlb_range(vma, start, end) flushes a range of pages
  10. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version
  15. * 2 of the License, or (at your option) any later version.
  16. */
  17. #ifdef __KERNEL__
  18. #if defined(CONFIG_4xx) || defined(CONFIG_8xx) || defined(CONFIG_FSL_BOOKE)
  19. /*
  20. * TLB flushing for software loaded TLB chips
  21. *
  22. * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
  23. * flush_tlb_kernel_range are best implemented as tlbia vs
  24. * specific tlbie's
  25. */
  26. #include <linux/mm.h>
  27. extern void _tlbie(unsigned long address, unsigned int pid);
  28. #if defined(CONFIG_40x) || defined(CONFIG_8xx)
  29. #define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
  30. #else /* CONFIG_44x || CONFIG_FSL_BOOKE */
  31. extern void _tlbia(void);
  32. #endif
  33. static inline void flush_tlb_mm(struct mm_struct *mm)
  34. {
  35. _tlbia();
  36. }
  37. static inline void flush_tlb_page(struct vm_area_struct *vma,
  38. unsigned long vmaddr)
  39. {
  40. _tlbie(vmaddr, vma ? vma->vm_mm->context.id : 0);
  41. }
  42. static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
  43. unsigned long vmaddr)
  44. {
  45. _tlbie(vmaddr, vma ? vma->vm_mm->context.id : 0);
  46. }
  47. static inline void flush_tlb_range(struct vm_area_struct *vma,
  48. unsigned long start, unsigned long end)
  49. {
  50. _tlbia();
  51. }
  52. static inline void flush_tlb_kernel_range(unsigned long start,
  53. unsigned long end)
  54. {
  55. _tlbia();
  56. }
  57. #elif defined(CONFIG_PPC32)
  58. /*
  59. * TLB flushing for "classic" hash-MMMU 32-bit CPUs, 6xx, 7xx, 7xxx
  60. */
  61. extern void _tlbie(unsigned long address);
  62. extern void _tlbia(void);
  63. extern void flush_tlb_mm(struct mm_struct *mm);
  64. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  65. extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
  66. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  67. unsigned long end);
  68. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  69. #else
  70. /*
  71. * TLB flushing for 64-bit has-MMU CPUs
  72. */
  73. #include <linux/percpu.h>
  74. #include <asm/page.h>
  75. #define PPC64_TLB_BATCH_NR 192
  76. struct ppc64_tlb_batch {
  77. int active;
  78. unsigned long index;
  79. struct mm_struct *mm;
  80. real_pte_t pte[PPC64_TLB_BATCH_NR];
  81. unsigned long vaddr[PPC64_TLB_BATCH_NR];
  82. unsigned int psize;
  83. int ssize;
  84. };
  85. DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
  86. extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
  87. extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
  88. pte_t *ptep, unsigned long pte, int huge);
  89. #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
  90. static inline void arch_enter_lazy_mmu_mode(void)
  91. {
  92. struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
  93. batch->active = 1;
  94. }
  95. static inline void arch_leave_lazy_mmu_mode(void)
  96. {
  97. struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
  98. if (batch->index)
  99. __flush_tlb_pending(batch);
  100. batch->active = 0;
  101. }
  102. #define arch_flush_lazy_mmu_mode() do {} while (0)
  103. extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
  104. int ssize, int local);
  105. extern void flush_hash_range(unsigned long number, int local);
  106. static inline void flush_tlb_mm(struct mm_struct *mm)
  107. {
  108. }
  109. static inline void flush_tlb_page(struct vm_area_struct *vma,
  110. unsigned long vmaddr)
  111. {
  112. }
  113. static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
  114. unsigned long vmaddr)
  115. {
  116. }
  117. static inline void flush_tlb_range(struct vm_area_struct *vma,
  118. unsigned long start, unsigned long end)
  119. {
  120. }
  121. static inline void flush_tlb_kernel_range(unsigned long start,
  122. unsigned long end)
  123. {
  124. }
  125. /* Private function for use by PCI IO mapping code */
  126. extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
  127. unsigned long end);
  128. #endif
  129. #endif /*__KERNEL__ */
  130. #endif /* _ASM_POWERPC_TLBFLUSH_H */