ia64/xen-unstable

view patches/linux-2.6.12/pmd-shared.patch @ 8331:d80066fa2dc2

Merged.
author emellor@leeni.uk.xensource.com
date Tue Dec 13 00:16:02 2005 +0000 (2005-12-13)
parents 001ba14fbb1b
children
line source
1 diff -urNpP linux-2.6.12/arch/i386/mm/pageattr.c linux-2.6.12.new/arch/i386/mm/pageattr.c
2 --- linux-2.6.12/arch/i386/mm/pageattr.c 2005-06-17 20:48:29.000000000 +0100
3 +++ linux-2.6.12.new/arch/i386/mm/pageattr.c 2005-07-11 16:28:09.775165494 +0100
4 @@ -75,7 +75,7 @@ static void set_pmd_pte(pte_t *kpte, uns
5 unsigned long flags;
7 set_pte_atomic(kpte, pte); /* change init_mm */
8 - if (PTRS_PER_PMD > 1)
9 + if (HAVE_SHARED_KERNEL_PMD)
10 return;
12 spin_lock_irqsave(&pgd_lock, flags);
13 diff -urNpP linux-2.6.12/arch/i386/mm/pgtable.c linux-2.6.12.new/arch/i386/mm/pgtable.c
14 --- linux-2.6.12/arch/i386/mm/pgtable.c 2005-11-26 09:55:10.000000000 +0000
15 +++ linux-2.6.12.new/arch/i386/mm/pgtable.c 2005-11-26 10:20:36.000000000 +0000
16 @@ -199,19 +199,20 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
17 {
18 unsigned long flags;
20 - if (PTRS_PER_PMD == 1)
21 + if (PTRS_PER_PMD > 1) {
22 + if (HAVE_SHARED_KERNEL_PMD)
23 + memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
24 + swapper_pg_dir + USER_PTRS_PER_PGD,
25 + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
26 + } else {
27 spin_lock_irqsave(&pgd_lock, flags);
28 -
29 - memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
30 - swapper_pg_dir + USER_PTRS_PER_PGD,
31 - (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
32 -
33 - if (PTRS_PER_PMD > 1)
34 - return;
35 -
36 - pgd_list_add(pgd);
37 - spin_unlock_irqrestore(&pgd_lock, flags);
38 - memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
39 + memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
40 + swapper_pg_dir + USER_PTRS_PER_PGD,
41 + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
42 + memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
43 + pgd_list_add(pgd);
44 + spin_unlock_irqrestore(&pgd_lock, flags);
45 + }
46 }
48 /* never called when PTRS_PER_PMD > 1 */
49 @@ -238,6 +239,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
50 goto out_oom;
51 set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
52 }
53 +
54 + if (!HAVE_SHARED_KERNEL_PMD) {
55 + unsigned long flags;
56 +
57 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
58 + pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
59 + if (!pmd)
60 + goto out_oom;
61 + set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
62 + }
63 +
64 + spin_lock_irqsave(&pgd_lock, flags);
65 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
66 + unsigned long v = (unsigned long)i << PGDIR_SHIFT;
67 + pgd_t *kpgd = pgd_offset_k(v);
68 + pud_t *kpud = pud_offset(kpgd, v);
69 + pmd_t *kpmd = pmd_offset(kpud, v);
70 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
71 + memcpy(pmd, kpmd, PAGE_SIZE);
72 + }
73 + pgd_list_add(pgd);
74 + spin_unlock_irqrestore(&pgd_lock, flags);
75 + }
76 +
77 return pgd;
79 out_oom:
80 @@ -252,9 +277,23 @@ void pgd_free(pgd_t *pgd)
81 int i;
83 /* in the PAE case user pgd entries are overwritten before usage */
84 - if (PTRS_PER_PMD > 1)
85 - for (i = 0; i < USER_PTRS_PER_PGD; ++i)
86 - kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
87 + if (PTRS_PER_PMD > 1) {
88 + for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
89 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
90 + kmem_cache_free(pmd_cache, pmd);
91 + }
92 + if (!HAVE_SHARED_KERNEL_PMD) {
93 + unsigned long flags;
94 + spin_lock_irqsave(&pgd_lock, flags);
95 + pgd_list_del(pgd);
96 + spin_unlock_irqrestore(&pgd_lock, flags);
97 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
98 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
99 + memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
100 + kmem_cache_free(pmd_cache, pmd);
101 + }
102 + }
103 + }
104 /* in the non-PAE case, free_pgtables() clears user pgd entries */
105 kmem_cache_free(pgd_cache, pgd);
106 }
107 diff -urNpP linux-2.6.12/include/asm-i386/pgtable-2level-defs.h linux-2.6.12.new/include/asm-i386/pgtable-2level-defs.h
108 --- linux-2.6.12/include/asm-i386/pgtable-2level-defs.h 2005-06-17 20:48:29.000000000 +0100
109 +++ linux-2.6.12.new/include/asm-i386/pgtable-2level-defs.h 2005-07-11 16:28:09.733164251 +0100
110 @@ -1,6 +1,8 @@
111 #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
112 #define _I386_PGTABLE_2LEVEL_DEFS_H
114 +#define HAVE_SHARED_KERNEL_PMD 0
115 +
116 /*
117 * traditional i386 two-level paging structure:
118 */
119 diff -urNpP linux-2.6.12/include/asm-i386/pgtable-3level-defs.h linux-2.6.12.new/include/asm-i386/pgtable-3level-defs.h
120 --- linux-2.6.12/include/asm-i386/pgtable-3level-defs.h 2005-06-17 20:48:29.000000000 +0100
121 +++ linux-2.6.12.new/include/asm-i386/pgtable-3level-defs.h 2005-07-11 16:28:09.755164902 +0100
122 @@ -1,6 +1,8 @@
123 #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
124 #define _I386_PGTABLE_3LEVEL_DEFS_H
126 +#define HAVE_SHARED_KERNEL_PMD 1
127 +
128 /*
129 * PGDIR_SHIFT determines what a top-level page table entry can map
130 */