提交 3c1df68b 编写于 作者: A Arjan van de Ven 提交者: Ingo Molnar

x86: make sure initmem is writable

When we free initmem, various rodata and CPA checks may have left
memory read only.. this patch ensures that the memory is writable
before we free it.
Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 488fd995
...@@ -780,6 +780,13 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) ...@@ -780,6 +780,13 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
{ {
unsigned long addr; unsigned long addr;
/*
* We just marked the kernel text read only above, now that
* we are going to free part of that, we need to make that
* writeable first.
*/
set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
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));
init_page_count(virt_to_page(addr)); init_page_count(virt_to_page(addr));
......
...@@ -570,6 +570,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) ...@@ -570,6 +570,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
* 2Mb kernel mapping just for this debug feature. * 2Mb kernel mapping just for this debug feature.
*/ */
if (begin >= __START_KERNEL_map) { if (begin >= __START_KERNEL_map) {
set_memory_rw(begin, (end - begin)/PAGE_SIZE);
set_memory_np(begin, (end - begin)/PAGE_SIZE); set_memory_np(begin, (end - begin)/PAGE_SIZE);
set_memory_nx(begin, (end - begin)/PAGE_SIZE); set_memory_nx(begin, (end - begin)/PAGE_SIZE);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册