summaryrefslogtreecommitdiff
blob: 072c5129c9ac2cbdb1cc2f9339abee3cada33157 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
From: jbeulich@novell.com
Subject: miscellaneous initialization code cleanup
Patch-mainline: obsolete

Index: 10.3-2007-10-22/arch/x86_64/kernel/head-xen.S
===================================================================
--- 10.3-2007-10-22.orig/arch/x86_64/kernel/head-xen.S	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/arch/x86_64/kernel/head-xen.S	2007-10-22 14:00:10.000000000 +0200
@@ -47,15 +47,13 @@ ENTRY(name)
 
 NEXT_PAGE(init_level4_pgt)
 	.fill	512,8,0
-
         /*
          * We update two pgd entries to make kernel and user pgd consistent
          * at pgd_populate(). It can be used for kernel modules. So we place 
          * this page here for those cases to avoid memory corruption.
-         * We also use this page to establish the initiali mapping for
+         * We also use this page to establish the initial mapping for the
          * vsyscall area.
          */
-NEXT_PAGE(init_level4_user_pgt)
 	.fill	512,8,0
 
 NEXT_PAGE(level3_kernel_pgt)
Index: 10.3-2007-10-22/arch/x86_64/kernel/setup-xen.c
===================================================================
--- 10.3-2007-10-22.orig/arch/x86_64/kernel/setup-xen.c	2007-10-22 14:00:08.000000000 +0200
+++ 10.3-2007-10-22/arch/x86_64/kernel/setup-xen.c	2007-10-22 14:00:10.000000000 +0200
@@ -448,28 +448,18 @@ void __init setup_arch(char **cmdline_p)
         */
        acpi_reserve_bootmem();
 #endif
-#ifdef CONFIG_XEN
 #ifdef CONFIG_BLK_DEV_INITRD
+#ifndef CONFIG_XEN
+	if (LOADER_TYPE && INITRD_START) {
+#else
 	if (xen_start_info->mod_start) {
-		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
-			/*reserve_bootmem_generic(INITRD_START, INITRD_SIZE);*/
-			initrd_start = INITRD_START + PAGE_OFFSET;
-			initrd_end = initrd_start+INITRD_SIZE;
-			initrd_below_start_ok = 1;
-		} else {
-			printk(KERN_ERR "initrd extends beyond end of memory "
-				"(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-				(unsigned long)(INITRD_START + INITRD_SIZE),
-				(unsigned long)(end_pfn << PAGE_SHIFT));
-			initrd_start = 0;
-		}
-	}
 #endif
-#else	/* CONFIG_XEN */
-#ifdef CONFIG_BLK_DEV_INITRD
-	if (LOADER_TYPE && INITRD_START) {
 		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
+#ifndef CONFIG_XEN
 			reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
+#else
+			initrd_below_start_ok = 1;
+#endif
 			initrd_start = INITRD_START + PAGE_OFFSET;
 			initrd_end = initrd_start+INITRD_SIZE;
 		}
@@ -482,7 +472,6 @@ void __init setup_arch(char **cmdline_p)
 		}
 	}
 #endif
-#endif	/* !CONFIG_XEN */
 #ifdef CONFIG_KEXEC
 #ifdef CONFIG_XEN
 	xen_machine_kexec_setup_resources();
Index: 10.3-2007-10-22/arch/x86_64/kernel/setup64-xen.c
===================================================================
--- 10.3-2007-10-22.orig/arch/x86_64/kernel/setup64-xen.c	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/arch/x86_64/kernel/setup64-xen.c	2007-10-22 14:00:10.000000000 +0200
@@ -127,8 +127,8 @@ void __init setup_per_cpu_areas(void)
 #ifdef CONFIG_XEN
 static void switch_pt(void)
 {
-	xen_pt_switch(__pa(init_level4_pgt));
-        xen_new_user_pt(__pa(init_level4_user_pgt));
+	xen_pt_switch(__pa_symbol(init_level4_pgt));
+	xen_new_user_pt(__pa_symbol(__user_pgd(init_level4_pgt)));
 }
 
 void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
