tlb.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef __ASM_SH_TLB_H
  2. #define __ASM_SH_TLB_H
  3. #ifdef CONFIG_SUPERH64
  4. # include "tlb_64.h"
  5. #endif
  6. #ifndef __ASSEMBLY__
  7. #include <linux/pagemap.h>
  8. #ifdef CONFIG_MMU
  9. #include <linux/swap.h>
  10. #include <asm/pgalloc.h>
  11. #include <asm/tlbflush.h>
  12. #include <asm/mmu_context.h>
  13. /*
  14. * TLB handling. This allows us to remove pages from the page
  15. * tables, and efficiently handle the TLB issues.
  16. */
  17. struct mmu_gather {
  18. struct mm_struct *mm;
  19. unsigned int fullmm;
  20. unsigned long start, end;
  21. };
  22. static inline void init_tlb_gather(struct mmu_gather *tlb)
  23. {
  24. tlb->start = TASK_SIZE;
  25. tlb->end = 0;
  26. if (tlb->fullmm) {
  27. tlb->start = 0;
  28. tlb->end = TASK_SIZE;
  29. }
  30. }
  31. static inline void
  32. tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
  33. {
  34. tlb->mm = mm;
  35. tlb->fullmm = full_mm_flush;
  36. init_tlb_gather(tlb);
  37. }
  38. static inline void
  39. tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
  40. {
  41. if (tlb->fullmm)
  42. flush_tlb_mm(tlb->mm);
  43. /* keep the page table cache within bounds */
  44. check_pgt_cache();
  45. }
  46. static inline void
  47. tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, unsigned long address)
  48. {
  49. if (tlb->start > address)
  50. tlb->start = address;
  51. if (tlb->end < address + PAGE_SIZE)
  52. tlb->end = address + PAGE_SIZE;
  53. }
  54. /*
  55. * In the case of tlb vma handling, we can optimise these away in the
  56. * case where we're doing a full MM flush. When we're doing a munmap,
  57. * the vmas are adjusted to only cover the region to be torn down.
  58. */
  59. static inline void
  60. tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  61. {
  62. if (!tlb->fullmm)
  63. flush_cache_range(vma, vma->vm_start, vma->vm_end);
  64. }
  65. static inline void
  66. tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  67. {
  68. if (!tlb->fullmm && tlb->end) {
  69. flush_tlb_range(vma, tlb->start, tlb->end);
  70. init_tlb_gather(tlb);
  71. }
  72. }
  73. static inline void tlb_flush_mmu(struct mmu_gather *tlb)
  74. {
  75. }
  76. static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
  77. {
  78. free_page_and_swap_cache(page);
  79. return 1; /* avoid calling tlb_flush_mmu */
  80. }
  81. static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
  82. {
  83. __tlb_remove_page(tlb, page);
  84. }
  85. #define pte_free_tlb(tlb, ptep, addr) pte_free((tlb)->mm, ptep)
  86. #define pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, pmdp)
  87. #define pud_free_tlb(tlb, pudp, addr) pud_free((tlb)->mm, pudp)
  88. #define tlb_migrate_finish(mm) do { } while (0)
  89. #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SUPERH64)
  90. extern void tlb_wire_entry(struct vm_area_struct *, unsigned long, pte_t);
  91. extern void tlb_unwire_entry(void);
  92. #else
  93. static inline void tlb_wire_entry(struct vm_area_struct *vma ,
  94. unsigned long addr, pte_t pte)
  95. {
  96. BUG();
  97. }
  98. static inline void tlb_unwire_entry(void)
  99. {
  100. BUG();
  101. }
  102. #endif
  103. #else /* CONFIG_MMU */
  104. #define tlb_start_vma(tlb, vma) do { } while (0)
  105. #define tlb_end_vma(tlb, vma) do { } while (0)
  106. #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
  107. #define tlb_flush(tlb) do { } while (0)
  108. #include <asm-generic/tlb.h>
  109. #endif /* CONFIG_MMU */
  110. #endif /* __ASSEMBLY__ */
  111. #endif /* __ASM_SH_TLB_H */