diff options
author | Quentin Barnes <qbarnes@gmail.com> | 2007-06-11 18:20:10 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-01-26 10:25:16 -0500 |
commit | 35aa1df4328340f38edc46f00837f08d33d49f63 (patch) | |
tree | 8ed273b1d39462282fadd4c854f17bf545024528 /include/asm-arm/kprobes.h | |
parent | 9b73e76f3cf63379dcf45fcd4f112f5812418d0a (diff) |
ARM kprobes: instruction single-stepping support
This is the code implementing instruction single-stepping for kprobes
on ARM.
To get around the limitation of no Next-PC and no hardware single-
stepping, all kprobe'd instructions are split into three camps:
simulation, emulation, and rejected. "Simulated" instructions are
those instructions which behavior is reproduced by straight C code.
"Emulated" instructions are ones that are copied, slightly altered
and executed directly in the instruction slot to reproduce their
behavior. "Rejected" instructions are ones that could be simulated,
but work hasn't been put into simulating them. These instructions
should be very rare, if not unencountered, in the kernel. If ever
needed, code could be added to simulate them.
One might wonder why this and the ptrace singlestep facility are not
sharing some code. Both approaches are fundamentally different because
the ptrace code regains control after the stepped instruction by installing
a breakpoint after the instruction itself, and possibly at the location
where the instruction might be branching to, instead of simulating or
emulating the target instruction.
The ptrace approach isn't suitable for kprobes because the breakpoints
would have to be moved back, and the icache flushed, everytime the
probe is hit to let normal code execution resume, which would have a
significant performance impact. It is also racy on SMP since another
CPU could, with the right timing, sail through the probe point without
being caught. Because ptrace single-stepping always result in a
different process to be scheduled, the concern for performance is much
less significant.
On the other hand, the kprobes approach isn't (currently) suitable for
ptrace because it has no provision for proper user space memory
protection and translation, and even if that was implemented, the gain
wouldn't be worth the added complexity in the ptrace path compared to
the current approach.
So, until kprobes does support user space, both kprobes and ptrace are
best kept independent and separate.
Signed-off-by: Quentin Barnes <qbarnes@gmail.com>
Signed-off-by: Abhishek Sagar <sagar.abhishek@gmail.com>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
Diffstat (limited to 'include/asm-arm/kprobes.h')
-rw-r--r-- | include/asm-arm/kprobes.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/asm-arm/kprobes.h b/include/asm-arm/kprobes.h new file mode 100644 index 000000000000..951322328793 --- /dev/null +++ b/include/asm-arm/kprobes.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * include/asm-arm/kprobes.h | ||
3 | * | ||
4 | * Copyright (C) 2006, 2007 Motorola Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #ifndef _ARM_KPROBES_H | ||
17 | #define _ARM_KPROBES_H | ||
18 | |||
19 | #include <linux/types.h> | ||
20 | #include <linux/ptrace.h> | ||
21 | |||
22 | typedef u32 kprobe_opcode_t; | ||
23 | |||
24 | struct kprobe; | ||
25 | typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *); | ||
26 | |||
27 | /* Architecture specific copy of original instruction. */ | ||
28 | struct arch_specific_insn { | ||
29 | kprobe_opcode_t *insn; | ||
30 | kprobe_insn_handler_t *insn_handler; | ||
31 | }; | ||
32 | |||
33 | enum kprobe_insn { | ||
34 | INSN_REJECTED, | ||
35 | INSN_GOOD, | ||
36 | INSN_GOOD_NO_SLOT | ||
37 | }; | ||
38 | |||
39 | enum kprobe_insn arm_kprobe_decode_insn(kprobe_opcode_t, | ||
40 | struct arch_specific_insn *); | ||
41 | void __init arm_kprobe_decode_init(void); | ||
42 | |||
43 | #endif /* _ARM_KPROBES_H */ | ||