tlbflush.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version
  16. * 2 of the License, or (at your option) any later version.
  17. */
  18. #ifdef __KERNEL__
  19. #include <linux/config.h>
  20. struct mm_struct;
  21. #ifdef CONFIG_PPC64
  22. #include <linux/percpu.h>
  23. #include <asm/page.h>
  24. #define PPC64_TLB_BATCH_NR 192
  25. struct ppc64_tlb_batch {
  26. unsigned long index;
  27. struct mm_struct *mm;
  28. real_pte_t pte[PPC64_TLB_BATCH_NR];
  29. unsigned long vaddr[PPC64_TLB_BATCH_NR];
  30. unsigned int psize;
  31. };
  32. DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
  33. extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
  34. static inline void flush_tlb_pending(void)
  35. {
  36. struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch);
  37. if (batch->index)
  38. __flush_tlb_pending(batch);
  39. put_cpu_var(ppc64_tlb_batch);
  40. }
  41. extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
  42. int local);
  43. extern void flush_hash_range(unsigned long number, int local);
  44. #else /* CONFIG_PPC64 */
  45. #include <linux/mm.h>
  46. extern void _tlbie(unsigned long address);
  47. extern void _tlbia(void);
  48. /*
  49. * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
  50. * flush_tlb_kernel_range are best implemented as tlbia vs
  51. * specific tlbie's
  52. */
  53. #if (defined(CONFIG_4xx) && !defined(CONFIG_44x)) || defined(CONFIG_8xx)
  54. #define flush_tlb_pending() asm volatile ("tlbia; sync" : : : "memory")
  55. #elif defined(CONFIG_4xx) || defined(CONFIG_FSL_BOOKE)
  56. #define flush_tlb_pending() _tlbia()
  57. #endif
  58. /*
  59. * This gets called at the end of handling a page fault, when
  60. * the kernel has put a new PTE into the page table for the process.
  61. * We use it to ensure coherency between the i-cache and d-cache
  62. * for the page which has just been mapped in.
  63. * On machines which use an MMU hash table, we use this to put a
  64. * corresponding HPTE into the hash table ahead of time, instead of
  65. * waiting for the inevitable extra hash-table miss exception.
  66. */
  67. extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
  68. #endif /* CONFIG_PPC64 */
  69. #if defined(CONFIG_PPC64) || defined(CONFIG_4xx) || \
  70. defined(CONFIG_FSL_BOOKE) || defined(CONFIG_8xx)
  71. static inline void flush_tlb_mm(struct mm_struct *mm)
  72. {
  73. flush_tlb_pending();
  74. }
  75. static inline void flush_tlb_page(struct vm_area_struct *vma,
  76. unsigned long vmaddr)
  77. {
  78. #ifdef CONFIG_PPC64
  79. flush_tlb_pending();
  80. #else
  81. _tlbie(vmaddr);
  82. #endif
  83. }
  84. static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
  85. unsigned long vmaddr)
  86. {
  87. #ifndef CONFIG_PPC64
  88. _tlbie(vmaddr);
  89. #endif
  90. }
  91. static inline void flush_tlb_range(struct vm_area_struct *vma,
  92. unsigned long start, unsigned long end)
  93. {
  94. flush_tlb_pending();
  95. }
  96. static inline void flush_tlb_kernel_range(unsigned long start,
  97. unsigned long end)
  98. {
  99. flush_tlb_pending();
  100. }
  101. #else /* 6xx, 7xx, 7xxx cpus */
  102. extern void flush_tlb_mm(struct mm_struct *mm);
  103. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  104. extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
  105. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  106. unsigned long end);
  107. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  108. #endif
  109. /*
  110. * This is called in munmap when we have freed up some page-table
  111. * pages. We don't need to do anything here, there's nothing special
  112. * about our page-table pages. -- paulus
  113. */
  114. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  115. unsigned long start, unsigned long end)
  116. {
  117. }
  118. #endif /*__KERNEL__ */
  119. #endif /* _ASM_POWERPC_TLBFLUSH_H */