Message ID | 1682561552-32324-6-git-send-email-tangyouling@loongson.cn (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | LoongArch: ftrace: Add direct call support and code simplification | expand |
On Thu, Apr 27 2023 at 10:12:32 AM +0800, Youling Tang wrote: > From: Qing Zhang <zhangqing@loongson.cn> > > 1. Adds new ftrace_regs_{get,set}_*() helpers which can be used to manipulate > ftrace_regs. When CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=y, these can always > be used on any ftrace_regs, and when CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=n > these can be used when regs are available. A new ftrace_regs_has_args(fregs) > helper is added which code can use to check when these are usable. > > 2. Prepare ftrace_regs_set_instruction_pointer support in advance. > > Signed-off-by: Qing Zhang <zhangqing@loongson.cn> > --- > arch/loongarch/include/asm/ftrace.h | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/arch/loongarch/include/asm/ftrace.h b/arch/loongarch/include/asm/ftrace.h > index f789e680f633..30ee01243416 100644 > --- a/arch/loongarch/include/asm/ftrace.h > +++ b/arch/loongarch/include/asm/ftrace.h > @@ -54,6 +54,31 @@ static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs * > return &fregs->regs; > } > > +static __always_inline void > +ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, > + unsigned long ip) > +{ > + regs_set_return_value(&fregs->regs, ip); > +} > + > +static __always_inline unsigned long > +ftrace_regs_get_instruction_pointer(struct ftrace_regs *fregs) > +{ > + return instruction_pointer(&fregs->regs); > +} > + > +#define ftrace_regs_get_argument(fregs, n) \ > + regs_get_kernel_argument(&(fregs)->regs, n) > +#define ftrace_regs_get_stack_pointer(fregs) \ > + kernel_stack_pointer(&(fregs)->regs) > +#define ftrace_regs_return_value(fregs) \ > + regs_return_value(&(fregs)->regs) > +#define ftrace_regs_set_return_value(fregs, ret) \ Hi Youling, > + regs_set_return_value(&(fregs)->regs, ret) ^^^^^^^^^^^^^^^^^^^^^^^^ I can not find the implementation of this function, am I missing something? > +#define ftrace_override_function_with_return(fregs) \ > + override_function_with_return(&(fregs)->regs) > +#define ftrace_regs_query_register_offset(name) \ ^^^^^^ There seems to be a missing function here. Otherwise, the backslash should be redundant. Did I understand correctly? Best Regards, Enze > + > #define ftrace_graph_func ftrace_graph_func > void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > struct ftrace_ops *op, struct ftrace_regs *fregs);
Hi, Enze On 04/27/2023 02:16 PM, Enze Li wrote: > On Thu, Apr 27 2023 at 10:12:32 AM +0800, Youling Tang wrote: > >> From: Qing Zhang <zhangqing@loongson.cn> >> >> 1. Adds new ftrace_regs_{get,set}_*() helpers which can be used to manipulate >> ftrace_regs. When CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=y, these can always >> be used on any ftrace_regs, and when CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=n >> these can be used when regs are available. A new ftrace_regs_has_args(fregs) >> helper is added which code can use to check when these are usable. >> >> 2. Prepare ftrace_regs_set_instruction_pointer support in advance. >> >> Signed-off-by: Qing Zhang <zhangqing@loongson.cn> >> --- >> arch/loongarch/include/asm/ftrace.h | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/arch/loongarch/include/asm/ftrace.h b/arch/loongarch/include/asm/ftrace.h >> index f789e680f633..30ee01243416 100644 >> --- a/arch/loongarch/include/asm/ftrace.h >> +++ b/arch/loongarch/include/asm/ftrace.h >> @@ -54,6 +54,31 @@ static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs * >> return &fregs->regs; >> } >> >> +static __always_inline void >> +ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, >> + unsigned long ip) >> +{ >> + regs_set_return_value(&fregs->regs, ip); >> +} >> + >> +static __always_inline unsigned long >> +ftrace_regs_get_instruction_pointer(struct ftrace_regs *fregs) >> +{ >> + return instruction_pointer(&fregs->regs); >> +} >> + >> +#define ftrace_regs_get_argument(fregs, n) \ >> + regs_get_kernel_argument(&(fregs)->regs, n) >> +#define ftrace_regs_get_stack_pointer(fregs) \ >> + kernel_stack_pointer(&(fregs)->regs) >> +#define ftrace_regs_return_value(fregs) \ >> + regs_return_value(&(fregs)->regs) >> +#define ftrace_regs_set_return_value(fregs, ret) \ > > Hi Youling, > >> + regs_set_return_value(&(fregs)->regs, ret) > ^^^^^^^^^^^^^^^^^^^^^^^^ > I can not find the implementation of this function, am I missing > something? Note: This patch depends on regs_set_return_value() in the patch "LoongArch: Add support for function error injection". https://github.com/chenhuacai/linux/commit/c78e80c75b98feeb02b9a6eefb9de759f9036f42 > >> +#define ftrace_override_function_with_return(fregs) \ >> + override_function_with_return(&(fregs)->regs) >> +#define ftrace_regs_query_register_offset(name) \ > ^^^^^^ > There seems to be a missing function here. Otherwise, the backslash > should be redundant. Did I understand correctly? Sorry for my oversight. ftrace_regs_query_register_offset() will reuse regs_query_register_offset(), I will modify it as follows, #define ftrace_regs_query_register_offset(name) \ regs_query_register_offset(name) Thanks, Youling. > > Best Regards, > Enze > >> + >> #define ftrace_graph_func ftrace_graph_func >> void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, >> struct ftrace_ops *op, struct ftrace_regs *fregs);
diff --git a/arch/loongarch/include/asm/ftrace.h b/arch/loongarch/include/asm/ftrace.h index f789e680f633..30ee01243416 100644 --- a/arch/loongarch/include/asm/ftrace.h +++ b/arch/loongarch/include/asm/ftrace.h @@ -54,6 +54,31 @@ static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs * return &fregs->regs; } +static __always_inline void +ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, + unsigned long ip) +{ + regs_set_return_value(&fregs->regs, ip); +} + +static __always_inline unsigned long +ftrace_regs_get_instruction_pointer(struct ftrace_regs *fregs) +{ + return instruction_pointer(&fregs->regs); +} + +#define ftrace_regs_get_argument(fregs, n) \ + regs_get_kernel_argument(&(fregs)->regs, n) +#define ftrace_regs_get_stack_pointer(fregs) \ + kernel_stack_pointer(&(fregs)->regs) +#define ftrace_regs_return_value(fregs) \ + regs_return_value(&(fregs)->regs) +#define ftrace_regs_set_return_value(fregs, ret) \ + regs_set_return_value(&(fregs)->regs, ret) +#define ftrace_override_function_with_return(fregs) \ + override_function_with_return(&(fregs)->regs) +#define ftrace_regs_query_register_offset(name) \ + #define ftrace_graph_func ftrace_graph_func void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs);