aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/kernel/kprobes.c16
-rw-r--r--include/asm-i386/kprobes.h7
2 files changed, 19 insertions, 4 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 6483eeb1a4e8..694a13997637 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -58,6 +58,11 @@ static inline int is_IF_modifier(kprobe_opcode_t opcode)
58 58
59int __kprobes arch_prepare_kprobe(struct kprobe *p) 59int __kprobes arch_prepare_kprobe(struct kprobe *p)
60{ 60{
61 /* insn: must be on special executable page on i386. */
62 p->ainsn.insn = get_insn_slot();
63 if (!p->ainsn.insn)
64 return -ENOMEM;
65
61 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 66 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
62 p->opcode = *p->addr; 67 p->opcode = *p->addr;
63 return 0; 68 return 0;
@@ -77,6 +82,13 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
77 (unsigned long) p->addr + sizeof(kprobe_opcode_t)); 82 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
78} 83}
79 84
85void __kprobes arch_remove_kprobe(struct kprobe *p)
86{
87 down(&kprobe_mutex);
88 free_insn_slot(p->ainsn.insn);
89 up(&kprobe_mutex);
90}
91
80static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) 92static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
81{ 93{
82 kcb->prev_kprobe.kp = kprobe_running(); 94 kcb->prev_kprobe.kp = kprobe_running();
@@ -111,7 +123,7 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
111 if (p->opcode == BREAKPOINT_INSTRUCTION) 123 if (p->opcode == BREAKPOINT_INSTRUCTION)
112 regs->eip = (unsigned long)p->addr; 124 regs->eip = (unsigned long)p->addr;
113 else 125 else
114 regs->eip = (unsigned long)&p->ainsn.insn; 126 regs->eip = (unsigned long)p->ainsn.insn;
115} 127}
116 128
117/* Called with kretprobe_lock held */ 129/* Called with kretprobe_lock held */
@@ -351,7 +363,7 @@ static void __kprobes resume_execution(struct kprobe *p,
351{ 363{
352 unsigned long *tos = (unsigned long *)&regs->esp; 364 unsigned long *tos = (unsigned long *)&regs->esp;
353 unsigned long next_eip = 0; 365 unsigned long next_eip = 0;
354 unsigned long copy_eip = (unsigned long)&p->ainsn.insn; 366 unsigned long copy_eip = (unsigned long)p->ainsn.insn;
355 unsigned long orig_eip = (unsigned long)p->addr; 367 unsigned long orig_eip = (unsigned long)p->addr;
356 368
357 switch (p->ainsn.insn[0]) { 369 switch (p->ainsn.insn[0]) {
diff --git a/include/asm-i386/kprobes.h b/include/asm-i386/kprobes.h
index 27cac050a60e..a0d2d74a7dda 100644
--- a/include/asm-i386/kprobes.h
+++ b/include/asm-i386/kprobes.h
@@ -27,6 +27,9 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/ptrace.h> 28#include <linux/ptrace.h>
29 29
30#define __ARCH_WANT_KPROBES_INSN_SLOT
31
32struct kprobe;
30struct pt_regs; 33struct pt_regs;
31 34
32typedef u8 kprobe_opcode_t; 35typedef u8 kprobe_opcode_t;
@@ -40,14 +43,14 @@ typedef u8 kprobe_opcode_t;
40 43
41#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry 44#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
42#define ARCH_SUPPORTS_KRETPROBES 45#define ARCH_SUPPORTS_KRETPROBES
43#define arch_remove_kprobe(p) do {} while (0)
44 46
47void arch_remove_kprobe(struct kprobe *p);
45void kretprobe_trampoline(void); 48void kretprobe_trampoline(void);
46 49
47/* Architecture specific copy of original instruction*/ 50/* Architecture specific copy of original instruction*/
48struct arch_specific_insn { 51struct arch_specific_insn {
49 /* copy of the original instruction */ 52 /* copy of the original instruction */
50 kprobe_opcode_t insn[MAX_INSN_SIZE]; 53 kprobe_opcode_t *insn;
51}; 54};
52 55
53struct prev_kprobe { 56struct prev_kprobe {