public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Christoph Hellwig <hch@infradead.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Oleg Nesterov <oleg@redhat.com>, Mark Wielaard <mjw@redhat.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Naren A Devaiah <naren.devaiah@in.ibm.com>,
	Jim Keniston <jkenisto@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCHv8 2.6.35-rc4-tip 6/12]  uprobes: X86 support for Uprobes
Date: Thu, 08 Jul 2010 22:41:08 +0530	[thread overview]
Message-ID: <20100708171108.29165.37582.sendpatchset@localhost6.localdomain6> (raw)
In-Reply-To: <20100708171003.29165.57615.sendpatchset@localhost6.localdomain6>


uprobes: X86 support for Uprobes

Changelog from V5: Using local_irq_enable() instead of
    native_irq_enable and no more disabling irqs as suggested by Oleg
    Nesterov.

Provides x86 specific details for uprobes.
This includes interrupt notifier for uprobes, enabling/disabling
singlestep.

Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
---

 arch/x86/kernel/signal.c  |   13 +++++++++++
 arch/x86/kernel/uprobes.c |   52 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 0 deletions(-)


diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 4fd173c..3657563 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -848,6 +848,19 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
 	if (thread_info_flags & _TIF_SIGPENDING)
 		do_signal(regs);
 
+	if (thread_info_flags & _TIF_UPROBE) {
+		clear_thread_flag(TIF_UPROBE);
+#ifdef CONFIG_X86_32
+		/*
+		 * On x86_32, do_notify_resume() gets called with
+		 * interrupts disabled. Hence enable interrupts if they
+		 * are still disabled.
+		 */
+		local_irq_enable();
+#endif
+		uprobe_notify_resume(regs);
+	}
+
 	if (thread_info_flags & _TIF_NOTIFY_RESUME) {
 		clear_thread_flag(TIF_NOTIFY_RESUME);
 		tracehook_notify_resume(regs);
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 1eb85bb..9456328 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -26,6 +26,7 @@
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
 
+#include <linux/kdebug.h>
 #include <asm/insn.h>
 
 #ifdef CONFIG_X86_32
@@ -545,3 +546,54 @@ struct user_bkpt_arch_info user_bkpt_arch_info = {
 	.analyze_insn = analyze_insn,
 	.post_xol = post_xol,
 };
+
+/*
+ * Wrapper routine for handling exceptions.
+ */
+int uprobes_exception_notify(struct notifier_block *self,
+				       unsigned long val, void *data)
+{
+	struct die_args *args = data;
+	struct pt_regs *regs = args->regs;
+	int ret = NOTIFY_DONE;
+
+	/* We are only interested in userspace traps */
+	if (regs && !user_mode_vm(regs))
+		return NOTIFY_DONE;
+
+	switch (val) {
+	case DIE_INT3:
+		/* Run your handler here */
+		if (uprobe_bkpt_notifier(regs))
+			ret = NOTIFY_STOP;
+		break;
+	case DIE_DEBUG:
+		if (uprobe_post_notifier(regs))
+			ret = NOTIFY_STOP;
+	default:
+		break;
+	}
+	return ret;
+}
+
+void arch_uprobe_enable_sstep(struct pt_regs *regs)
+{
+	/*
+	 * Enable single-stepping by
+	 * - Set TF on stack
+	 * - Set TIF_SINGLESTEP: Guarantees that TF is set when
+	 *	returning to user mode.
+	 *  - Indicate that TF is set by us.
+	 */
+	regs->flags |= X86_EFLAGS_TF;
+	set_thread_flag(TIF_SINGLESTEP);
+	set_thread_flag(TIF_FORCED_TF);
+}
+
+void arch_uprobe_disable_sstep(struct pt_regs *regs)
+{
+	/* Disable single-stepping by clearing what we set */
+	clear_thread_flag(TIF_SINGLESTEP);
+	clear_thread_flag(TIF_FORCED_TF);
+	regs->flags &= ~X86_EFLAGS_TF;
+}

  parent reply	other threads:[~2010-07-08 17:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-08 17:10 [PATCHv8 2.6.35-rc4-tip 0/12] Uprobes Patches: Srikar Dronamraju
2010-07-08 17:10 ` [PATCHv8 2.6.35-rc4-tip 1/12] mm: Move replace_page() / write_protect_page() to mm/memory.c Srikar Dronamraju
2010-07-08 17:10 ` [PATCHv8 2.6.35-rc4-tip 2/12] uprobes: Breakpoint insertion/removal in user space applications Srikar Dronamraju
2010-07-08 17:10 ` [PATCHv8 2.6.35-rc4-tip 3/12] uprobes: Slot allocation for Execution out of line(XOL) Srikar Dronamraju
2010-07-08 17:10 ` [PATCHv8 2.6.35-rc4-tip 4/12] uprobes: x86 specific functions for user space breakpointing Srikar Dronamraju
2010-07-08 17:10 ` [PATCHv8 2.6.35-rc4-tip 5/12] uprobes: Uprobes (un)registration and exception handling Srikar Dronamraju
2010-07-08 17:11 ` Srikar Dronamraju [this message]
2010-07-08 17:11 ` [PATCHv8 2.6.35-rc4-tip 7/12] uprobes: Uprobes Documentation Srikar Dronamraju
2010-07-08 17:11 ` [PATCHv8 2.6.35-rc4-tip 8/12] trace: Extract out common code for kprobes/uprobes traceevents Srikar Dronamraju
2010-07-08 17:11 ` [PATCHv8 2.6.35-rc4-tip 9/12] trace: uprobes trace_event interface Srikar Dronamraju
2010-07-08 17:12 ` [PATCHv8 2.6.35-rc4-tip 10/12] perf: Re-Add make_absolute_path Srikar Dronamraju
2010-07-08 17:12 ` [PATCHv8 2.6.35-rc4-tip 11/12] perf: perf interface for uprobes Srikar Dronamraju
2010-07-08 20:19   ` Christoph Hellwig
2010-07-09  5:41     ` Srikar Dronamraju
2010-07-09  4:47   ` Srikar Dronamraju
2010-07-08 17:12 ` [PATCHv8 2.6.35-rc4-tip 12/12] perf: Show Potential probe points Srikar Dronamraju
2010-07-08 20:20   ` Christoph Hellwig
2010-07-09  5:56     ` Srikar Dronamraju
2010-07-09  7:17       ` Ingo Molnar
2010-07-09 14:13       ` Arnaldo Carvalho de Melo
2010-07-09  6:04   ` Srikar Dronamraju
2010-07-08 20:17 ` [PATCHv8 2.6.35-rc4-tip 0/12] Uprobes Patches: Christoph Hellwig
2010-07-09  4:42   ` Srikar Dronamraju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100708171108.29165.37582.sendpatchset@localhost6.localdomain6 \
    --to=srikar@linux.vnet.ibm.com \
    --cc=acme@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=jkenisto@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@elte.hu \
    --cc=mjw@redhat.com \
    --cc=naren.devaiah@in.ibm.com \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@xenotime.net \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox