提交 ae3a2a21 编写于 作者: C Christophe Leroy 提交者: Michael Ellerman

powerpc/ftrace: Remove redundant create_branch() calls

Since commit d5937db1 ("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: NChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/aa45fbad0b4b7493080835d8276c0cb4ce146503.1652074503.git.christophe.leroy@csgroup.eu
上级 d996d505
...@@ -301,7 +301,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) ...@@ -301,7 +301,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
int i; int i;
ppc_inst_t op; ppc_inst_t op;
unsigned long ptr; unsigned long ptr;
ppc_inst_t instr;
static unsigned long ftrace_plt_tramps[NUM_FTRACE_TRAMPS]; static unsigned long ftrace_plt_tramps[NUM_FTRACE_TRAMPS];
/* Is this a known long jump tramp? */ /* Is this a known long jump tramp? */
...@@ -344,12 +343,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) ...@@ -344,12 +343,6 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
#else #else
ptr = ppc_global_function_entry((void *)ftrace_caller); ptr = ppc_global_function_entry((void *)ftrace_caller);
#endif #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)) { if (patch_branch((u32 *)tramp, ptr, 0)) {
pr_debug("REL24 out of range!\n"); pr_debug("REL24 out of range!\n");
return -1; return -1;
...@@ -490,7 +483,6 @@ static int ...@@ -490,7 +483,6 @@ static int
__ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
{ {
ppc_inst_t op[2]; ppc_inst_t op[2];
ppc_inst_t instr;
void *ip = (void *)rec->ip; void *ip = (void *)rec->ip;
unsigned long entry, ptr, tramp; unsigned long entry, ptr, tramp;
struct module *mod = rec->arch.mod; struct module *mod = rec->arch.mod;
...@@ -539,12 +531,6 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) ...@@ -539,12 +531,6 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return -EINVAL; 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)) { if (patch_branch(ip, tramp, BRANCH_SET_LINK)) {
pr_err("REL24 out of range!\n"); pr_err("REL24 out of range!\n");
return -EINVAL; return -EINVAL;
...@@ -770,12 +756,6 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, ...@@ -770,12 +756,6 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
return -EINVAL; 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)) { if (patch_branch((u32 *)ip, tramp, BRANCH_SET_LINK)) {
pr_err("REL24 out of range!\n"); pr_err("REL24 out of range!\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册