[PATCH] x86_64: eliminate empty_bad_{page,{pte,pmd}_table}

... as they are no longer needed. Since there were hard-coded numbers in the
file, the patch also adds a mechanism to avoid these (otherwise potential
future changes would again and again require adjusting these numbers).

Signed-Off-By: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jan Beulich and committed by Linus Torvalds f0cf5d1a 0addb142

+37 -71
+37 -71
arch/x86_64/kernel/head.S
··· 241 241 ENTRY(stext) 242 242 ENTRY(_stext) 243 243 244 - .org 0x1000 245 - ENTRY(init_level4_pgt) 244 + $page = 0 245 + #define NEXT_PAGE(name) \ 246 + $page = $page + 1; \ 247 + .org $page * 0x1000; \ 248 + phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \ 249 + ENTRY(name) 250 + 251 + NEXT_PAGE(init_level4_pgt) 246 252 /* This gets initialized in x86_64_start_kernel */ 247 253 .fill 512,8,0 248 254 249 - .org 0x2000 250 - ENTRY(level3_ident_pgt) 251 - .quad 0x0000000000004007 + __PHYSICAL_START 255 + NEXT_PAGE(level3_ident_pgt) 256 + .quad phys_level2_ident_pgt | 0x007 252 257 .fill 511,8,0 253 258 254 - .org 0x3000 255 - ENTRY(level3_kernel_pgt) 259 + NEXT_PAGE(level3_kernel_pgt) 256 260 .fill 510,8,0 257 261 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ 258 - .quad 0x0000000000005007 + __PHYSICAL_START /* -> level2_kernel_pgt */ 262 + .quad phys_level2_kernel_pgt | 0x007 259 263 .fill 1,8,0 260 264 261 - .org 0x4000 262 - ENTRY(level2_ident_pgt) 265 + NEXT_PAGE(level2_ident_pgt) 263 266 /* 40MB for bootup. */ 264 - .quad 0x0000000000000083 265 - .quad 0x0000000000200083 266 - .quad 0x0000000000400083 267 - .quad 0x0000000000600083 268 - .quad 0x0000000000800083 269 - .quad 0x0000000000A00083 270 - .quad 0x0000000000C00083 271 - .quad 0x0000000000E00083 272 - .quad 0x0000000001000083 273 - .quad 0x0000000001200083 274 - .quad 0x0000000001400083 275 - .quad 0x0000000001600083 276 - .quad 0x0000000001800083 277 - .quad 0x0000000001A00083 278 - .quad 0x0000000001C00083 279 - .quad 0x0000000001E00083 280 - .quad 0x0000000002000083 281 - .quad 0x0000000002200083 282 - .quad 0x0000000002400083 283 - .quad 0x0000000002600083 267 + i = 0 268 + .rept 20 269 + .quad i << 21 | 0x083 270 + i = i + 1 271 + .endr 284 272 /* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */ 285 273 .globl temp_boot_pmds 286 274 temp_boot_pmds: 287 275 .fill 492,8,0 288 276 289 - .org 0x5000 290 - ENTRY(level2_kernel_pgt) 277 + NEXT_PAGE(level2_kernel_pgt) 291 278 /* 40MB kernel mapping. The kernel code cannot be bigger than that. 292 279 When you change this change KERNEL_TEXT_SIZE in page.h too. */ 293 280 /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ 294 - .quad 0x0000000000000183 295 - .quad 0x0000000000200183 296 - .quad 0x0000000000400183 297 - .quad 0x0000000000600183 298 - .quad 0x0000000000800183 299 - .quad 0x0000000000A00183 300 - .quad 0x0000000000C00183 301 - .quad 0x0000000000E00183 302 - .quad 0x0000000001000183 303 - .quad 0x0000000001200183 304 - .quad 0x0000000001400183 305 - .quad 0x0000000001600183 306 - .quad 0x0000000001800183 307 - .quad 0x0000000001A00183 308 - .quad 0x0000000001C00183 309 - .quad 0x0000000001E00183 310 - .quad 0x0000000002000183 311 - .quad 0x0000000002200183 312 - .quad 0x0000000002400183 313 - .quad 0x0000000002600183 281 + i = 0 282 + .rept 20 283 + .quad i << 21 | 0x183 284 + i = i + 1 285 + .endr 314 286 /* Module mapping starts here */ 315 287 .fill 492,8,0 316 288 317 - .org 0x6000 318 - ENTRY(empty_zero_page) 289 + NEXT_PAGE(empty_zero_page) 319 290 320 - .org 0x7000 321 - ENTRY(empty_bad_page) 291 + NEXT_PAGE(level3_physmem_pgt) 292 + .quad phys_level2_kernel_pgt | 0x007 /* so that __va works even before pagetable_init */ 293 + .fill 511,8,0 322 294 323 - .org 0x8000 324 - ENTRY(empty_bad_pte_table) 295 + #undef NEXT_PAGE 325 296 326 - .org 0x9000 327 - ENTRY(empty_bad_pmd_table) 297 + .data 328 298 329 - .org 0xa000 330 - ENTRY(level3_physmem_pgt) 331 - .quad 0x0000000000005007 + __PHYSICAL_START /* -> level2_kernel_pgt (so that __va works even before pagetable_init) */ 332 - 333 - .org 0xb000 334 299 #ifdef CONFIG_ACPI_SLEEP 300 + .align PAGE_SIZE 335 301 ENTRY(wakeup_level4_pgt) 336 - .quad 0x0000000000002007 + __PHYSICAL_START /* -> level3_ident_pgt */ 302 + .quad phys_level3_ident_pgt | 0x007 337 303 .fill 255,8,0 338 - .quad 0x000000000000a007 + __PHYSICAL_START 304 + .quad phys_level3_physmem_pgt | 0x007 339 305 .fill 254,8,0 340 306 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ 341 - .quad 0x0000000000003007 + __PHYSICAL_START /* -> level3_kernel_pgt */ 307 + .quad phys_level3_kernel_pgt | 0x007 342 308 #endif 343 309 344 310 #ifndef CONFIG_HOTPLUG_CPU ··· 318 352 */ 319 353 .align PAGE_SIZE 320 354 ENTRY(boot_level4_pgt) 321 - .quad 0x0000000000002007 + __PHYSICAL_START /* -> level3_ident_pgt */ 355 + .quad phys_level3_ident_pgt | 0x007 322 356 .fill 255,8,0 323 - .quad 0x000000000000a007 + __PHYSICAL_START 357 + .quad phys_level3_physmem_pgt | 0x007 324 358 .fill 254,8,0 325 359 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ 326 - .quad 0x0000000000003007 + __PHYSICAL_START /* -> level3_kernel_pgt */ 360 + .quad phys_level3_kernel_pgt | 0x007 327 361 328 362 .data 329 363