linux/arch
Srikar Dronamraju 0326f5a94d uprobes/core: Handle breakpoint and singlestep exceptions
Uprobes uses exception notifiers to get to know if a thread hit
a breakpoint or a 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.

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.

Where possible, we check and skip singlestepping the
breakpointed instructions. For now we skip single byte as well
as few multibyte nop instructions. However this can be extended
to other instructions too.

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

Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com>
Cc: Linux-mm <linux-mm@kvack.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120313180011.29771.89027.sendpatchset@srdronam.in.ibm.com
[ Performed various cleanliness edits ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-14 07:41:36 +01:00
..
alpha alpha: Use generic posix_types.h 2012-02-14 12:01:27 -08:00
arm Merge branch 'x86/cleanups' into perf/uprobes 2012-03-13 16:33:03 +01:00
avr32 avr32: Use generic posix_types.h 2012-02-14 12:01:28 -08:00
blackfin Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci 2012-01-11 18:50:26 -08:00
c6x Kbuild: Use dtc's -d (dependency) option 2012-02-14 21:14:44 -05:00
cris cris: Use generic posix_types.h 2012-02-14 12:01:28 -08:00
frv Merge branch 'x86/cleanups' into perf/uprobes 2012-03-13 16:33:03 +01:00
h8300 h8300: Use generic posix_types.h 2012-02-14 12:01:28 -08:00
hexagon Merge branch 'perf/fast' into perf/core 2012-01-27 12:08:09 +01:00
ia64 ia64: Use generic posix_types.h 2012-02-14 12:01:28 -08:00
m32r m32r: Use generic posix_types.h 2012-02-14 12:01:28 -08:00
m68k Merge branch 'x86/x32' into x86/cleanups 2012-03-13 05:54:41 +01:00
microblaze Revert "microblaze: Add topology init" 2012-01-31 09:06:52 +01:00
mips fs: Remove missed ->fds_bits from cessation use of fd_set structs internally 2012-02-24 14:04:50 +01:00
mn10300 mn10300: Use generic posix_types.h 2012-02-14 12:01:29 -08:00
openrisc openrisc: Fix up audit_syscall_[entry|exit]() usage 2012-02-17 09:53:12 +01:00
parisc Merge branch 'x86/x32' into x86/cleanups 2012-03-13 05:54:41 +01:00
powerpc Merge branch 'x86/cleanups' into perf/uprobes 2012-03-13 16:33:03 +01:00
s390 Merge branch 'x86/cleanups' into perf/uprobes 2012-03-13 16:33:03 +01:00
score score: fix off-by-one index into syscall table 2012-01-23 08:38:49 -08:00
sh Merge branch 'x86/x32' into x86/cleanups 2012-03-13 05:54:41 +01:00
sparc sparc: Use generic posix_types.h 2012-02-14 12:01:30 -08:00
tile Merge branch 'for-next' of git://git.infradead.org/users/dhowells/linux-headers 2012-01-14 18:03:30 -08:00
um Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit 2012-01-17 16:41:31 -08:00
unicore32 Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci 2012-01-11 18:50:26 -08:00
x86 uprobes/core: Handle breakpoint and singlestep exceptions 2012-03-14 07:41:36 +01:00
xtensa xtensa: Use generic posix_types.h 2012-02-14 12:01:30 -08:00
.gitignore
Kconfig uprobes: Move to kernel/events/ 2012-02-22 11:08:00 +01:00