[PATCH][git pull] update to tip/tracing/ftrace

Steven Rostedt
2009-02-20T02:05:58Z

Ingo,

Please pull the latest tip/tracing/ftrace tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace

Steven Rostedt (1):
ftrace, x86: do not depend on system state for kernel text info

----
arch/x86/kernel/ftrace.c | 8 --------
arch/x86/mm/init_32.c | 10 ++++++++++
arch/x86/mm/init_64.c | 10 ++++++++++
3 files changed, 20 insertions(+), 8 deletions(-)
---------------------------
commit 5d8ecb6568c598de6b6e678329e2ec0703a821f7
Author: Steven Rostedt <srostedt@redhat.com>
Date: Thu Feb 19 20:51:45 2009 -0500

ftrace, x86: do not depend on system state for kernel text info

Andrew Morton pointed out that using SYSTEM_STATE is a bad idea
since there is no guarantee to what its state will actually be.

Instead, I moved the check into the set_kernel_text_* functions
themselves, and use a local variable to determine when it is
OK to change the kernel text RW permissions.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 26b64a8..4f4e82c 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -28,20 +28,12 @@

int ftrace_arch_modify_prepare(void)
{
- /* at boot up, we are still writable */
- if (system_state != SYSTEM_RUNNING)
- return 0;
-
set_kernel_text_rw();
return 0;
}

int ftrace_arch_modify_post_process(void)
{
- /* at boot up, we are still writable */
- if (system_state != SYSTEM_RUNNING)
- return 0;
-
set_kernel_text_ro();
return 0;
}
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index bcd7f00..9ca4c57 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -1155,12 +1155,17 @@ static noinline int do_test_wp_bit(void)
const int rodata_test_data = 0xC3;
EXPORT_SYMBOL_GPL(rodata_test_data);

+static int kernel_set_to_readonly;
+
/* used by ftrace */
void set_kernel_text_rw(void)
{
unsigned long start = PFN_ALIGN(_text);
unsigned long size = PFN_ALIGN(_etext) - start;

+ if (!kernel_set_to_readonly)
+ return;
+
printk(KERN_INFO "Set kernel text: %lx - %lx for read write\n",
start, start+size);

@@ -1173,6 +1178,9 @@ void set_kernel_text_ro(void)
unsigned long start = PFN_ALIGN(_text);
unsigned long size = PFN_ALIGN(_etext) - start;

+ if (!kernel_set_to_readonly)
+ return;
+
printk(KERN_INFO "Set kernel text: %lx - %lx for read only\n",
start, start+size);

@@ -1188,6 +1196,8 @@ void mark_rodata_ro(void)
printk(KERN_INFO "Write protecting the kernel text: %luk\n",
size >> 10);

+ kernel_set_to_readonly = 1;
+
#ifdef CONFIG_CPA_DEBUG
printk(KERN_INFO "Testing CPA: Reverting %lx-%lx\n",
start, start+size);
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 8c1b5ee..c204433 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -986,12 +986,17 @@ void free_initmem(void)
const int rodata_test_data = 0xC3;
EXPORT_SYMBOL_GPL(rodata_test_data);

+static int kernel_set_to_readonly;
+
/* used by ftrace */
void set_kernel_text_rw(void)
{
unsigned long start = PFN_ALIGN(_stext);
unsigned long end = PFN_ALIGN(__start_rodata);

+ if (!kernel_set_to_readonly)
+ return;
+
printk(KERN_INFO "Set kernel text: %lx - %lx for read write\n",
start, end);

@@ -1004,6 +1009,9 @@ void set_kernel_text_ro(void)
unsigned long start = PFN_ALIGN(_stext);
unsigned long end = PFN_ALIGN(__start_rodata);

+ if (!kernel_set_to_readonly)
+ return;
+
printk(KERN_INFO "Set kernel text: %lx - %lx for read only\n",
start, end);

@@ -1020,6 +1028,8 @@ void mark_rodata_ro(void)
(end - start) >> 10);
set_memory_ro(start, (end - start) >> PAGE_SHIFT);

+ kernel_set_to_readonly = 1;
+
/*
* The rodata section (but not the kernel text!) should also be
* not-executable.