diff options
author | Roland McGrath <roland@redhat.com> | 2008-07-25 22:45:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 15:00:09 -0400 |
commit | 64b1208d5b0ef8859fd52ea7ae286a3eb994669b (patch) | |
tree | ebb92b717406dc104924c4ccdedf14357a62b84f /include/linux/tracehook.h | |
parent | b787f7ba677840da16a2228c16571ce8a1fcb799 (diff) |
tracehook: TIF_NOTIFY_RESUME
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>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Reviewed-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/tracehook.h')
-rw-r--r-- | 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 43bc51b6bd33..32867ab86c70 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, | |||
537 | { | 537 | { |
538 | } | 538 | } |
539 | 539 | ||
540 | #ifdef TIF_NOTIFY_RESUME | ||
541 | /** | ||
542 | * set_notify_resume - cause tracehook_notify_resume() to be called | ||
543 | * @task: task that will call tracehook_notify_resume() | ||
544 | * | ||
545 | * Calling this arranges that @task will call tracehook_notify_resume() | ||
546 | * before returning to user mode. If it's already running in user mode, | ||
547 | * it will enter the kernel and call tracehook_notify_resume() soon. | ||
548 | * If it's blocked, it will not be woken. | ||
549 | */ | ||
550 | static inline void set_notify_resume(struct task_struct *task) | ||
551 | { | ||
552 | if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME)) | ||
553 | kick_process(task); | ||
554 | } | ||
555 | |||
556 | /** | ||
557 | * tracehook_notify_resume - report when about to return to user mode | ||
558 | * @regs: user-mode registers of @current task | ||
559 | * | ||
560 | * This is called when %TIF_NOTIFY_RESUME has been set. Now we are | ||
561 | * about to return to user mode, and the user state in @regs can be | ||
562 | * inspected or adjusted. The caller in arch code has cleared | ||
563 | * %TIF_NOTIFY_RESUME before the call. If the flag gets set again | ||
564 | * asynchronously, this will be called again before we return to | ||
565 | * user mode. | ||
566 | * | ||
567 | * Called without locks. | ||
568 | */ | ||
569 | static inline void tracehook_notify_resume(struct pt_regs *regs) | ||
570 | { | ||
571 | } | ||
572 | #endif /* TIF_NOTIFY_RESUME */ | ||
573 | |||
540 | #endif /* <linux/tracehook.h> */ | 574 | #endif /* <linux/tracehook.h> */ |