提交 ee01f112 编写于 作者: I Ingo Molnar

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: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 1a487252
...@@ -783,6 +783,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) ...@@ -783,6 +783,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
{ {
unsigned long addr; 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 just marked the kernel text read only above, now that
* we are going to free part of that, we need to make 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) ...@@ -798,6 +808,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
totalram_pages++; totalram_pages++;
} }
printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
#endif
} }
void free_initmem(void) void free_initmem(void)
......
...@@ -550,6 +550,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) ...@@ -550,6 +550,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
if (begin >= end) if (begin >= end)
return; 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); printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
for (addr = begin; addr < end; addr += PAGE_SIZE) { for (addr = begin; addr < end; addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr)); ClearPageReserved(virt_to_page(addr));
...@@ -575,6 +585,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) ...@@ -575,6 +585,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
set_memory_nx(begin, (end - begin)/PAGE_SIZE); set_memory_nx(begin, (end - begin)/PAGE_SIZE);
} }
#endif #endif
#endif
} }
void free_initmem(void) void free_initmem(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册