aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-03-17 19:36:58 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-24 17:57:30 -0400
commit170fdff7057d4247e3f28cca96d0db1fbc854e3b (patch)
treeb0d5281dc5de0b9a0ddb1e626818d8f7f562713c /include/asm-x86
parent397f687ab7f840dbe50353c4b60108672b653d0c (diff)
x86: move pmd functions into common asm/pgalloc.h
Common definitions for 3-level pagetable functions. 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 'include/asm-x86')
-rw-r--r--include/asm-x86/pgalloc.h33
-rw-r--r--include/asm-x86/pgalloc_32.h32
-rw-r--r--include/asm-x86/pgalloc_64.h24
3 files changed, 33 insertions, 56 deletions
diff --git a/include/asm-x86/pgalloc.h b/include/asm-x86/pgalloc.h
index 0d15e21eefec..ae23839db20b 100644
--- a/include/asm-x86/pgalloc.h
+++ b/include/asm-x86/pgalloc.h
@@ -40,6 +40,39 @@ static inline void pte_free(struct mm_struct *mm, struct page *pte)
40 40
41extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte); 41extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte);
42 42
43static inline void pmd_populate_kernel(struct mm_struct *mm,
44 pmd_t *pmd, pte_t *pte)
45{
46 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
47 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
48}
49
50static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
51 struct page *pte)
52{
53 unsigned long pfn = page_to_pfn(pte);
54
55 paravirt_alloc_pt(mm, pfn);
56 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
57}
58
59#define pmd_pgtable(pmd) pmd_page(pmd)
60
61#if PAGETABLE_LEVELS > 2
62static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
63{
64 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
65}
66
67static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
68{
69 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
70 free_page((unsigned long)pmd);
71}
72
73extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
74#endif /* PAGETABLE_LEVELS > 2 */
75
43#ifdef CONFIG_X86_32 76#ifdef CONFIG_X86_32
44# include "pgalloc_32.h" 77# include "pgalloc_32.h"
45#else 78#else
diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h
index 96a09f566155..b83bc010af09 100644
--- a/include/asm-x86/pgalloc_32.h
+++ b/include/asm-x86/pgalloc_32.h
@@ -1,39 +1,7 @@
1#ifndef _I386_PGALLOC_H 1#ifndef _I386_PGALLOC_H
2#define _I386_PGALLOC_H 2#define _I386_PGALLOC_H
3 3
4static inline void pmd_populate_kernel(struct mm_struct *mm,
5 pmd_t *pmd, pte_t *pte)
6{
7 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
8 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
9}
10
11static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
12{
13 unsigned long pfn = page_to_pfn(pte);
14
15 paravirt_alloc_pt(mm, pfn);
16 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
17}
18#define pmd_pgtable(pmd) pmd_page(pmd)
19
20#ifdef CONFIG_X86_PAE 4#ifdef CONFIG_X86_PAE
21/*
22 * In the PAE case we free the pmds as part of the pgd.
23 */
24static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
25{
26 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
27}
28
29static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
30{
31 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
32 free_page((unsigned long)pmd);
33}
34
35extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
36
37extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd); 5extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
38 6
39#endif /* CONFIG_X86_PAE */ 7#endif /* CONFIG_X86_PAE */
diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h
index fc3414d3ed04..501968194253 100644
--- a/include/asm-x86/pgalloc_64.h
+++ b/include/asm-x86/pgalloc_64.h
@@ -3,11 +3,6 @@
3 3
4#include <asm/pda.h> 4#include <asm/pda.h>
5 5
6static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
7{
8 set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)));
9}
10
11static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) 6static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
12{ 7{
13 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd))); 8 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
@@ -18,24 +13,6 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
18 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud))); 13 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
19} 14}
20 15
21#define pmd_pgtable(pmd) pmd_page(pmd)
22
23static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
24{
25 set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
26}
27
28static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
29{
30 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
31 free_page((unsigned long)pmd);
32}
33
34static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
35{
36 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
37}
38
39static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) 16static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
40{ 17{
41 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); 18 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
@@ -47,7 +24,6 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)
47 free_page((unsigned long)pud); 24 free_page((unsigned long)pud);
48} 25}
49 26
50extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
51extern void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud); 27extern void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud);
52 28
53#endif /* _X86_64_PGALLOC_H */ 29#endif /* _X86_64_PGALLOC_H */