diff mbox

powerpc: ftrace: bugfix for test_24bit_addr

Message ID 1393381381-30179-1-git-send-email-pingfank@linux.vnet.ibm.com (mailing list archive)
State Accepted
Headers show

Commit Message

Pingfan Liu Feb. 26, 2014, 2:23 a.m. UTC
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.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
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(+)

Comments

Ananth N Mavinakayanahalli Feb. 26, 2014, 4:35 a.m. UTC | #1
On Wed, Feb 26, 2014 at 10:23:01AM +0800, Liu Ping Fan wrote:
> 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.
> 
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
> 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(+)
> 
> diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> index 9b27b29..b0ded97 100644
> --- a/arch/powerpc/kernel/ftrace.c
> +++ b/arch/powerpc/kernel/ftrace.c
> @@ -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?
Pingfan Liu Feb. 26, 2014, 6:06 a.m. UTC | #2
On Wed, Feb 26, 2014 at 12:35 PM, Ananth N Mavinakayanahalli
<ananth@in.ibm.com> wrote:
> On Wed, Feb 26, 2014 at 10:23:01AM +0800, Liu Ping Fan wrote:
>> 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.
>>
>> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>> ---
>> 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(+)
>>
>> diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
>> index 9b27b29..b0ded97 100644
>> --- a/arch/powerpc/kernel/ftrace.c
>> +++ b/arch/powerpc/kernel/ftrace.c
>> @@ -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
Michael Ellerman Feb. 26, 2014, 12:22 p.m. UTC | #3
On Wed, 2014-02-26 at 10:05 +0530, Ananth N Mavinakayanahalli wrote:
> On Wed, Feb 26, 2014 at 10:23:01AM +0800, Liu Ping Fan wrote:
> > 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.
> > 
> > Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> > ---
> > 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(+)
> > 
> > diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> > index 9b27b29..b0ded97 100644
> > --- a/arch/powerpc/kernel/ftrace.c
> > +++ b/arch/powerpc/kernel/ftrace.c
> > @@ -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
Tony Breeds Feb. 26, 2014, 11:19 p.m. UTC | #4
On Wed, Feb 26, 2014 at 11:22:16PM +1100, Michael Ellerman wrote:
 
> 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
diff mbox

Patch

diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 9b27b29..b0ded97 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -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);