aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2009-03-03 06:15:02 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-03 06:21:17 -0500
commit05f209e7b936a48e341d36831079116a06658ccc (patch)
tree28eb28ba8f3eb627893b84716f3d62c5a8deebc2 /arch
parentfd578f9c0a0a7bf3e460e6f21cdc6f4018949e80 (diff)
x86: add sanity checks to init_32.c
Impact: unification This patch adds sanity checks that are already in init_64.c to init_32.c. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> LKML-Reference: <1236078902.2675.16.camel@penberg-laptop> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/mm/init_32.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 1dd6b6334dc..1570a822c18 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
1215void free_init_pages(char *what, unsigned long begin, unsigned long end) 1215void 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