powerpc: Change calling convention for create_branch() et. al.
create_branch(), create_cond_branch() and translate_branch() return the instruction that they create, or return 0 to signal an error. Separate these concerns in preparation for an instruction type that is not just an unsigned int. Fill the created instruction to a pointer passed as the first parameter to the function and use a non-zero return value to signify an error. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Reviewed-by: Alistair Popple <alistair@popple.id.au> Link: https://lore.kernel.org/r/20200506034050.24806-6-jniethe5@gmail.com
This commit is contained in:

committed by
Michael Ellerman

parent
5a7fdcab54
commit
7c95d8893f
@@ -251,15 +251,17 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
|
||||
goto error;
|
||||
}
|
||||
|
||||
branch_op_callback = create_branch((unsigned int *)buff + TMPL_CALL_HDLR_IDX,
|
||||
(unsigned long)op_callback_addr,
|
||||
BRANCH_SET_LINK);
|
||||
rc = create_branch(&branch_op_callback,
|
||||
(unsigned int *)buff + TMPL_CALL_HDLR_IDX,
|
||||
(unsigned long)op_callback_addr,
|
||||
BRANCH_SET_LINK);
|
||||
|
||||
branch_emulate_step = create_branch((unsigned int *)buff + TMPL_EMULATE_IDX,
|
||||
(unsigned long)emulate_step_addr,
|
||||
BRANCH_SET_LINK);
|
||||
rc |= create_branch(&branch_emulate_step,
|
||||
(unsigned int *)buff + TMPL_EMULATE_IDX,
|
||||
(unsigned long)emulate_step_addr,
|
||||
BRANCH_SET_LINK);
|
||||
|
||||
if (!branch_op_callback || !branch_emulate_step)
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
patch_instruction(buff + TMPL_CALL_HDLR_IDX, branch_op_callback);
|
||||
@@ -305,6 +307,7 @@ int arch_check_optimized_kprobe(struct optimized_kprobe *op)
|
||||
|
||||
void arch_optimize_kprobes(struct list_head *oplist)
|
||||
{
|
||||
unsigned int instr;
|
||||
struct optimized_kprobe *op;
|
||||
struct optimized_kprobe *tmp;
|
||||
|
||||
@@ -315,9 +318,10 @@ void arch_optimize_kprobes(struct list_head *oplist)
|
||||
*/
|
||||
memcpy(op->optinsn.copied_insn, op->kp.addr,
|
||||
RELATIVEJUMP_SIZE);
|
||||
patch_instruction(op->kp.addr,
|
||||
create_branch((unsigned int *)op->kp.addr,
|
||||
(unsigned long)op->optinsn.insn, 0));
|
||||
create_branch(&instr,
|
||||
(unsigned int *)op->kp.addr,
|
||||
(unsigned long)op->optinsn.insn, 0);
|
||||
patch_instruction(op->kp.addr, instr);
|
||||
list_del_init(&op->list);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user