mips/ftrace: Fix function tracing return address to match
PATCH 1/1 mips/ftrace: Fix function tracing return address to match
From: Corey Minyard <[email protected]>
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.
--- arch/mips/kernel/mcount.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/mcount.S +1 -1
@@ -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 */
Signature · 1 line
1.7.11.7
Quoted 24 lines · David Daney
From: Corey Minyard <[email protected]>
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 <[email protected]>[[email protected]: Adjusted code comment and patch Subject.]Signed-off-by David Daney <[email protected]>--- arch/mips/kernel/mcount.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/mcount.S +0
-0
arch/mips/kernel/mcount.S _mcount: · line 89
Quoted 8 lines
arch/mips/kernel/mcount.S +1
-1@@ -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
Quoted 28 lines · Steven Rostedt
Quoted 27 lines · David Daney
From: Corey Minyard <[email protected]>
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 <[email protected]>[[email protected]: Adjusted code comment and patch Subject.]Signed-off-by David Daney <[email protected]>--- arch/mips/kernel/mcount.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/mcount.S +0
-0@@ -83,7 +83,7 @@ _mcount: PTR_S MCOUNT_RA_ADDRESS_REG, PT_R12(sp) #endif
Quoted 9 lines
arch/mips/kernel/mcount.S _mcount: · line 89
Quoted 5 lines
arch/mips/kernel/mcount.S +1
-1- 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
Quoted 5 lines
-- Steve
Quoted 6 lines · David Daney
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
Quoted 1 line · Steven Rostedt
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
Quoted 11 lines · Steven Rostedt
Quoted 6 lines · David Daney
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
Quoted 7 lines
I can down load the 4.7 version and see if that makes a difference.
-- Steve
Quoted 36 lines · Steven Rostedt
Quoted 24 lines · David Daney
From: Corey Minyard <[email protected]>
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 <[email protected]>[[email protected]: Adjusted code comment and patch Subject.]Signed-off-by David Daney <[email protected]>--- arch/mips/kernel/mcount.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/mcount.S +0
-0arch/mips/kernel/mcount.S _mcount: · line 89
Quoted 8 lines
arch/mips/kernel/mcount.S +1
-1@@ -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.
Quoted 3 lines
-- 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