microblaze: Fix ftrace_update_ftrace_func panic

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, April 7, 2010 - 9:59 am

Gitweb:     http://git.kernel.org/linus/d2bf98e6fc2612cbd2fc40f75a1e2c5d60262331
Commit:     d2bf98e6fc2612cbd2fc40f75a1e2c5d60262331
Parent:     0fdf86754f70e813845af4abaa805165ce57a0bb
Author:     Steven J. Magnani <steve@digidescorp.com>
AuthorDate: Fri Apr 2 13:29:39 2010 -0500
Committer:  Michal Simek <monstr@monstr.eu>
CommitDate: Wed Apr 7 07:27:25 2010 +0200

    microblaze: Fix ftrace_update_ftrace_func panic
    
    The Microblaze dynamic ftrace code assumes a call ordering that is not met
    in all scenarios. Specifically, executing a command similar to:
    
      echo 105 > /sys/kernel/debug/tracing/set_ftrace_pid
    
    before any other tracing-related commands results in a kernel panic:
    
      BUG: failure at arch/microblaze/kernel/ftrace.c:198/ftrace_update_ftrace_func()!
    
    Recoding ftrace_update_ftrace_func() to use &ftrace_caller directly eliminates
    the need to capture its address elsewhere (and thus rely on a particular call
    sequence).
    
    Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
    Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/kernel/ftrace.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
index 388b31c..515feb4 100644
--- a/arch/microblaze/kernel/ftrace.c
+++ b/arch/microblaze/kernel/ftrace.c
@@ -151,13 +151,10 @@ int ftrace_make_nop(struct module *mod,
 	return ret;
 }
 
-static int ret_addr; /* initialized as 0 by default */
-
 /* I believe that first is called ftrace_make_nop before this function */
 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 {
 	int ret;
-	ret_addr = addr; /* saving where the barrier jump is */
 	pr_debug("%s: addr:0x%x, rec->ip: 0x%x, imm:0x%x\n",
 		__func__, (unsigned int)addr, (unsigned int)rec->ip, imm);
 	ret = ftrace_modify_code(rec->ip, imm);
@@ -194,12 +191,9 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
 	ret = ftrace_modify_code(ip, upper);
 	ret += ftrace_modify_code(ip + 4, lower);
 
-	/* We just need to remove the rtsd r15, 8 by NOP */
-	BUG_ON(!ret_addr);
-	if (ret_addr)
-		ret += ftrace_modify_code(ret_addr, MICROBLAZE_NOP);
-	else
-		ret = 1; /* fault */
+	/* We just need to replace the rtsd r15, 8 with NOP */
+	ret += ftrace_modify_code((unsigned long)&ftrace_caller,
+				  MICROBLAZE_NOP);
 
 	/* All changes are done - lets do caches consistent */
 	flush_icache();
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
microblaze: Fix ftrace_update_ftrace_func panic, Linux Kernel Mailing ..., (Wed Apr 7, 9:59 am)