Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1582462

[PATCH 5/5] powerpc: kprobes: emulate instructions on kprobe handler re-entry

From "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH 5/5] powerpc: kprobes: emulate instructions on kprobe handler re-entry
Date 2017-02-16 12:00 +0100
Message-ID <tbrX4-54i-9@gated-at.bofh.it> (permalink)
References <tbrX4-54i-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On kprobe handler re-entry, try to emulate the instruction rather than
single stepping always.

As a related change, remove the duplicate saving of msr as that is
already done in set_current_kprobe()

Acked-by: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/kprobes.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 8b48f7d046bd..005bd4a75902 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -273,10 +273,17 @@ int __kprobes kprobe_handler(struct pt_regs *regs)
 			 */
 			save_previous_kprobe(kcb);
 			set_current_kprobe(p, regs, kcb);
-			kcb->kprobe_saved_msr = regs->msr;
 			kprobes_inc_nmissed_count(p);
 			prepare_singlestep(p, regs);
 			kcb->kprobe_status = KPROBE_REENTER;
+			if (p->ainsn.boostable >= 0) {
+				ret = try_to_emulate(p, regs);
+
+				if (ret > 0) {
+					restore_previous_kprobe(kcb);
+					return 1;
+				}
+			}
 			return 1;
 		} else {
 			if (*addr != BREAKPOINT_INSTRUCTION) {
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/5] powerpc: introduce a new helper to obtain function entry points "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 12:00 +0100
  [PATCH 5/5] powerpc: kprobes: emulate instructions on kprobe handler re-entry "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 12:00 +0100
  [PATCH 4/5] powerpc: kprobes: factor out code to emulate instruction into a helper "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 12:00 +0100
  [PATCH 2/5] kprobes: convert kprobe_lookup_name() to a function "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 12:00 +0100
  [PATCH 3/5] powerpc: kprobes: fix handling of function offsets on ABIv2 "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 12:00 +0100

csiph-web