ia64/xen-unstable

view patches/linux-2.6.12/pmd-shared.patch @ 8066:43e25c2653ee

Also, make a small tweak to the 12_block_attach test so that we don't leave
a DomU running with a block device attached.

Signed-off-by: Dan Smith <danms@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Fri Nov 25 23:19:23 2005 +0000 (2005-11-25)
parents b0338759544e
children 001ba14fbb1b
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-24 21:51:49.000000000 +0000
15 +++ linux-2.6.12.new/arch/i386/mm/pgtable.c 2005-11-24 22:06:04.000000000 +0000
16 @@ -199,19 +199,22 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
17 {
18 unsigned long flags;
20 - if (PTRS_PER_PMD == 1)
21 - spin_lock_irqsave(&pgd_lock, flags);
22 -
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 -
27 - if (PTRS_PER_PMD > 1)
28 - return;
29 -
30 - pgd_list_add(pgd);
31 - spin_unlock_irqrestore(&pgd_lock, flags);
32 - memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
33 + if (PTRS_PER_PMD > 1) {
34 + if (HAVE_SHARED_KERNEL_PMD)
35 + memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
36 + swapper_pg_dir, sizeof(pgd_t));
37 + } else {
38 + if (!HAVE_SHARED_KERNEL_PMD)
39 + spin_lock_irqsave(&pgd_lock, flags);
40 + memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
41 + swapper_pg_dir + USER_PTRS_PER_PGD,
42 + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
43 + memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
44 + if (!HAVE_SHARED_KERNEL_PMD) {
45 + pgd_list_add(pgd);
46 + spin_unlock_irqrestore(&pgd_lock, flags);
47 + }
48 + }
49 }
51 /* never called when PTRS_PER_PMD > 1 */
52 @@ -219,6 +222,9 @@ void pgd_dtor(void *pgd, kmem_cache_t *c
53 {
54 unsigned long flags; /* can be called from interrupt context */
56 + if (HAVE_SHARED_KERNEL_PMD)
57 + return;
58 +
59 spin_lock_irqsave(&pgd_lock, flags);
60 pgd_list_del(pgd);
61 spin_unlock_irqrestore(&pgd_lock, flags);
62 @@ -238,6 +244,24 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
63 goto out_oom;
64 set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
65 }
66 +
67 + if (!HAVE_SHARED_KERNEL_PMD) {
68 + unsigned long flags;
69 + pgd_t *copy_pgd = pgd_offset_k(PAGE_OFFSET);
70 + pud_t *copy_pud = pud_offset(copy_pgd, PAGE_OFFSET);
71 + pmd_t *copy_pmd = pmd_offset(copy_pud, PAGE_OFFSET);
72 + pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
73 + ++i;
74 + if (!pmd)
75 + goto out_oom;
76 +
77 + spin_lock_irqsave(&pgd_lock, flags);
78 + memcpy(pmd, copy_pmd, PAGE_SIZE);
79 + set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
80 + pgd_list_add(pgd);
81 + spin_unlock_irqrestore(&pgd_lock, flags);
82 + }
83 +
84 return pgd;
86 out_oom:
87 @@ -252,9 +276,21 @@ void pgd_free(pgd_t *pgd)
88 int i;
90 /* in the PAE case user pgd entries are overwritten before usage */
91 - if (PTRS_PER_PMD > 1)
92 - for (i = 0; i < USER_PTRS_PER_PGD; ++i)
93 - kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
94 + if (PTRS_PER_PMD > 1) {
95 + for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
96 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
97 + kmem_cache_free(pmd_cache, pmd);
98 + }
99 + if (!HAVE_SHARED_KERNEL_PMD) {
100 + unsigned long flags;
101 + pmd_t *pmd = (void *)__va(pgd_val(pgd[USER_PTRS_PER_PGD])-1);
102 + spin_lock_irqsave(&pgd_lock, flags);
103 + pgd_list_del(pgd);
104 + spin_unlock_irqrestore(&pgd_lock, flags);
105 + memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
106 + kmem_cache_free(pmd_cache, pmd);
107 + }
108 + }
109 /* in the non-PAE case, free_pgtables() clears user pgd entries */
110 kmem_cache_free(pgd_cache, pgd);
111 }
112 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
113 --- linux-2.6.12/include/asm-i386/pgtable-2level-defs.h 2005-06-17 20:48:29.000000000 +0100
114 +++ linux-2.6.12.new/include/asm-i386/pgtable-2level-defs.h 2005-07-11 16:28:09.733164251 +0100
115 @@ -1,6 +1,8 @@
116 #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
117 #define _I386_PGTABLE_2LEVEL_DEFS_H
119 +#define HAVE_SHARED_KERNEL_PMD 0
120 +
121 /*
122 * traditional i386 two-level paging structure:
123 */
124 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
125 --- linux-2.6.12/include/asm-i386/pgtable-3level-defs.h 2005-06-17 20:48:29.000000000 +0100
126 +++ linux-2.6.12.new/include/asm-i386/pgtable-3level-defs.h 2005-07-11 16:28:09.755164902 +0100
127 @@ -1,6 +1,8 @@
128 #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
129 #define _I386_PGTABLE_3LEVEL_DEFS_H
131 +#define HAVE_SHARED_KERNEL_PMD 1
132 +
133 /*
134 * PGDIR_SHIFT determines what a top-level page table entry can map
135 */