Index: 10.3-2007-10-22/arch/x86_64/kernel/vsyscall-xen.c
===================================================================
--- 10.3-2007-10-22.orig/arch/x86_64/kernel/vsyscall-xen.c	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/arch/x86_64/kernel/vsyscall-xen.c	2007-10-22 14:00:10.000000000 +0200
@@ -344,17 +344,6 @@ static void __init map_vsyscall(void)
 	__set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
 }
 
-#ifdef CONFIG_XEN
-static void __init map_vsyscall_user(void)
-{
-	extern void __set_fixmap_user(enum fixed_addresses, unsigned long, pgprot_t);
-	extern char __vsyscall_0;
-	unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
-
-	__set_fixmap_user(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
-}
-#endif
-
 static int __init vsyscall_init(void)
 {
 	BUG_ON(((unsigned long) &vgettimeofday !=
@@ -364,7 +353,6 @@ static int __init vsyscall_init(void)
 	BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
 	map_vsyscall();
 #ifdef CONFIG_XEN
-	map_vsyscall_user();
 	vsyscall_gtod_data.sysctl_enabled = 0; /* disable vgettimeofay() */
  	if (boot_cpu_has(X86_FEATURE_RDTSCP))
 		vgetcpu_mode = VGETCPU_RDTSCP;
Index: 10.3-2007-10-22/arch/x86_64/mm/init-xen.c
===================================================================
--- 10.3-2007-10-22.orig/arch/x86_64/mm/init-xen.c	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/arch/x86_64/mm/init-xen.c	2007-10-22 14:00:10.000000000 +0200
@@ -61,6 +61,8 @@ unsigned int __kernel_page_user;
 EXPORT_SYMBOL(__kernel_page_user);
 #endif
 
+int after_bootmem;
+
 extern unsigned long *contiguous_bitmap;
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
@@ -86,6 +88,11 @@ static void __meminit early_make_page_re
 	if (xen_feature(feature))
 		return;
 
+	if (after_bootmem) {
+		make_page_readonly(va, feature);
+		return;
+	}
+
 	addr = (unsigned long) page[pgd_index(_va)];
 	addr_to_page(addr, page);
 
@@ -214,8 +221,6 @@ void show_mem(void)
 	printk(KERN_INFO "%lu pages swap cached\n",cached);
 }
 
-int after_bootmem;
-
 static __init void *spp_getpage(void)
 { 
 	void *ptr;
@@ -234,14 +239,8 @@ static __init void *spp_getpage(void)
 	return ptr;
 } 
 
-#define pgd_offset_u(address) (pgd_t *)(init_level4_user_pgt + pgd_index(address))
-
-static inline pud_t *pud_offset_u(unsigned long address)
-{
-	pud_t *pud = level3_user_pgt;
-
-	return pud + pud_index(address);
-}
+#define pgd_offset_u(address) (__user_pgd(init_level4_pgt) + pgd_index(address))
+#define pud_offset_u(address) (level3_user_pgt + pud_index(address))
 
 static __init void set_pte_phys(unsigned long vaddr,
 			 unsigned long phys, pgprot_t prot, int user_mode)
@@ -344,9 +343,6 @@ static __init void set_pte_phys_ma(unsig
 	__flush_tlb_one(vaddr);
 }
 
-#define SET_FIXMAP_KERNEL 0
-#define SET_FIXMAP_USER   1
-
 /* NOTE: this is meant to be run only at boot */
 void __init 
 __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
@@ -359,7 +355,8 @@ __set_fixmap (enum fixed_addresses idx, 
 	}
 	switch (idx) {
 	case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE:
-		set_pte_phys(address, phys, prot, SET_FIXMAP_KERNEL);
+		set_pte_phys(address, phys, prot, 0);
+		set_pte_phys(address, phys, prot, 1);
 		break;
 	default:
 		set_pte_phys_ma(address, phys, prot);
@@ -367,22 +364,6 @@ __set_fixmap (enum fixed_addresses idx, 
 	}
 }
 
-/*
- * This only supports vsyscall area.
- */
-void __init
-__set_fixmap_user (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
-{
-	unsigned long address = __fix_to_virt(idx);
-
-	if (idx >= __end_of_fixed_addresses) {
-		printk("Invalid __set_fixmap\n");
-		return;
-	}
-
-	set_pte_phys(address, phys, prot, SET_FIXMAP_USER); 
-}
-
 unsigned long __meminitdata table_start, table_end;
 
 static __meminit void *alloc_static_page(unsigned long *phys)
@@ -509,9 +490,9 @@ phys_pmd_init(pmd_t *pmd_page, unsigned 
 		pte = alloc_static_page(&pte_phys);
 		pte_save = pte;
 		for (k = 0; k < PTRS_PER_PTE; pte++, k++, address += PTE_SIZE) {
-			if ((address >= end) ||
-			    ((address >> PAGE_SHIFT) >=
-			     xen_start_info->nr_pages)) { 
+			if (address >= (after_bootmem
+			                ? end
+			                : xen_start_info->nr_pages << PAGE_SHIFT)) {
 				__set_pte(pte, __pte(0)); 
 				continue;
 			}
@@ -607,13 +588,15 @@ void __init xen_init_pt(void)
 	init_level4_pgt[pgd_index(__START_KERNEL_map)] = 
 		__pgd(__pa_symbol(level3_kernel_pgt) | _PAGE_TABLE);
 	level3_kernel_pgt[pud_index(__START_KERNEL_map)] = 
-		__pud(__pa_symbol(level2_kernel_pgt) |
-		      _KERNPG_TABLE);
-	memcpy((void *)level2_kernel_pgt, page, PAGE_SIZE);
+		__pud(__pa_symbol(level2_kernel_pgt) | _PAGE_TABLE);
+	memcpy(level2_kernel_pgt, page, PAGE_SIZE);
+
+	__user_pgd(init_level4_pgt)[pgd_index(VSYSCALL_START)] =
+		__pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE);
 
 	early_make_page_readonly(init_level4_pgt,
 				 XENFEAT_writable_page_tables);
-	early_make_page_readonly(init_level4_user_pgt,
+	early_make_page_readonly(__user_pgd(init_level4_pgt),
 				 XENFEAT_writable_page_tables);
 	early_make_page_readonly(level3_kernel_pgt,
 				 XENFEAT_writable_page_tables);
@@ -624,11 +607,8 @@ void __init xen_init_pt(void)
 
 	if (!xen_feature(XENFEAT_writable_page_tables)) {
 		xen_pgd_pin(__pa_symbol(init_level4_pgt));
-		xen_pgd_pin(__pa_symbol(init_level4_user_pgt));
+		xen_pgd_pin(__pa_symbol(__user_pgd(init_level4_pgt)));
 	}
-
-	set_pgd((pgd_t *)(init_level4_user_pgt + 511), 
-		mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
 }
 
 static void __init extend_init_mapping(unsigned long tables_space)
Index: 10.3-2007-10-22/include/asm-x86_64/mach-xen/asm/pgalloc.h
===================================================================
--- 10.3-2007-10-22.orig/include/asm-x86_64/mach-xen/asm/pgalloc.h	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/include/asm-x86_64/mach-xen/asm/pgalloc.h	2007-10-22 14:00:10.000000000 +0200
@@ -137,8 +137,8 @@ static inline pgd_t *pgd_alloc(struct mm
 	/*
 	 * Set level3_user_pgt for vsyscall area
 	 */
-	set_pgd(__user_pgd(pgd) + pgd_index(VSYSCALL_START),
-		__pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE));
+	__user_pgd(pgd)[pgd_index(VSYSCALL_START)] =
+		__pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE);
 	return pgd;
 }
 
Index: 10.3-2007-10-22/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
--- 10.3-2007-10-22.orig/include/asm-x86_64/mach-xen/asm/pgtable.h	2007-10-22 13:58:57.000000000 +0200
+++ 10.3-2007-10-22/include/asm-x86_64/mach-xen/asm/pgtable.h	2007-10-22 14:00:10.000000000 +0200
@@ -17,7 +17,6 @@
 #include <asm/hypervisor.h>
 
 extern pud_t level3_user_pgt[512];
-extern pud_t init_level4_user_pgt[];
 
 extern void xen_init_pt(void);
 
@@ -390,7 +389,7 @@ static inline int pmd_large(pmd_t pte) {
 #define pgd_page(pgd)		(pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT))
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 #define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
-#define pgd_offset_k(address) (pgd_t *)(init_level4_pgt + pgd_index(address))
+#define pgd_offset_k(address) (init_level4_pgt + pgd_index(address))
 #define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT)
 #define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE)