linux-mips
[Top] [All Lists]

Re: [PATCH] mips/ftrace: Fix function tracing return address to match

To: Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] mips/ftrace: Fix function tracing return address to match
From: Corey Minyard <cminyard@mvista.com>
Date: Thu, 18 Jul 2013 19:24:06 -0500
Cc: David Daney <ddaney.cavm@gmail.com>, linux-mips@linux-mips.org, ralf@linux-mips.org, David Daney <david.daney@cavium.com>
In-reply-to: <1374178262.6458.266.camel@gandalf.local.home>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1373926637-24627-1-git-send-email-ddaney.cavm@gmail.com> <1374178262.6458.266.camel@gandalf.local.home>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
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

<Prev in Thread] Current Thread [Next in Thread>