ia64/xen-unstable

view patches/linux-2.6.16.13/pmd-shared.patch @ 10912:ee6014279103

[LINUX] Clarify a confusing error message in xenbus_probe.c.

Signed-off-by: Michael LeMay <mdlemay@epoch.ncsc.mil>
author kfraser@localhost.localdomain
date Wed Aug 02 14:59:22 2006 +0100 (2006-08-02)
parents ad5b833122a8
children
line source
1 diff -pruN ../pristine-linux-2.6.16.13/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
2 --- ../pristine-linux-2.6.16.13/arch/i386/mm/pageattr.c 2006-05-02 22:38:44.000000000 +0100
3 +++ ./arch/i386/mm/pageattr.c 2006-05-04 17:41:40.000000000 +0100
4 @@ -78,7 +78,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 -pruN ../pristine-linux-2.6.16.13/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
14 --- ../pristine-linux-2.6.16.13/arch/i386/mm/pgtable.c 2006-05-02 22:38:44.000000000 +0100
15 +++ ./arch/i386/mm/pgtable.c 2006-05-04 17:41:40.000000000 +0100
16 @@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
17 spin_lock_irqsave(&pgd_lock, flags);
18 }
20 - clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
21 - swapper_pg_dir + USER_PTRS_PER_PGD,
22 - KERNEL_PGD_PTRS);
23 + if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
24 + clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
25 + swapper_pg_dir + USER_PTRS_PER_PGD,
26 + KERNEL_PGD_PTRS);
27 if (PTRS_PER_PMD > 1)
28 return;
30 @@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31 goto out_oom;
32 set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
33 }
34 +
35 + if (!HAVE_SHARED_KERNEL_PMD) {
36 + unsigned long flags;
37 +
38 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
39 + pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
40 + if (!pmd)
41 + goto out_oom;
42 + set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
43 + }
44 +
45 + spin_lock_irqsave(&pgd_lock, flags);
46 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
47 + unsigned long v = (unsigned long)i << PGDIR_SHIFT;
48 + pgd_t *kpgd = pgd_offset_k(v);
49 + pud_t *kpud = pud_offset(kpgd, v);
50 + pmd_t *kpmd = pmd_offset(kpud, v);
51 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
52 + memcpy(pmd, kpmd, PAGE_SIZE);
53 + }
54 + pgd_list_add(pgd);
55 + spin_unlock_irqrestore(&pgd_lock, flags);
56 + }
57 +
58 return pgd;
60 out_oom:
61 @@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
62 int i;
64 /* in the PAE case user pgd entries are overwritten before usage */
65 - if (PTRS_PER_PMD > 1)
66 - for (i = 0; i < USER_PTRS_PER_PGD; ++i)
67 - kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
68 + if (PTRS_PER_PMD > 1) {
69 + for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
70 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
71 + kmem_cache_free(pmd_cache, pmd);
72 + }
73 + if (!HAVE_SHARED_KERNEL_PMD) {
74 + unsigned long flags;
75 + spin_lock_irqsave(&pgd_lock, flags);
76 + pgd_list_del(pgd);
77 + spin_unlock_irqrestore(&pgd_lock, flags);
78 + for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
79 + pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
80 + memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
81 + kmem_cache_free(pmd_cache, pmd);
82 + }
83 + }
84 + }
85 /* in the non-PAE case, free_pgtables() clears user pgd entries */
86 kmem_cache_free(pgd_cache, pgd);
87 }
88 diff -pruN ../pristine-linux-2.6.16.13/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
89 --- ../pristine-linux-2.6.16.13/include/asm-i386/pgtable-2level-defs.h 2006-05-02 22:38:44.000000000 +0100
90 +++ ./include/asm-i386/pgtable-2level-defs.h 2006-05-04 17:41:40.000000000 +0100
91 @@ -1,6 +1,8 @@
92 #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
93 #define _I386_PGTABLE_2LEVEL_DEFS_H
95 +#define HAVE_SHARED_KERNEL_PMD 0
96 +
97 /*
98 * traditional i386 two-level paging structure:
99 */
100 diff -pruN ../pristine-linux-2.6.16.13/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
101 --- ../pristine-linux-2.6.16.13/include/asm-i386/pgtable-3level-defs.h 2006-05-02 22:38:44.000000000 +0100
102 +++ ./include/asm-i386/pgtable-3level-defs.h 2006-05-04 17:41:40.000000000 +0100
103 @@ -1,6 +1,8 @@
104 #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
105 #define _I386_PGTABLE_3LEVEL_DEFS_H
107 +#define HAVE_SHARED_KERNEL_PMD 1
108 +
109 /*
110 * PGDIR_SHIFT determines what a top-level page table entry can map
111 */