diff mbox series

[14/17] powerpc/ftrace: Replace use of ftrace_call_replace() with ftrace_create_branch_inst()

Message ID 953513b88fa922ba7a66d772dc1310710efe9177.1687166935.git.naveen@kernel.org (mailing list archive)
State Accepted
Commit a26ce4272eea2b20d4f39b9d7e56daf0c77151d8
Headers show
Series powerpc/ftrace: refactor and add support for -fpatchable-function-entry | expand

Commit Message

Naveen N Rao June 19, 2023, 9:47 a.m. UTC
ftrace_create_branch_inst() is clearer about its intent than
ftrace_call_replace().

Signed-off-by: Naveen N Rao <naveen@kernel.org>
---
 arch/powerpc/kernel/trace/ftrace.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

Comments

Christophe Leroy June 23, 2023, 5:32 a.m. UTC | #1
Le 19/06/2023 à 11:47, Naveen N Rao a écrit :
> ftrace_create_branch_inst() is clearer about its intent than
> ftrace_call_replace().
> 
> Signed-off-by: Naveen N Rao <naveen@kernel.org>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/trace/ftrace.c | 17 ++---------------
>   1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> index c37e22c6c26521..422dd760fbe013 100644
> --- a/arch/powerpc/kernel/trace/ftrace.c
> +++ b/arch/powerpc/kernel/trace/ftrace.c
> @@ -41,19 +41,6 @@ static ppc_inst_t ftrace_create_branch_inst(unsigned long ip, unsigned long addr
>   	return op;
>   }
>   
> -static ppc_inst_t
> -ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
> -{
> -	ppc_inst_t op;
> -
> -	addr = ppc_function_entry((void *)addr);
> -
> -	/* if (link) set op to 'bl' else 'b' */
> -	create_branch(&op, (u32 *)ip, addr, link ? BRANCH_SET_LINK : 0);
> -
> -	return op;
> -}
> -
>   static inline int ftrace_read_inst(unsigned long ip, ppc_inst_t *op)
>   {
>   	if (copy_inst_from_kernel_nofault(op, (void *)ip)) {
> @@ -275,14 +262,14 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>   	int ret;
>   
>   	old = ppc_inst_read((u32 *)&ftrace_call);
> -	new = ftrace_call_replace(ip, (unsigned long)func, 1);
> +	new = ftrace_create_branch_inst(ip, ppc_function_entry(func), 1);
>   	ret = ftrace_modify_code(ip, old, new);
>   
>   	/* Also update the regs callback function */
>   	if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) && !ret) {
>   		ip = (unsigned long)(&ftrace_regs_call);
>   		old = ppc_inst_read((u32 *)&ftrace_regs_call);
> -		new = ftrace_call_replace(ip, (unsigned long)func, 1);
> +		new = ftrace_create_branch_inst(ip, ppc_function_entry(func), 1);
>   		ret = ftrace_modify_code(ip, old, new);
>   	}
>
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index c37e22c6c26521..422dd760fbe013 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -41,19 +41,6 @@  static ppc_inst_t ftrace_create_branch_inst(unsigned long ip, unsigned long addr
 	return op;
 }
 
-static ppc_inst_t
-ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
-{
-	ppc_inst_t op;
-
-	addr = ppc_function_entry((void *)addr);
-
-	/* if (link) set op to 'bl' else 'b' */
-	create_branch(&op, (u32 *)ip, addr, link ? BRANCH_SET_LINK : 0);
-
-	return op;
-}
-
 static inline int ftrace_read_inst(unsigned long ip, ppc_inst_t *op)
 {
 	if (copy_inst_from_kernel_nofault(op, (void *)ip)) {
@@ -275,14 +262,14 @@  int ftrace_update_ftrace_func(ftrace_func_t func)
 	int ret;
 
 	old = ppc_inst_read((u32 *)&ftrace_call);
-	new = ftrace_call_replace(ip, (unsigned long)func, 1);
+	new = ftrace_create_branch_inst(ip, ppc_function_entry(func), 1);
 	ret = ftrace_modify_code(ip, old, new);
 
 	/* Also update the regs callback function */
 	if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) && !ret) {
 		ip = (unsigned long)(&ftrace_regs_call);
 		old = ppc_inst_read((u32 *)&ftrace_regs_call);
-		new = ftrace_call_replace(ip, (unsigned long)func, 1);
+		new = ftrace_create_branch_inst(ip, ppc_function_entry(func), 1);
 		ret = ftrace_modify_code(ip, old, new);
 	}