blob: 3482c342789786d71683c9ebd2870441da705208 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _I386_PGALLOC_H
2#define _I386_PGALLOC_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/threads.h>
5#include <linux/mm.h> /* for struct page */
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +01006#include <asm/tlb.h>
7#include <asm-generic/tlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Zachary Amsdenc119ecc2007-02-13 13:26:21 +01009#ifdef CONFIG_PARAVIRT
10#include <asm/paravirt.h>
11#else
Jeremy Fitzhardingefdb4c332007-07-17 18:37:03 -070012#define paravirt_alloc_pt(mm, pfn) do { } while (0)
Jeremy Fitzhardinge6c435452008-01-30 13:33:39 +010013#define paravirt_alloc_pd(mm, pfn) do { } while (0)
Zachary Amsdenc119ecc2007-02-13 13:26:21 +010014#define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
15#define paravirt_release_pt(pfn) do { } while (0)
16#define paravirt_release_pd(pfn) do { } while (0)
17#endif
18
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +010019static inline void pmd_populate_kernel(struct mm_struct *mm,
20 pmd_t *pmd, pte_t *pte)
21{
22 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
23 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
24}
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +010026static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
27{
28 unsigned long pfn = page_to_pfn(pte);
29
30 paravirt_alloc_pt(mm, pfn);
31 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
32}
Zachary Amsdenc119ecc2007-02-13 13:26:21 +010033
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/*
35 * Allocate and free page tables.
36 */
37extern pgd_t *pgd_alloc(struct mm_struct *);
38extern void pgd_free(pgd_t *pgd);
39
40extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
41extern struct page *pte_alloc_one(struct mm_struct *, unsigned long);
42
43static inline void pte_free_kernel(pte_t *pte)
44{
45 free_page((unsigned long)pte);
46}
47
48static inline void pte_free(struct page *pte)
49{
50 __free_page(pte);
51}
52
53
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +010054static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
55{
56 paravirt_release_pt(page_to_pfn(pte));
57 tlb_remove_page(tlb, pte);
58}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#ifdef CONFIG_X86_PAE
61/*
62 * In the PAE case we free the pmds as part of the pgd.
63 */
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +010064static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
65{
66 BUG();
67 return (pmd_t *)2;
68}
69
70static inline void pmd_free(pmd_t *pmd)
71{
72}
73
74static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
75{
76}
77
78static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
79{
80 BUG();
81}
82#endif /* CONFIG_X86_PAE */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#endif /* _I386_PGALLOC_H */