]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/ftrace: Remove redundant create_branch() calls
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 9 May 2022 05:36:00 +0000 (07:36 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 19 May 2022 13:11:28 +0000 (23:11 +1000)
Since commit 55afba3325e1 ("powerpc/code-patching: Fix patch_branch()
return on out-of-range failure") patch_branch() fails with -ERANGE
when trying to branch out of range.

No need to perform the test twice. Remove redundant create_branch()
calls.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/aa45fbad0b4b7493080835d8276c0cb4ce146503.1652074503.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/trace/ftrace.c

index 7a266fd469b7ed86647cb86c126dec34223a4da9..3ce3697e8a7cc3d8d41d67c46be38146c4cd7da9 100644 (file)
@@ -301,7 +301,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
        int i;
        ppc_inst_t op;
        unsigned long ptr;
-       ppc_inst_t instr;
        static unsigned long ftrace_plt_tramps[NUM_FTRACE_TRAMPS];
 
        /* Is this a known long jump tramp? */
@@ -344,12 +343,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
 #else
        ptr = ppc_global_function_entry((void *)ftrace_caller);
 #endif
-       if (create_branch(&instr, (void *)tramp, ptr, 0)) {
-               pr_debug("%ps is not reachable from existing mcount tramp\n",
-                               (void *)ptr);
-               return -1;
-       }
-
        if (patch_branch((u32 *)tramp, ptr, 0)) {
                pr_debug("REL24 out of range!\n");
                return -1;
@@ -490,7 +483,6 @@ static int
 __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 {
        ppc_inst_t op[2];
-       ppc_inst_t instr;
        void *ip = (void *)rec->ip;
        unsigned long entry, ptr, tramp;
        struct module *mod = rec->arch.mod;
@@ -539,12 +531,6 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
                return -EINVAL;
        }
 
-       /* Ensure branch is within 24 bits */
-       if (create_branch(&instr, ip, tramp, BRANCH_SET_LINK)) {
-               pr_err("Branch out of range\n");
-               return -EINVAL;
-       }
-
        if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
                pr_err("REL24 out of range!\n");
                return -EINVAL;
@@ -770,12 +756,6 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
                return -EINVAL;
        }
 
-       /* Ensure branch is within 24 bits */
-       if (create_branch(&op, (u32 *)ip, tramp, BRANCH_SET_LINK)) {
-               pr_err("Branch out of range\n");
-               return -EINVAL;
-       }
-
        if (patch_branch((u32 *)ip, tramp, BRANCH_SET_LINK)) {
                pr_err("REL24 out of range!\n");
                return -EINVAL;