From: Ingo Molnar Date: Wed, 30 Jan 2008 12:34:09 +0000 (+0100) Subject: x86: init memory debugging X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee01f1122ceb02a2c9b7142c5dd17b49e59ba774;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git x86: init memory debugging debug incorrect/late access to init memory, by permanently unmapping the init memory ranges. Depends on CONFIG_DEBUG_PAGEALLOC=y. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index a72737c05747..8d7f723cfc28 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -783,6 +783,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) { unsigned long addr; +#ifdef CONFIG_DEBUG_PAGEALLOC + /* + * If debugging page accesses then do not free this memory but + * mark them not present - any buggy init-section access will + * create a kernel page fault: + */ + printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", + begin, PAGE_ALIGN(end)); + set_memory_np(begin, (end - begin) >> PAGE_SHIFT); +#else /* * We just marked the kernel text read only above, now that * we are going to free part of that, we need to make that @@ -798,6 +808,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) totalram_pages++; } printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); +#endif } void free_initmem(void) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index f51180c02b8f..e0c1e98ad1bf 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -550,6 +550,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) if (begin >= end) return; + /* + * If debugging page accesses then do not free this memory but + * mark them not present - any buggy init-section access will + * create a kernel page fault: + */ +#ifdef CONFIG_DEBUG_PAGEALLOC + printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", + begin, PAGE_ALIGN(end)); + set_memory_np(begin, (end - begin) >> PAGE_SHIFT); +#else printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); for (addr = begin; addr < end; addr += PAGE_SIZE) { ClearPageReserved(virt_to_page(addr)); @@ -575,6 +585,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) set_memory_nx(begin, (end - begin)/PAGE_SIZE); } #endif +#endif } void free_initmem(void)