5 # include <asm/tlb_64.h>
9 #include <linux/pagemap.h>
12 #include <linux/swap.h>
13 #include <asm/pgalloc.h>
14 #include <asm/tlbflush.h>
15 #include <asm/mmu_context.h>
18 * TLB handling. This allows us to remove pages from the page
19 * tables, and efficiently handle the TLB issues.
24 unsigned long start
, end
;
27 static inline void init_tlb_gather(struct mmu_gather
*tlb
)
29 tlb
->start
= TASK_SIZE
;
39 tlb_gather_mmu(struct mmu_gather
*tlb
, struct mm_struct
*mm
, unsigned long start
, unsigned long end
)
44 tlb
->fullmm
= !(start
| (end
+1));
50 tlb_finish_mmu(struct mmu_gather
*tlb
, unsigned long start
, unsigned long end
)
53 flush_tlb_mm(tlb
->mm
);
55 /* keep the page table cache within bounds */
60 tlb_remove_tlb_entry(struct mmu_gather
*tlb
, pte_t
*ptep
, unsigned long address
)
62 if (tlb
->start
> address
)
64 if (tlb
->end
< address
+ PAGE_SIZE
)
65 tlb
->end
= address
+ PAGE_SIZE
;
69 * In the case of tlb vma handling, we can optimise these away in the
70 * case where we're doing a full MM flush. When we're doing a munmap,
71 * the vmas are adjusted to only cover the region to be torn down.
74 tlb_start_vma(struct mmu_gather
*tlb
, struct vm_area_struct
*vma
)
77 flush_cache_range(vma
, vma
->vm_start
, vma
->vm_end
);
81 tlb_end_vma(struct mmu_gather
*tlb
, struct vm_area_struct
*vma
)
83 if (!tlb
->fullmm
&& tlb
->end
) {
84 flush_tlb_range(vma
, tlb
->start
, tlb
->end
);
89 static inline void tlb_flush_mmu_tlbonly(struct mmu_gather
*tlb
)
93 static inline void tlb_flush_mmu_free(struct mmu_gather
*tlb
)
97 static inline void tlb_flush_mmu(struct mmu_gather
*tlb
)
101 static inline int __tlb_remove_page(struct mmu_gather
*tlb
, struct page
*page
)
103 free_page_and_swap_cache(page
);
104 return 1; /* avoid calling tlb_flush_mmu */
107 static inline void tlb_remove_page(struct mmu_gather
*tlb
, struct page
*page
)
109 __tlb_remove_page(tlb
, page
);
112 #define pte_free_tlb(tlb, ptep, addr) pte_free((tlb)->mm, ptep)
113 #define pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, pmdp)
114 #define pud_free_tlb(tlb, pudp, addr) pud_free((tlb)->mm, pudp)
116 #define tlb_migrate_finish(mm) do { } while (0)
118 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SUPERH64)
119 extern void tlb_wire_entry(struct vm_area_struct
*, unsigned long, pte_t
);
120 extern void tlb_unwire_entry(void);
122 static inline void tlb_wire_entry(struct vm_area_struct
*vma
,
123 unsigned long addr
, pte_t pte
)
128 static inline void tlb_unwire_entry(void)
134 #else /* CONFIG_MMU */
136 #define tlb_start_vma(tlb, vma) do { } while (0)
137 #define tlb_end_vma(tlb, vma) do { } while (0)
138 #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
139 #define tlb_flush(tlb) do { } while (0)
141 #include <asm-generic/tlb.h>
143 #endif /* CONFIG_MMU */
144 #endif /* __ASSEMBLY__ */
145 #endif /* __ASM_SH_TLB_H */