-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nds32/ftrace: Support static function tracer
This patch support the static function tracer. On nds32 ABI, we need to always push return address to stack for __builtin_return_address can work correctly, otherwise, it will get the wrong value of $lp at leaf function. Signed-off-by: Zong Li <zong@andestech.com> Acked-by: Greentime Hu <greentime@andestech.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
- Loading branch information
Zong Li
authored and
Greentime Hu
committed
Sep 4, 2018
1 parent
487913a
commit a180825
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#ifndef __ASM_NDS32_FTRACE_H | ||
#define __ASM_NDS32_FTRACE_H | ||
|
||
#ifdef CONFIG_FUNCTION_TRACER | ||
|
||
#define HAVE_FUNCTION_GRAPH_FP_TEST | ||
|
||
#define MCOUNT_ADDR ((unsigned long)(_mcount)) | ||
/* mcount call is composed of three instructions: | ||
* sethi + ori + jral | ||
*/ | ||
#define MCOUNT_INSN_SIZE 12 | ||
|
||
extern void _mcount(unsigned long parent_ip); | ||
|
||
#endif /* CONFIG_FUNCTION_TRACER */ | ||
|
||
#endif /* __ASM_NDS32_FTRACE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/ftrace.h> | ||
#include <linux/uaccess.h> | ||
#include <asm/cacheflush.h> | ||
|
||
extern void (*ftrace_trace_function)(unsigned long, unsigned long, | ||
struct ftrace_ops*, struct pt_regs*); | ||
|
||
noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip, | ||
struct ftrace_ops *op, struct pt_regs *regs) | ||
{ | ||
__asm__ (""); /* avoid to optimize as pure function */ | ||
} | ||
|
||
noinline void _mcount(unsigned long parent_ip) | ||
{ | ||
/* save all state by the compiler prologue */ | ||
|
||
unsigned long ip = (unsigned long)__builtin_return_address(0); | ||
|
||
if (ftrace_trace_function != ftrace_stub) | ||
ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip, | ||
NULL, NULL); | ||
|
||
/* restore all state by the compiler epilogue */ | ||
} | ||
EXPORT_SYMBOL(_mcount); |