diff options
Diffstat (limited to 'arch/x86/mm/init.c')
-rw-r--r-- | arch/x86/mm/init.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index d406c5239019..b278535b14aa 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <linux/gfp.h> | ||
1 | #include <linux/initrd.h> | 2 | #include <linux/initrd.h> |
2 | #include <linux/ioport.h> | 3 | #include <linux/ioport.h> |
3 | #include <linux/swap.h> | 4 | #include <linux/swap.h> |
@@ -266,16 +267,9 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, | |||
266 | if (!after_bootmem) | 267 | if (!after_bootmem) |
267 | find_early_table_space(end, use_pse, use_gbpages); | 268 | find_early_table_space(end, use_pse, use_gbpages); |
268 | 269 | ||
269 | #ifdef CONFIG_X86_32 | ||
270 | for (i = 0; i < nr_range; i++) | ||
271 | kernel_physical_mapping_init(mr[i].start, mr[i].end, | ||
272 | mr[i].page_size_mask); | ||
273 | ret = end; | ||
274 | #else /* CONFIG_X86_64 */ | ||
275 | for (i = 0; i < nr_range; i++) | 270 | for (i = 0; i < nr_range; i++) |
276 | ret = kernel_physical_mapping_init(mr[i].start, mr[i].end, | 271 | ret = kernel_physical_mapping_init(mr[i].start, mr[i].end, |
277 | mr[i].page_size_mask); | 272 | mr[i].page_size_mask); |
278 | #endif | ||
279 | 273 | ||
280 | #ifdef CONFIG_X86_32 | 274 | #ifdef CONFIG_X86_32 |
281 | early_ioremap_page_table_range_init(); | 275 | early_ioremap_page_table_range_init(); |
@@ -338,11 +332,23 @@ int devmem_is_allowed(unsigned long pagenr) | |||
338 | 332 | ||
339 | void free_init_pages(char *what, unsigned long begin, unsigned long end) | 333 | void free_init_pages(char *what, unsigned long begin, unsigned long end) |
340 | { | 334 | { |
341 | unsigned long addr = begin; | 335 | unsigned long addr; |
336 | unsigned long begin_aligned, end_aligned; | ||
337 | |||
338 | /* Make sure boundaries are page aligned */ | ||
339 | begin_aligned = PAGE_ALIGN(begin); | ||
340 | end_aligned = end & PAGE_MASK; | ||
342 | 341 | ||
343 | if (addr >= end) | 342 | if (WARN_ON(begin_aligned != begin || end_aligned != end)) { |
343 | begin = begin_aligned; | ||
344 | end = end_aligned; | ||
345 | } | ||
346 | |||
347 | if (begin >= end) | ||
344 | return; | 348 | return; |
345 | 349 | ||
350 | addr = begin; | ||
351 | |||
346 | /* | 352 | /* |
347 | * If debugging page accesses then do not free this memory but | 353 | * If debugging page accesses then do not free this memory but |
348 | * mark them not present - any buggy init-section access will | 354 | * mark them not present - any buggy init-section access will |
@@ -350,7 +356,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) | |||
350 | */ | 356 | */ |
351 | #ifdef CONFIG_DEBUG_PAGEALLOC | 357 | #ifdef CONFIG_DEBUG_PAGEALLOC |
352 | printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", | 358 | printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", |
353 | begin, PAGE_ALIGN(end)); | 359 | begin, end); |
354 | set_memory_np(begin, (end - begin) >> PAGE_SHIFT); | 360 | set_memory_np(begin, (end - begin) >> PAGE_SHIFT); |
355 | #else | 361 | #else |
356 | /* | 362 | /* |
@@ -365,8 +371,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) | |||
365 | for (; addr < end; addr += PAGE_SIZE) { | 371 | for (; addr < end; addr += PAGE_SIZE) { |
366 | ClearPageReserved(virt_to_page(addr)); | 372 | ClearPageReserved(virt_to_page(addr)); |
367 | init_page_count(virt_to_page(addr)); | 373 | init_page_count(virt_to_page(addr)); |
368 | memset((void *)(addr & ~(PAGE_SIZE-1)), | 374 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); |
369 | POISON_FREE_INITMEM, PAGE_SIZE); | ||
370 | free_page(addr); | 375 | free_page(addr); |
371 | totalram_pages++; | 376 | totalram_pages++; |
372 | } | 377 | } |
@@ -383,6 +388,15 @@ void free_initmem(void) | |||
383 | #ifdef CONFIG_BLK_DEV_INITRD | 388 | #ifdef CONFIG_BLK_DEV_INITRD |
384 | void free_initrd_mem(unsigned long start, unsigned long end) | 389 | void free_initrd_mem(unsigned long start, unsigned long end) |
385 | { | 390 | { |
386 | free_init_pages("initrd memory", start, end); | 391 | /* |
392 | * end could be not aligned, and We can not align that, | ||
393 | * decompresser could be confused by aligned initrd_end | ||
394 | * We already reserve the end partial page before in | ||
395 | * - i386_start_kernel() | ||
396 | * - x86_64_start_kernel() | ||
397 | * - relocate_initrd() | ||
398 | * So here We can do PAGE_ALIGN() safely to get partial page to be freed | ||
399 | */ | ||
400 | free_init_pages("initrd memory", start, PAGE_ALIGN(end)); | ||
387 | } | 401 | } |
388 | #endif | 402 | #endif |