aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/x86/mm/init_64.c5
-rw-r--r--arch/x86/mm/pgtable.c8
-rw-r--r--arch/x86/mm/pgtable_32.c10
-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
6 files changed, 41 insertions, 71 deletions
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 9c09893e54fb..4465104f5514 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -662,11 +662,6 @@ int memory_add_physaddr_to_nid(u64 start)
662EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 662EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
663#endif 663#endif
664 664
665void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
666{
667 tlb_remove_page(tlb, virt_to_page(pmd));
668}
669
670void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) 665void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud)
671{ 666{
672 tlb_remove_page(tlb, virt_to_page(pud)); 667 tlb_remove_page(tlb, virt_to_page(pud));
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 83765328e265..1c41efedf6d0 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -28,6 +28,14 @@ void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
28 tlb_remove_page(tlb, pte); 28 tlb_remove_page(tlb, pte);
29} 29}
30 30
31#if PAGETABLE_LEVELS > 2
32void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
33{
34 paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT);
35 tlb_remove_page(tlb, virt_to_page(pmd));
36}
37#endif /* PAGETABLE_LEVELS > 2 */
38
31#ifdef CONFIG_X86_64 39#ifdef CONFIG_X86_64
32static inline void pgd_list_add(pgd_t *pgd) 40static inline void pgd_list_add(pgd_t *pgd)
33{ 41{
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index b9e3dac32391..9ee007be9142 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -173,16 +173,6 @@ void reserve_top_address(unsigned long reserve)
173 __VMALLOC_RESERVE += reserve; 173 __VMALLOC_RESERVE += reserve;
174} 174}
175 175
176#ifdef CONFIG_X86_PAE
177
178void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
179{
180 paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT);
181 tlb_remove_page(tlb, virt_to_page(pmd));
182}
183
184#endif
185
186int pmd_bad(pmd_t pmd) 176int pmd_bad(pmd_t pmd)
187{ 177{
188 WARN_ON_ONCE(pmd_bad_v1(pmd) != pmd_bad_v2(pmd)); 178 WARN_ON_ONCE(pmd_bad_v1(pmd) != pmd_bad_v2(pmd));
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 */