Thread (38 messages) 38 messages, 6 authors, 2017-04-25

Re: [PATCH v3 6/7] powerpc: kprobes: emulate instructions on kprobe handler re-entry

From: Naveen N. Rao <hidden>
Date: 2017-04-19 16:44:00
Also in: lkml

Excerpts from Masami Hiramatsu's message of April 19, 2017 20:13:
=20
BTW, as I pointed, 5/7 and 6/7 should be merged since this actually
makes meaningful change.
Yes, sorry if I wasn't clear in my previous reply in the (!) previous=20
patch series.

Since this has to go through the powerpc tree, I followed this since I=20
felt that Michael Ellerman prefers to keep functional changes separate=20
from refactoring. I'm fine with either approach.

Michael?

Thanks!
- Naveen
=20
Thank you,
=20
On Wed, 19 Apr 2017 18:21:05 +0530
"Naveen N. Rao" [off-list ref] wrote:
=20
quoted
On kprobe handler re-entry, try to emulate the instruction rather than
single stepping always.
=20
Acked-by: Ananth N Mavinakayanahalli <redacted>
Signed-off-by: Naveen N. Rao <redacted>
---
 arch/powerpc/kernel/kprobes.c | 8 ++++++++
 1 file changed, 8 insertions(+)
=20
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes=
.c
quoted
index 46e8c1e03ce4..067e9863bfdf 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -276,6 +276,14 @@ int __kprobes kprobe_handler(struct pt_regs *regs)
 			kprobes_inc_nmissed_count(p);
 			prepare_singlestep(p, regs);
 			kcb->kprobe_status =3D KPROBE_REENTER;
+			if (p->ainsn.boostable >=3D 0) {
+				ret =3D try_to_emulate(p, regs);
+
+				if (ret > 0) {
+					restore_previous_kprobe(kcb);
+					return 1;
+				}
+			}
 			return 1;
 		} else {
 			if (*addr !=3D BREAKPOINT_INSTRUCTION) {
--=20
2.12.1
=20
=20
=20
--=20
Masami Hiramatsu [off-list ref]
=20
=20
=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help