diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-03-17 19:37:09 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-24 17:57:31 -0400 |
commit | 947a69c90c0d07ac7f214e46dabbe49f2a230e00 (patch) | |
tree | 6b0c650896d4735d0ce2dd2e639ed056cc976743 /arch | |
parent | 430442e38e7f049841c5838f8c7027bd9e170045 (diff) |
xen: unify pte operations
We can fold the essentially common pte functions together now.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/xen/mmu.c | 125 |
1 files changed, 44 insertions, 81 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 3148db8e794e..272635aaef88 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -171,6 +171,49 @@ void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, | |||
171 | xen_set_pte(ptep, pteval); | 171 | xen_set_pte(ptep, pteval); |
172 | } | 172 | } |
173 | 173 | ||
174 | pteval_t xen_pte_val(pte_t pte) | ||
175 | { | ||
176 | pteval_t ret = pte.pte; | ||
177 | |||
178 | if (ret & _PAGE_PRESENT) | ||
179 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
180 | |||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | pgdval_t xen_pgd_val(pgd_t pgd) | ||
185 | { | ||
186 | pgdval_t ret = pgd.pgd; | ||
187 | if (ret & _PAGE_PRESENT) | ||
188 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | pte_t xen_make_pte(pteval_t pte) | ||
193 | { | ||
194 | if (pte & _PAGE_PRESENT) { | ||
195 | pte = phys_to_machine(XPADDR(pte)).maddr; | ||
196 | pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
197 | } | ||
198 | |||
199 | return (pte_t){ .pte = pte }; | ||
200 | } | ||
201 | |||
202 | pgd_t xen_make_pgd(pgdval_t pgd) | ||
203 | { | ||
204 | if (pgd & _PAGE_PRESENT) | ||
205 | pgd = phys_to_machine(XPADDR(pgd)).maddr; | ||
206 | |||
207 | return (pgd_t){ pgd }; | ||
208 | } | ||
209 | |||
210 | pmdval_t xen_pmd_val(pmd_t pmd) | ||
211 | { | ||
212 | pmdval_t ret = native_pmd_val(pmd); | ||
213 | if (ret & _PAGE_PRESENT) | ||
214 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
215 | return ret; | ||
216 | } | ||
174 | #ifdef CONFIG_X86_PAE | 217 | #ifdef CONFIG_X86_PAE |
175 | void xen_set_pud(pud_t *ptr, pud_t val) | 218 | void xen_set_pud(pud_t *ptr, pud_t val) |
176 | { | 219 | { |
@@ -214,98 +257,18 @@ void xen_pmd_clear(pmd_t *pmdp) | |||
214 | xen_set_pmd(pmdp, __pmd(0)); | 257 | xen_set_pmd(pmdp, __pmd(0)); |
215 | } | 258 | } |
216 | 259 | ||
217 | pteval_t xen_pte_val(pte_t pte) | ||
218 | { | ||
219 | pteval_t ret = pte.pte; | ||
220 | |||
221 | if (ret & _PAGE_PRESENT) | ||
222 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
223 | |||
224 | return ret; | ||
225 | } | ||
226 | |||
227 | pmdval_t xen_pmd_val(pmd_t pmd) | ||
228 | { | ||
229 | pmdval_t ret = pmd.pmd; | ||
230 | if (ret & _PAGE_PRESENT) | ||
231 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
232 | return ret; | ||
233 | } | ||
234 | |||
235 | pgdval_t xen_pgd_val(pgd_t pgd) | ||
236 | { | ||
237 | pgdval_t ret = pgd.pgd; | ||
238 | if (ret & _PAGE_PRESENT) | ||
239 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
240 | return ret; | ||
241 | } | ||
242 | |||
243 | pte_t xen_make_pte(pteval_t pte) | ||
244 | { | ||
245 | if (pte & _PAGE_PRESENT) { | ||
246 | pte = phys_to_machine(XPADDR(pte)).maddr; | ||
247 | pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
248 | } | ||
249 | |||
250 | return (pte_t){ .pte = pte }; | ||
251 | } | ||
252 | |||
253 | pmd_t xen_make_pmd(pmdval_t pmd) | 260 | pmd_t xen_make_pmd(pmdval_t pmd) |
254 | { | 261 | { |
255 | if (pmd & _PAGE_PRESENT) | 262 | if (pmd & _PAGE_PRESENT) |
256 | pmd = phys_to_machine(XPADDR(pmd)).maddr; | 263 | pmd = phys_to_machine(XPADDR(pmd)).maddr; |
257 | 264 | ||
258 | return (pmd_t){ pmd }; | 265 | return native_make_pmd(pmd); |
259 | } | ||
260 | |||
261 | pgd_t xen_make_pgd(pgdval_t pgd) | ||
262 | { | ||
263 | if (pgd & _PAGE_PRESENT) | ||
264 | pgd = phys_to_machine(XPADDR(pgd)).maddr; | ||
265 | |||
266 | return (pgd_t){ pgd }; | ||
267 | } | 266 | } |
268 | #else /* !PAE */ | 267 | #else /* !PAE */ |
269 | void xen_set_pte(pte_t *ptep, pte_t pte) | 268 | void xen_set_pte(pte_t *ptep, pte_t pte) |
270 | { | 269 | { |
271 | *ptep = pte; | 270 | *ptep = pte; |
272 | } | 271 | } |
273 | |||
274 | pteval_t xen_pte_val(pte_t pte) | ||
275 | { | ||
276 | pteval_t ret = pte.pte; | ||
277 | |||
278 | if (ret & _PAGE_PRESENT) | ||
279 | ret = machine_to_phys(XMADDR(ret)).paddr; | ||
280 | |||
281 | return ret; | ||
282 | } | ||
283 | |||
284 | pgdval_t xen_pgd_val(pgd_t pgd) | ||
285 | { | ||
286 | pteval_t ret = pgd.pgd; | ||
287 | if (ret & _PAGE_PRESENT) | ||
288 | ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; | ||
289 | return ret; | ||
290 | } | ||
291 | |||
292 | pte_t xen_make_pte(pteval_t pte) | ||
293 | { | ||
294 | if (pte & _PAGE_PRESENT) { | ||
295 | pte = phys_to_machine(XPADDR(pte)).maddr; | ||
296 | pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
297 | } | ||
298 | |||
299 | return (pte_t){ pte }; | ||
300 | } | ||
301 | |||
302 | pgd_t xen_make_pgd(pgdval_t pgd) | ||
303 | { | ||
304 | if (pgd & _PAGE_PRESENT) | ||
305 | pgd = phys_to_machine(XPADDR(pgd)).maddr; | ||
306 | |||
307 | return (pgd_t){ pgd }; | ||
308 | } | ||
309 | #endif /* CONFIG_X86_PAE */ | 272 | #endif /* CONFIG_X86_PAE */ |
310 | 273 | ||
311 | /* | 274 | /* |