Skip to contentSkip to conversation

powerpc: ftrace: bugfix for test_24bit_addr

PATCH In review Liu Ping Fan 4 participants 5 messages Feb 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: ftrace: bugfix for test_24bit_addr

The branch target should be the func addr, not the addr of func_descr_t. So using ppc_function_entry() to generate the right target addr.

---
This bug will make ftrace fail to work. It can be triggered when the kernel size grows up.

---
 arch/powerpc/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kernel/ftrace.c +1 -0
index 9b27b29..b0ded97 100644
@@ -74,6 +74,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
  */
 static int test_24bit_addr(unsigned long ip, unsigned long addr)
 {
+	addr = ppc_function_entry((void *)addr);
 
 	/* use the create_branch to verify that this offset can be branched */
 	return create_branch((unsigned int *)ip, addr, 0);
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 16 lines · Liu Ping Fan

The branch target should be the func addr, not the addr of func_descr_t. So using ppc_function_entry() to generate the right target addr.

---
This bug will make ftrace fail to work. It can be triggered when the kernel size grows up.

---
 arch/powerpc/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kernel/ftrace.c +0 -0
index 9b27b29..b0ded97 100644

arch/powerpc/kernel/ftrace.c ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) · line 77

Quoted 4 lines
arch/powerpc/kernel/ftrace.c +1 -0
@@ -74,6 +74,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
  */
 static int test_24bit_addr(unsigned long ip, unsigned long addr)
 {
+	addr = ppc_function_entry((void *)addr);

Won't this break on LE?

#2 lore raw
Quoted 12 lines · Ananth N Mavinakayanahalli
Quoted 11 lines · Liu Ping Fan

The branch target should be the func addr, not the addr of func_descr_t. So using ppc_function_entry() to generate the right target addr.

---
This bug will make ftrace fail to work. It can be triggered when the kernel size grows up.

---
 arch/powerpc/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

arch/powerpc/kernel/ftrace.c ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) · line 77

Quoted 9 lines
arch/powerpc/kernel/ftrace.c +1 -0
index 9b27b29..b0ded97 100644
@@ -74,6 +74,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
  */
 static int test_24bit_addr(unsigned long ip, unsigned long addr)
 {
+     addr = ppc_function_entry((void *)addr);

Won't this break on LE?

How? I can not figure out it. Anyway, ppc_function_entry() is already used in other places with LE.

Thx,
Fan

#3 lore raw
In reply to Ananth N Mavinakayanahalli
Quoted 12 lines · Ananth N Mavinakayanahalli
Quoted 11 lines · Liu Ping Fan

The branch target should be the func addr, not the addr of func_descr_t. So using ppc_function_entry() to generate the right target addr.

---
This bug will make ftrace fail to work. It can be triggered when the kernel size grows up.

---
 arch/powerpc/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

arch/powerpc/kernel/ftrace.c ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) · line 77

Quoted 9 lines
arch/powerpc/kernel/ftrace.c +1 -0
index 9b27b29..b0ded97 100644
@@ -74,6 +74,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
  */
 static int test_24bit_addr(unsigned long ip, unsigned long addr)
 {
+	addr = ppc_function_entry((void *)addr);

Won't this break on LE?

ppc_function_entry() just needs to be a nop on LE, as it already is on 32-bit.

cheers

#4 lore raw
Quoted 1 line · Michael Ellerman

ppc_function_entry() just needs to be a nop on LE, as it already is on 32-bit.

Well on LE ABI2, but yes.

Yours Tony