All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mips/ftrace: Fix function tracing return address to match
@ 2013-07-15 22:17 David Daney
  2013-07-18 20:11 ` Steven Rostedt
  0 siblings, 1 reply; 8+ messages in thread
From: David Daney @ 2013-07-15 22:17 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: Corey Minyard, Steven Rostedt, David Daney

From: Corey Minyard <cminyard@mvista.com>

Dynamic function tracing was not working on MIPS.  When doing dynamic
tracing, the tracer attempts to match up the passed in address with
the one the compiler creates in the mcount tables.  The MIPS code was
passing in the return address from the tracing function call, but the
compiler tables were the address of the function call.  So they
wouldn't match.

Just subtracting 8 from the return address will give the address of
the function call.  Easy enough.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
[david.daney@cavium.com: Adjusted code comment and patch Subject.]
Signed-off-by: David Daney <david.daney@cavium.com>
---
 arch/mips/kernel/mcount.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index a03e93c..539b629 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -83,7 +83,7 @@ _mcount:
 	PTR_S	MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
 #endif
 
-	move	a0, ra		/* arg1: self return address */
+	PTR_SUBU a0, ra, 8	/* arg1: self address */
 	.globl ftrace_call
 ftrace_call:
 	nop	/* a placeholder for the call to a real tracing function */
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
  2013-07-15 22:17 [PATCH] mips/ftrace: Fix function tracing return address to match David Daney
@ 2013-07-18 20:11 ` Steven Rostedt
  2013-07-18 20:14   ` David Daney
  2013-07-19  0:24   ` Corey Minyard
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-07-18 20:11 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf, Corey Minyard, David Daney

On Mon, 2013-07-15 at 15:17 -0700, David Daney wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Dynamic function tracing was not working on MIPS.  When doing dynamic
> tracing, the tracer attempts to match up the passed in address with
> the one the compiler creates in the mcount tables.  The MIPS code was
> passing in the return address from the tracing function call, but the
> compiler tables were the address of the function call.  So they
> wouldn't match.
> 
> Just subtracting 8 from the return address will give the address of
> the function call.  Easy enough.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> [david.daney@cavium.com: Adjusted code comment and patch Subject.]
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
>  arch/mips/kernel/mcount.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
> index a03e93c..539b629 100644
> --- a/arch/mips/kernel/mcount.S
> +++ b/arch/mips/kernel/mcount.S
> @@ -83,7 +83,7 @@ _mcount:
>  	PTR_S	MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
>  #endif
>  
> -	move	a0, ra		/* arg1: self return address */
> +	PTR_SUBU a0, ra, 8	/* arg1: self address */
>  	.globl ftrace_call
>  ftrace_call:
>  	nop	/* a placeholder for the call to a real tracing function */

I applied this patch to my Yeeloong Lemote laptop and it causes the
system to crash. Not sure why. I'll try to investigate.

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
  2013-07-18 20:11 ` Steven Rostedt
@ 2013-07-18 20:14   ` David Daney
  2013-07-18 20:26     ` Steven Rostedt
  2013-07-19  0:24   ` Corey Minyard
  1 sibling, 1 reply; 8+ messages in thread
From: David Daney @ 2013-07-18 20:14 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-mips, ralf, Corey Minyard, David Daney

On 07/18/2013 01:11 PM, Steven Rostedt wrote:
> On Mon, 2013-07-15 at 15:17 -0700, David Daney wrote:
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> Dynamic function tracing was not working on MIPS.  When doing dynamic
>> tracing, the tracer attempts to match up the passed in address with
>> the one the compiler creates in the mcount tables.  The MIPS code was
>> passing in the return address from the tracing function call, but the
>> compiler tables were the address of the function call.  So they
>> wouldn't match.
>>
>> Just subtracting 8 from the return address will give the address of
>> the function call.  Easy enough.
>>
>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>> [david.daney@cavium.com: Adjusted code comment and patch Subject.]
>> Signed-off-by: David Daney <david.daney@cavium.com>
>> ---
>>   arch/mips/kernel/mcount.S | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
>> index a03e93c..539b629 100644
>> --- a/arch/mips/kernel/mcount.S
>> +++ b/arch/mips/kernel/mcount.S
>> @@ -83,7 +83,7 @@ _mcount:
>>   	PTR_S	MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
>>   #endif
>>
>> -	move	a0, ra		/* arg1: self return address */
>> +	PTR_SUBU a0, ra, 8	/* arg1: self address */
>>   	.globl ftrace_call
>>   ftrace_call:
>>   	nop	/* a placeholder for the call to a real tracing function */
>
> I applied this patch to my Yeeloong Lemote laptop and it causes the
> system to crash. Not sure why. I'll try to investigate.
>

There is an mcount ABI difference based on which GCC version you are 
using, although I wouldn't think it would effect this bit.

We are using GCC-4.7 FWIW.

David Daney


> -- Steve
>
>
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
  2013-07-18 20:14   ` David Daney
@ 2013-07-18 20:26     ` Steven Rostedt
  2013-07-18 20:27       ` Steven Rostedt
  2013-07-18 20:37         ` David Daney
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-07-18 20:26 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf, Corey Minyard, David Daney

