direct-io.hg

view patches/linux-2.6.16.29/pmd-shared.patch @ 11750:d845c9522d9e

[HVM][SVM] Check if SVM is disabled by the BIOS before enabling it.

Newer BIOS implementations will be able to disable the SVM feature,
although an additional test of an MSR (VMCR 0xC0010114 bit 4) is
necessary (set equals disabled). Bit 4 of MSR 0xc0010114 returns 0
(SVM enabled) on machines with older BIOS' without the SVM disable
feature support.

Signed-off-by: Wei Huang <wei.huang2@amd.com>=20
Signed-off-by: Tom Woller <thomas.woller@amd.com>=20
author kfraser@localhost.localdomain
date Thu Oct 12 16:12:10 2006 +0100 (2006-10-12)
parents 041be3f6b38e
children
line source
1 diff -pruN ../orig-linux-2.6.16.29/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
2 --- ../orig-linux-2.6.16.29/arch/i386/mm/pageattr.c 2006-09-12 19:02:10.000000000 +0100
3 +++ ./arch/i386/mm/pageattr.c 2006-09-19 14:05:35.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 ../orig-linux-2.6.16.29/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
14 --- ../orig-linux-2.6.16.29/arch/i386/mm/pgtable.c 2006-09-12 19:02:10.000000000 +0100
15 +++ ./arch/i386/mm/pgtable.c 2006-09-19 14:05:35.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 ../orig-linux-2.6.16.29/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
89 --- ../orig-linux-2.6.16.29/include/asm-i386/pgtable-2level-defs.h 2006-09-12 19:02:10.000000000 +0100
90 +++ ./include/asm-i386/pgtable-2level-defs.h 2006-09-19 14:05:35.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 ../orig-linux-2.6.16.29/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
101 --- ../orig-linux-2.6.16.29/include/asm-i386/pgtable-3level-defs.h 2006-09-12 19:02:10.000000000 +0100
102 +++ ./include/asm-i386/pgtable-3level-defs.h 2006-09-19 14:05:35.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 */