]> git.karo-electronics.de Git - karo-tx-linux.git/commit
uprobes: handle breakpoint and signal step exception.
authorSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Wed, 7 Dec 2011 10:15:48 +0000 (15:45 +0530)
committerSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Sun, 18 Dec 2011 06:22:57 +0000 (11:52 +0530)
commit599b83b592b33388c2d462c9af826a59eb343129
treeb14cff41d9906b4223421e860fd8a14e803c3da3
parent70b8389289038e2963eba6581be428cff40c988c
uprobes: handle breakpoint and signal step exception.

Uprobes uses exception notifiers to get to know if a thread hit a
breakpoint or singlestep exception.

When a thread hits a uprobe or is singlestepping post a uprobe hit,
the uprobe exception notifier, sets its TIF_UPROBE bit, which will
then be checked on its return to userspace path (do_notify_resume()
->uprobe_notify_resume()), where the consumers handlers are run
(in task context) based on the defined filters.

Uprobe hits are thread specific and hence we need to maintain
information about if a task hit a uprobe, what uprobe was hit, the slot
where the original instruction was copied for xol so that it can be
singlestepped with appropriate fixups.

In some cases, special care is needed for instructions that are
executed out of line (xol). These are architecture specific artefacts,
such as handling RIP relative instructions on x86_64.

Since the instruction at which the uprobe was inserted is executed out
of line, architecture specific fixups are added so that the thread
continues normal execution in the presence of a uprobe.

Postpone the signals until we execute the probed insn. post_xol()
path does a recalc_sigpending() before return to user-mode, this
ensures the signal can't be lost.

Uprobes relies on DIE_DEBUG notification to notify if a singlestep is
complete.

Checks and skip singlestepping underlying instructions where possible.

Adds x86 specific uprobe exception notifiers and appropriate hooks
needed to determine a uprobe hit and subsequent post processing.

Add requisite x86 fixups for xol for uprobes. Specific cases needing
fixups include relative jumps (x86_64), calls, etc.

Allows to skip singlestepping of specific instructions that need to
be singlestepped or can be emulated. For now handles single byte as
well as few multibyte nop instructions.  However can be extended to
other instructions too.

Credits to Oleg for suggestions/patches related to signal, breakpoint,
singlestep handling code.

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
arch/x86/include/asm/thread_info.h
arch/x86/include/asm/uprobes.h
arch/x86/kernel/signal.c
arch/x86/kernel/uprobes.c
include/linux/sched.h
include/linux/uprobes.h
kernel/fork.c
kernel/signal.c
kernel/uprobes.c