diff options
Diffstat (limited to 'arch/arm/mm/pgd.c')
-rw-r--r-- | arch/arm/mm/pgd.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c index b2027c154b2..a3e78ccabd6 100644 --- a/arch/arm/mm/pgd.c +++ b/arch/arm/mm/pgd.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/gfp.h> | 11 | #include <linux/gfp.h> |
12 | #include <linux/highmem.h> | 12 | #include <linux/highmem.h> |
13 | #include <linux/slab.h> | ||
13 | 14 | ||
14 | #include <asm/pgalloc.h> | 15 | #include <asm/pgalloc.h> |
15 | #include <asm/page.h> | 16 | #include <asm/page.h> |
@@ -17,6 +18,14 @@ | |||
17 | 18 | ||
18 | #include "mm.h" | 19 | #include "mm.h" |
19 | 20 | ||
21 | #ifdef CONFIG_ARM_LPAE | ||
22 | #define __pgd_alloc() kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL) | ||
23 | #define __pgd_free(pgd) kfree(pgd) | ||
24 | #else | ||
25 | #define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL, 2) | ||
26 | #define __pgd_free(pgd) free_pages((unsigned long)pgd, 2) | ||
27 | #endif | ||
28 | |||
20 | /* | 29 | /* |
21 | * need to get a 16k page for level 1 | 30 | * need to get a 16k page for level 1 |
22 | */ | 31 | */ |
@@ -27,7 +36,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm) | |||
27 | pmd_t *new_pmd, *init_pmd; | 36 | pmd_t *new_pmd, *init_pmd; |
28 | pte_t *new_pte, *init_pte; | 37 | pte_t *new_pte, *init_pte; |
29 | 38 | ||
30 | new_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, 2); | 39 | new_pgd = __pgd_alloc(); |
31 | if (!new_pgd) | 40 | if (!new_pgd) |
32 | goto no_pgd; | 41 | goto no_pgd; |
33 | 42 | ||
@@ -42,10 +51,25 @@ pgd_t *pgd_alloc(struct mm_struct *mm) | |||
42 | 51 | ||
43 | clean_dcache_area(new_pgd, PTRS_PER_PGD * sizeof(pgd_t)); | 52 | clean_dcache_area(new_pgd, PTRS_PER_PGD * sizeof(pgd_t)); |
44 | 53 | ||
54 | #ifdef CONFIG_ARM_LPAE | ||
55 | /* | ||
56 | * Allocate PMD table for modules and pkmap mappings. | ||
57 | */ | ||
58 | new_pud = pud_alloc(mm, new_pgd + pgd_index(MODULES_VADDR), | ||
59 | MODULES_VADDR); | ||
60 | if (!new_pud) | ||
61 | goto no_pud; | ||
62 | |||
63 | new_pmd = pmd_alloc(mm, new_pud, 0); | ||
64 | if (!new_pmd) | ||
65 | goto no_pmd; | ||
66 | #endif | ||
67 | |||
45 | if (!vectors_high()) { | 68 | if (!vectors_high()) { |
46 | /* | 69 | /* |
47 | * On ARM, first page must always be allocated since it | 70 | * On ARM, first page must always be allocated since it |
48 | * contains the machine vectors. | 71 | * contains the machine vectors. The vectors are always high |
72 | * with LPAE. | ||
49 | */ | 73 | */ |
50 | new_pud = pud_alloc(mm, new_pgd, 0); | 74 | new_pud = pud_alloc(mm, new_pgd, 0); |
51 | if (!new_pud) | 75 | if (!new_pud) |
@@ -74,7 +98,7 @@ no_pte: | |||
74 | no_pmd: | 98 | no_pmd: |
75 | pud_free(mm, new_pud); | 99 | pud_free(mm, new_pud); |
76 | no_pud: | 100 | no_pud: |
77 | free_pages((unsigned long)new_pgd, 2); | 101 | __pgd_free(new_pgd); |
78 | no_pgd: | 102 | no_pgd: |
79 | return NULL; | 103 | return NULL; |
80 | } | 104 | } |
@@ -111,5 +135,24 @@ no_pud: | |||
111 | pgd_clear(pgd); | 135 | pgd_clear(pgd); |
112 | pud_free(mm, pud); | 136 | pud_free(mm, pud); |
113 | no_pgd: | 137 | no_pgd: |
114 | free_pages((unsigned long) pgd_base, 2); | 138 | #ifdef CONFIG_ARM_LPAE |
139 | /* | ||
140 | * Free modules/pkmap or identity pmd tables. | ||
141 | */ | ||
142 | for (pgd = pgd_base; pgd < pgd_base + PTRS_PER_PGD; pgd++) { | ||
143 | if (pgd_none_or_clear_bad(pgd)) | ||
144 | continue; | ||
145 | if (pgd_val(*pgd) & L_PGD_SWAPPER) | ||
146 | continue; | ||
147 | pud = pud_offset(pgd, 0); | ||
148 | if (pud_none_or_clear_bad(pud)) | ||
149 | continue; | ||
150 | pmd = pmd_offset(pud, 0); | ||
151 | pud_clear(pud); | ||
152 | pmd_free(mm, pmd); | ||
153 | pgd_clear(pgd); | ||
154 | pud_free(mm, pud); | ||
155 | } | ||
156 | #endif | ||
157 | __pgd_free(pgd_base); | ||
115 | } | 158 | } |