[PATCH 18/23] tracehook: TIF_NOTIFY_RESUME

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roland McGrath
Date: Thursday, July 17, 2008 - 12:31 am

This adds tracehook.h inlines to enable a new arch feature in support
of user debugging/tracing.  This is not used yet, but it lays the
groundwork for a debugger to be able to wrangle a task that's possibly
running, without interrupting its syscalls in progress.

Each arch should define TIF_NOTIFY_RESUME, and in their entry.S code
treat it much like TIF_SIGPENDING.  That is, it causes you to take the
slow path when returning to user mode, where you get the full user-mode
state accessible as for signal handling or ptrace.  The arch code
should check TIF_NOTIFY_RESUME after handling TIF_SIGPENDING.
When it's set, clear it and then call tracehook_notify_resume().

In future, tracing code will call set_notify_resume() when it
wants to get a callback in tracehook_notify_resume().

Signed-off-by: Roland McGrath <roland@redhat.com>
---
 include/linux/tracehook.h |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 43bc51b..32867ab 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -537,4 +537,38 @@ static inline void tracehook_report_death(struct task_struct *task,
 {
 }
 
+#ifdef TIF_NOTIFY_RESUME
+/**
+ * set_notify_resume - cause tracehook_notify_resume() to be called
+ * @task:		task that will call tracehook_notify_resume()
+ *
+ * Calling this arranges that @task will call tracehook_notify_resume()
+ * before returning to user mode.  If it's already running in user mode,
+ * it will enter the kernel and call tracehook_notify_resume() soon.
+ * If it's blocked, it will not be woken.
+ */
+static inline void set_notify_resume(struct task_struct *task)
+{
+	if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
+		kick_process(task);
+}
+
+/**
+ * tracehook_notify_resume - report when about to return to user mode
+ * @regs:		user-mode registers of @current task
+ *
+ * This is called when %TIF_NOTIFY_RESUME has been set.  Now we are
+ * about to return to user mode, and the user state in @regs can be
+ * inspected or adjusted.  The caller in arch code has cleared
+ * %TIF_NOTIFY_RESUME before the call.  If the flag gets set again
+ * asynchronously, this will be called again before we return to
+ * user mode.
+ *
+ * Called without locks.
+ */
+static inline void tracehook_notify_resume(struct pt_regs *regs)
+{
+}
+#endif	/* TIF_NOTIFY_RESUME */
+
 #endif	/* <linux/tracehook.h> */
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/23] tracehook, Roland McGrath, (Thu Jul 17, 12:25 am)
[PATCH 01/23] tracehook: add linux/tracehook.h, Roland McGrath, (Thu Jul 17, 12:27 am)
[PATCH 02/23] tracehook: exec, Roland McGrath, (Thu Jul 17, 12:28 am)
[PATCH 03/23] tracehook: unexport ptrace_notify, Roland McGrath, (Thu Jul 17, 12:28 am)
[PATCH 04/23] tracehook: exit, Roland McGrath, (Thu Jul 17, 12:28 am)
[PATCH 05/23] tracehook: clone, Roland McGrath, (Thu Jul 17, 12:29 am)
[PATCH 06/23] tracehook: vfork-done, Roland McGrath, (Thu Jul 17, 12:29 am)
[PATCH 07/23] tracehook: release_task, Roland McGrath, (Thu Jul 17, 12:29 am)
[PATCH 08/23] tracehook: tracehook_tracer_task, Roland McGrath, (Thu Jul 17, 12:29 am)
[PATCH 09/23] tracehook: tracehook_expect_breakpoints, Roland McGrath, (Thu Jul 17, 12:29 am)
[PATCH 10/23] tracehook: tracehook_signal_handler, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 11/23] tracehook: tracehook_consider_ignored_signal, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 12/23] tracehook: tracehook_consider_fatal_signal, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 13/23] tracehook: syscall, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 14/23] tracehook: get_signal_to_deliver, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 15/23] tracehook: job control, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 16/23] tracehook: death, Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 17/23] tracehook: force signal_pending(), Roland McGrath, (Thu Jul 17, 12:30 am)
[PATCH 18/23] tracehook: TIF_NOTIFY_RESUME, Roland McGrath, (Thu Jul 17, 12:31 am)
[PATCH 19/23] tracehook: asm/syscall.h, Roland McGrath, (Thu Jul 17, 12:31 am)
[PATCH 20/23] tracehook: CONFIG_HAVE_ARCH_TRACEHOOK, Roland McGrath, (Thu Jul 17, 12:31 am)
[PATCH 21/23] tracehook: wait_task_inactive, Roland McGrath, (Thu Jul 17, 12:31 am)
[PATCH 22/23] task_current_syscall, Roland McGrath, (Thu Jul 17, 12:31 am)
[PATCH 23/23] /proc/PID/syscall, Roland McGrath, (Thu Jul 17, 12:31 am)
Re: [PATCH 00/23] tracehook, Andrew Morton, (Thu Jul 17, 12:39 am)
Re: [PATCH 00/23] tracehook, Roland McGrath, (Thu Jul 17, 1:11 am)
Re: [PATCH 00/23] tracehook, Andrew Morton, (Thu Jul 17, 1:30 am)
Re: [PATCH 00/23] tracehook, Roland McGrath, (Thu Jul 17, 1:37 am)
Re: [PATCH 01/23] tracehook: add linux/tracehook.h, Alexey Dobriyan, (Thu Jul 17, 1:48 am)
Re: [PATCH 00/23] tracehook, Andrew Morton, (Thu Jul 17, 1:51 am)
Re: [PATCH 01/23] tracehook: add linux/tracehook.h, Petr Tesarik, (Thu Jul 17, 4:06 am)
Re: [PATCH 01/23] tracehook: add linux/tracehook.h, Christoph Hellwig, (Thu Jul 17, 6:34 am)
Re: [PATCH 01/23] tracehook: add linux/tracehook.h, Alexey Dobriyan, (Thu Jul 17, 2:50 pm)
Re: [PATCH 23/23] /proc/PID/syscall, Alexey Dobriyan, (Thu Jul 17, 3:56 pm)
Re: [PATCH 00/23] tracehook, Ingo Molnar, (Fri Jul 18, 1:07 am)
Re: [PATCH 00/23] tracehook, David Miller, (Fri Jul 18, 2:20 am)
Re: [PATCH 00/23] tracehook, Andi Kleen, (Fri Jul 18, 4:24 am)
Re: [PATCH 00/23] tracehook, David Miller, (Fri Jul 18, 4:32 am)
Re: [PATCH 01/23] tracehook: add linux/tracehook.h, Petr Tesarik, (Fri Jul 18, 4:57 am)
Re: [PATCH 23/23] /proc/PID/syscall, Roland McGrath, (Mon Jul 21, 1:19 am)
Re: [PATCH 02/23] tracehook: exec, Christoph Hellwig, (Mon Jul 21, 1:49 am)
Re: [PATCH 00/23] tracehook, Roland McGrath, (Mon Jul 21, 2:59 am)
Re: [PATCH 00/23] tracehook, Roland McGrath, (Mon Jul 21, 3:54 am)
Re: [PATCH 00/23] tracehook, David Miller, (Mon Jul 21, 8:18 am)