On Thu, 2013-07-18 at 13:14 -0700, David Daney wrote:

> There is an mcount ABI difference based on which GCC version you are 
> using, although I wouldn't think it would effect this bit.
> 
> We are using GCC-4.7 FWIW.
> 
> David Daney

I'm using 4.6.3 which I downloaded from
https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/

I can down load the 4.7 version and see if that makes a difference.

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
  2013-07-18 20:26     ` Steven Rostedt
@ 2013-07-18 20:27       ` Steven Rostedt
  2013-07-18 20:37         ` David Daney
  1 sibling, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-07-18 20:27 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf, Corey Minyard, David Daney

On Thu, 2013-07-18 at 16:26 -0400, Steven Rostedt wrote:
> I can down load the 4.7 version and see if that makes a difference.

I guess I can't. There is no 4.7 version for MIPS :-p

https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.7.3/

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
@ 2013-07-18 20:37         ` David Daney
  0 siblings, 0 replies; 8+ messages in thread
From: David Daney @ 2013-07-18 20:37 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: David Daney, linux-mips, ralf, Corey Minyard, David Daney

On 07/18/2013 01:26 PM, Steven Rostedt wrote:
> On Thu, 2013-07-18 at 13:14 -0700, David Daney wrote:
>
>> There is an mcount ABI difference based on which GCC version you are
>> using, although I wouldn't think it would effect this bit.
>>
>> We are using GCC-4.7 FWIW.
>>
>> David Daney
>
> I'm using 4.6.3 which I downloaded from
> https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/

I would expect that version to be fine too.  The option in question is 
-mmcount-ra-address, which I added to GCC-4.5

>
> I can down load the 4.7 version and see if that makes a difference.
>
> -- Steve
>
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
@ 2013-07-18 20:37         ` David Daney
  0 siblings, 0 replies; 8+ messages in thread
From: David Daney @ 2013-07-18 20:37 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: David Daney, linux-mips, ralf, Corey Minyard, David Daney

On 07/18/2013 01:26 PM, Steven Rostedt wrote:
> On Thu, 2013-07-18 at 13:14 -0700, David Daney wrote:
>
>> There is an mcount ABI difference based on which GCC version you are
>> using, although I wouldn't think it would effect this bit.
>>
>> We are using GCC-4.7 FWIW.
>>
>> David Daney
>
> I'm using 4.6.3 which I downloaded from
> https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/

I would expect that version to be fine too.  The option in question is 
-mmcount-ra-address, which I added to GCC-4.5

>
> I can down load the 4.7 version and see if that makes a difference.
>
> -- Steve
>
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mips/ftrace: Fix function tracing return address to match
  2013-07-18 20:11 ` Steven Rostedt
  2013-07-18 20:14   ` David Daney
@ 2013-07-19  0:24   ` Corey Minyard
  1 sibling, 0 replies; 8+ messages in thread
From: Corey Minyard @ 2013-07-19  0:24 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: David Daney, linux-mips, ralf, David Daney

On 07/18/2013 03:11 PM, Steven Rostedt wrote:
> On Mon, 2013-07-15 at 15:17 -0700, David Daney wrote:
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> Dynamic function tracing was not working on MIPS.  When doing dynamic
>> tracing, the tracer attempts to match up the passed in address with
>> the one the compiler creates in the mcount tables.  The MIPS code was
>> passing in the return address from the tracing function call, but the
>> compiler tables were the address of the function call.  So they
>> wouldn't match.
>>
>> Just subtracting 8 from the return address will give the address of
>> the function call.  Easy enough.
>>
>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>> [david.daney@cavium.com: Adjusted code comment and patch Subject.]
>> Signed-off-by: David Daney <david.daney@cavium.com>
>> ---
>>   arch/mips/kernel/mcount.S | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
>> index a03e93c..539b629 100644
>> --- a/arch/mips/kernel/mcount.S
>> +++ b/arch/mips/kernel/mcount.S
>> @@ -83,7 +83,7 @@ _mcount:
>>   	PTR_S	MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
>>   #endif
>>   
>> -	move	a0, ra		/* arg1: self return address */
>> +	PTR_SUBU a0, ra, 8	/* arg1: self address */
>>   	.globl ftrace_call
>>   ftrace_call:
>>   	nop	/* a placeholder for the call to a real tracing function */
> I applied this patch to my Yeeloong Lemote laptop and it causes the
> system to crash. Not sure why. I'll try to investigate.
>
> -- Steve
>
>
That is bizarre.  That value should just be used for comparisons, it 
isn't dereferenced or anything like that.  What tracing do you have enabled?

-corey

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-19  0:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 22:17 [PATCH] mips/ftrace: Fix function tracing return address to match David Daney
2013-07-18 20:11 ` Steven Rostedt
2013-07-18 20:14   ` David Daney
2013-07-18 20:26     ` Steven Rostedt
2013-07-18 20:27       ` Steven Rostedt
2013-07-18 20:37       ` David Daney
2013-07-18 20:37         ` David Daney
2013-07-19  0:24   ` Corey Minyard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.