lkml.org 
[lkml]   [2009]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 3/3] x86_64, cpa: use only text section in set_kernel_text_rw/ro
set_kernel_text_rw()/set_kernel_text_ro() are marking pages starting
from _text to __start_rodata as RW or RO.

With CONFIG_DEBUG_RODATA, there might be free pages (associated with
padding the sections to 2MB large page boundary) between text
and rodata sections that are given back to page allocator. So we should
use only use the start (__text) and end (__stop___ex_table) of the
text section in set_kernel_text_rw()/set_kernel_text_ro().

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/mm/init_64.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

Index: tip/arch/x86/mm/init_64.c
===================================================================
--- tip.orig/arch/x86/mm/init_64.c
+++ tip/arch/x86/mm/init_64.c
@@ -700,7 +700,7 @@ int kernel_set_to_readonly;
void set_kernel_text_rw(void)
{
unsigned long start = PFN_ALIGN(_text);
- unsigned long end = PFN_ALIGN(__start_rodata);
+ unsigned long end = PFN_ALIGN(__stop___ex_table);

if (!kernel_set_to_readonly)
return;
@@ -708,13 +708,18 @@ void set_kernel_text_rw(void)
pr_debug("Set kernel text: %lx - %lx for read write\n",
start, end);

+ /*
+ * Make the kernel identity mapping for text RW. Kernel text
+ * mapping will always be RO. Refer to the comment in
+ * static_protections() in pageattr.c
+ */
set_memory_rw(start, (end - start) >> PAGE_SHIFT);
}

void set_kernel_text_ro(void)
{
unsigned long start = PFN_ALIGN(_text);
- unsigned long end = PFN_ALIGN(__start_rodata);
+ unsigned long end = PFN_ALIGN(__stop___ex_table);

if (!kernel_set_to_readonly)
return;
@@ -722,6 +727,9 @@ void set_kernel_text_ro(void)
pr_debug("Set kernel text: %lx - %lx for read only\n",
start, end);

+ /*
+ * Set the kernel identity mapping for text RO.
+ */
set_memory_ro(start, (end - start) >> PAGE_SHIFT);
}




\
 
 \ /
  Last update: 2009-10-29 02:55    [W:0.080 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site