Commit 762df10b authored by Anju T's avatar Anju T Committed by Michael Ellerman

powerpc/kprobes: Optimize kprobe in kretprobe_trampoline()

Kprobe placed on the  kretprobe_trampoline() during boot time can be
optimized, since the instruction at probe point is a 'nop'.
Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 51c9c084
...@@ -285,6 +285,7 @@ asm(".global kretprobe_trampoline\n" ...@@ -285,6 +285,7 @@ asm(".global kretprobe_trampoline\n"
".type kretprobe_trampoline, @function\n" ".type kretprobe_trampoline, @function\n"
"kretprobe_trampoline:\n" "kretprobe_trampoline:\n"
"nop\n" "nop\n"
"blr\n"
".size kretprobe_trampoline, .-kretprobe_trampoline\n"); ".size kretprobe_trampoline, .-kretprobe_trampoline\n");
/* /*
...@@ -337,6 +338,13 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p, ...@@ -337,6 +338,13 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
kretprobe_assert(ri, orig_ret_address, trampoline_address); kretprobe_assert(ri, orig_ret_address, trampoline_address);
regs->nip = orig_ret_address; regs->nip = orig_ret_address;
/*
* Make LR point to the orig_ret_address.
* When the 'nop' inside the kretprobe_trampoline
* is optimized, we can do a 'blr' after executing the
* detour buffer code.
*/
regs->link = orig_ret_address;
reset_current_kprobe(); reset_current_kprobe();
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
......
...@@ -72,12 +72,11 @@ static unsigned long can_optimize(struct kprobe *p) ...@@ -72,12 +72,11 @@ static unsigned long can_optimize(struct kprobe *p)
/* /*
* kprobe placed for kretprobe during boot time * kprobe placed for kretprobe during boot time
* is not optimizing now. * has a 'nop' instruction, which can be emulated.
* * So further checks can be skipped.
* TODO: Optimize kprobe in kretprobe_trampoline
*/ */
if (p->addr == (kprobe_opcode_t *)&kretprobe_trampoline) if (p->addr == (kprobe_opcode_t *)&kretprobe_trampoline)
return 0; return (unsigned long)p->addr + sizeof(kprobe_opcode_t);
/* /*
* We only support optimizing kernel addresses, but not * We only support optimizing kernel addresses, but not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment