aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/paravirt.c4
-rw-r--r--arch/x86/mm/pgtable.c13
-rw-r--r--arch/x86/xen/enlighten.c4
-rw-r--r--include/asm-x86/paravirt.h19
-rw-r--r--include/asm-x86/pgalloc.h4
5 files changed, 38 insertions, 6 deletions
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index e9b504537212..78c9a1b9e6b0 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -30,6 +30,7 @@
30#include <asm/setup.h> 30#include <asm/setup.h>
31#include <asm/arch_hooks.h> 31#include <asm/arch_hooks.h>
32#include <asm/time.h> 32#include <asm/time.h>
33#include <asm/pgalloc.h>
33#include <asm/irq.h> 34#include <asm/irq.h>
34#include <asm/delay.h> 35#include <asm/delay.h>
35#include <asm/fixmap.h> 36#include <asm/fixmap.h>
@@ -366,6 +367,9 @@ struct pv_mmu_ops pv_mmu_ops = {
366 .flush_tlb_single = native_flush_tlb_single, 367 .flush_tlb_single = native_flush_tlb_single,
367 .flush_tlb_others = native_flush_tlb_others, 368 .flush_tlb_others = native_flush_tlb_others,
368 369
370 .pgd_alloc = __paravirt_pgd_alloc,
371 .pgd_free = paravirt_nop,
372
369 .alloc_pte = paravirt_nop, 373 .alloc_pte = paravirt_nop,
370 .alloc_pmd = paravirt_nop, 374 .alloc_pmd = paravirt_nop,
371 .alloc_pmd_clone = paravirt_nop, 375 .alloc_pmd_clone = paravirt_nop,
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 45b99ac39480..418c4432fb39 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -215,13 +215,15 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
215 215
216 /* so that alloc_pmd can use it */ 216 /* so that alloc_pmd can use it */
217 mm->pgd = pgd; 217 mm->pgd = pgd;
218 if (pgd) 218 if (pgd) {
219 pgd_ctor(pgd); 219 pgd_ctor(pgd);
220 220
221 if (pgd && !pgd_prepopulate_pmd(mm, pgd)) { 221 if (paravirt_pgd_alloc(mm) != 0 ||
222 pgd_dtor(pgd); 222 !pgd_prepopulate_pmd(mm, pgd)) {
223 free_page((unsigned long)pgd); 223 pgd_dtor(pgd);
224 pgd = NULL; 224 free_page((unsigned long)pgd);
225 pgd = NULL;
226 }
225 } 227 }
226 228
227 return pgd; 229 return pgd;
@@ -231,6 +233,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
231{ 233{
232 pgd_mop_up_pmds(mm, pgd); 234 pgd_mop_up_pmds(mm, pgd);
233 pgd_dtor(pgd); 235 pgd_dtor(pgd);
236 paravirt_pgd_free(mm, pgd);
234 free_page((unsigned long)pgd); 237 free_page((unsigned long)pgd);
235} 238}
236 239
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 76ad1efaf09e..d62f14e20708 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -45,6 +45,7 @@
45#include <asm/pgtable.h> 45#include <asm/pgtable.h>
46#include <asm/tlbflush.h> 46#include <asm/tlbflush.h>
47#include <asm/reboot.h> 47#include <asm/reboot.h>
48#include <asm/pgalloc.h>
48 49
49#include "xen-ops.h" 50#include "xen-ops.h"
50#include "mmu.h" 51#include "mmu.h"
@@ -1153,6 +1154,9 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
1153 .pte_update = paravirt_nop, 1154 .pte_update = paravirt_nop,
1154 .pte_update_defer = paravirt_nop, 1155 .pte_update_defer = paravirt_nop,
1155 1156
1157 .pgd_alloc = __paravirt_pgd_alloc,
1158 .pgd_free = paravirt_nop,
1159
1156 .alloc_pte = xen_alloc_pte_init, 1160 .alloc_pte = xen_alloc_pte_init,
1157 .release_pte = xen_release_pte_init, 1161 .release_pte = xen_release_pte_init,
1158 .alloc_pmd = xen_alloc_pte_init, 1162 .alloc_pmd = xen_alloc_pte_init,
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index 41f5447efd88..5467e2cff4bc 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -219,7 +219,14 @@ struct pv_mmu_ops {
219 void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm, 219 void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm,
220 unsigned long va); 220 unsigned long va);
221 221
222 /* Hooks for allocating/releasing pagetable pages */ 222 /* Hooks for allocating and freeing a pagetable top-level */
223 int (*pgd_alloc)(struct mm_struct *mm);
224 void (*pgd_free)(struct mm_struct *mm, pgd_t *pgd);
225
226 /*
227 * Hooks for allocating/releasing pagetable pages when they're
228 * attached to a pagetable
229 */
223 void (*alloc_pte)(struct mm_struct *mm, u32 pfn); 230 void (*alloc_pte)(struct mm_struct *mm, u32 pfn);
224 void (*alloc_pmd)(struct mm_struct *mm, u32 pfn); 231 void (*alloc_pmd)(struct mm_struct *mm, u32 pfn);
225 void (*alloc_pmd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count); 232 void (*alloc_pmd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
@@ -925,6 +932,16 @@ static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
925 PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va); 932 PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va);
926} 933}
927 934
935static inline int paravirt_pgd_alloc(struct mm_struct *mm)
936{
937 return PVOP_CALL1(int, pv_mmu_ops.pgd_alloc, mm);
938}
939
940static inline void paravirt_pgd_free(struct mm_struct *mm, pgd_t *pgd)
941{
942 PVOP_VCALL2(pv_mmu_ops.pgd_free, mm, pgd);
943}
944
928static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned pfn) 945static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned pfn)
929{ 946{
930 PVOP_VCALL2(pv_mmu_ops.alloc_pte, mm, pfn); 947 PVOP_VCALL2(pv_mmu_ops.alloc_pte, mm, pfn);
diff --git a/include/asm-x86/pgalloc.h b/include/asm-x86/pgalloc.h
index 91e4641f3f31..d63ea431cb3b 100644
--- a/include/asm-x86/pgalloc.h
+++ b/include/asm-x86/pgalloc.h
@@ -5,9 +5,13 @@
5#include <linux/mm.h> /* for struct page */ 5#include <linux/mm.h> /* for struct page */
6#include <linux/pagemap.h> 6#include <linux/pagemap.h>
7 7
8static inline int __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
9
8#ifdef CONFIG_PARAVIRT 10#ifdef CONFIG_PARAVIRT
9#include <asm/paravirt.h> 11#include <asm/paravirt.h>
10#else 12#else
13#define paravirt_pgd_alloc(mm) __paravirt_pgd_alloc(mm)
14static inline void paravirt_pgd_free(struct mm_struct *mm, pgd_t *pgd) {}
11static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned long pfn) {} 15static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned long pfn) {}
12static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned long pfn) {} 16static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned long pfn) {}
13static inline void paravirt_alloc_pmd_clone(unsigned long pfn, unsigned long clonepfn, 17static inline void paravirt_alloc_pmd_clone(unsigned long pfn, unsigned long clonepfn,