diff options
-rw-r--r-- | arch/x86/mm/init_32.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 1dd6b6334dc8..1570a822c18a 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
@@ -1214,18 +1214,21 @@ void mark_rodata_ro(void) | |||
1214 | 1214 | ||
1215 | void free_init_pages(char *what, unsigned long begin, unsigned long end) | 1215 | void free_init_pages(char *what, unsigned long begin, unsigned long end) |
1216 | { | 1216 | { |
1217 | #ifdef CONFIG_DEBUG_PAGEALLOC | 1217 | unsigned long addr = begin; |
1218 | |||
1219 | if (addr >= end) | ||
1220 | return; | ||
1221 | |||
1218 | /* | 1222 | /* |
1219 | * If debugging page accesses then do not free this memory but | 1223 | * If debugging page accesses then do not free this memory but |
1220 | * mark them not present - any buggy init-section access will | 1224 | * mark them not present - any buggy init-section access will |
1221 | * create a kernel page fault: | 1225 | * create a kernel page fault: |
1222 | */ | 1226 | */ |
1227 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1223 | printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", | 1228 | printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", |
1224 | begin, PAGE_ALIGN(end)); | 1229 | begin, PAGE_ALIGN(end)); |
1225 | set_memory_np(begin, (end - begin) >> PAGE_SHIFT); | 1230 | set_memory_np(begin, (end - begin) >> PAGE_SHIFT); |
1226 | #else | 1231 | #else |
1227 | unsigned long addr; | ||
1228 | |||
1229 | /* | 1232 | /* |
1230 | * We just marked the kernel text read only above, now that | 1233 | * We just marked the kernel text read only above, now that |
1231 | * we are going to free part of that, we need to make that | 1234 | * we are going to free part of that, we need to make that |
@@ -1233,14 +1236,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) | |||
1233 | */ | 1236 | */ |
1234 | set_memory_rw(begin, (end - begin) >> PAGE_SHIFT); | 1237 | set_memory_rw(begin, (end - begin) >> PAGE_SHIFT); |
1235 | 1238 | ||
1236 | for (addr = begin; addr < end; addr += PAGE_SIZE) { | 1239 | printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); |
1240 | |||
1241 | for (; addr < end; addr += PAGE_SIZE) { | ||
1237 | ClearPageReserved(virt_to_page(addr)); | 1242 | ClearPageReserved(virt_to_page(addr)); |
1238 | init_page_count(virt_to_page(addr)); | 1243 | init_page_count(virt_to_page(addr)); |
1239 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | 1244 | memset((void *)(addr & ~(PAGE_SIZE-1)), |
1245 | POISON_FREE_INITMEM, PAGE_SIZE); | ||
1240 | free_page(addr); | 1246 | free_page(addr); |
1241 | totalram_pages++; | 1247 | totalram_pages++; |
1242 | } | 1248 | } |
1243 | printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); | ||
1244 | #endif | 1249 | #endif |
1245 | } | 1250 | } |
1246 | 1251 | ||