1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/kernel.h>
26#include <linux/mm.h>
27#include <linux/init.h>
28#include <linux/highmem.h>
29#include <linux/pagemap.h>
30#include <linux/export.h>
31
32#include <asm/tlbflush.h>
33#include <asm/tlb.h>
34
35#include "mmu_decl.h"
36
37
38
39
40void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, unsigned long addr)
41{
42 unsigned long ptephys;
43
44 if (Hash != 0) {
45 ptephys = __pa(ptep) & PAGE_MASK;
46 flush_hash_pages(mm->context.id, addr, ptephys, 1);
47 }
48}
49EXPORT_SYMBOL(flush_hash_entry);
50
51
52
53
54
55void tlb_flush(struct mmu_gather *tlb)
56{
57 if (Hash == 0) {
58
59
60
61
62 _tlbia();
63 }
64}
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79static void flush_range(struct mm_struct *mm, unsigned long start,
80 unsigned long end)
81{
82 pmd_t *pmd;
83 unsigned long pmd_end;
84 int count;
85 unsigned int ctx = mm->context.id;
86
87 if (Hash == 0) {
88 _tlbia();
89 return;
90 }
91 start &= PAGE_MASK;
92 if (start >= end)
93 return;
94 end = (end - 1) | ~PAGE_MASK;
95 pmd = pmd_offset(pud_offset(pgd_offset(mm, start), start), start);
96 for (;;) {
97 pmd_end = ((start + PGDIR_SIZE) & PGDIR_MASK) - 1;
98 if (pmd_end > end)
99 pmd_end = end;
100 if (!pmd_none(*pmd)) {
101 count = ((pmd_end - start) >> PAGE_SHIFT) + 1;
102 flush_hash_pages(ctx, start, pmd_val(*pmd), count);
103 }
104 if (pmd_end == end)
105 break;
106 start = pmd_end + 1;
107 ++pmd;
108 }
109}
110
111
112
113
114void flush_tlb_kernel_range(unsigned long start, unsigned long end)
115{
116 flush_range(&init_mm, start, end);
117}
118EXPORT_SYMBOL(flush_tlb_kernel_range);
119
120
121
122
123void flush_tlb_mm(struct mm_struct *mm)
124{
125 struct vm_area_struct *mp;
126
127 if (Hash == 0) {
128 _tlbia();
129 return;
130 }
131
132
133
134
135
136
137
138 for (mp = mm->mmap; mp != NULL; mp = mp->vm_next)
139 flush_range(mp->vm_mm, mp->vm_start, mp->vm_end);
140}
141EXPORT_SYMBOL(flush_tlb_mm);
142
143void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
144{
145 struct mm_struct *mm;
146 pmd_t *pmd;
147
148 if (Hash == 0) {
149 _tlbie(vmaddr);
150 return;
151 }
152 mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
153 pmd = pmd_offset(pud_offset(pgd_offset(mm, vmaddr), vmaddr), vmaddr);
154 if (!pmd_none(*pmd))
155 flush_hash_pages(mm->context.id, vmaddr, pmd_val(*pmd), 1);
156}
157EXPORT_SYMBOL(flush_tlb_page);
158
159
160
161
162
163
164void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
165 unsigned long end)
166{
167 flush_range(vma->vm_mm, start, end);
168}
169EXPORT_SYMBOL(flush_tlb_range);
170
171void __init early_init_mmu(void)
172{
173}
174