aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/kprobes.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel/kprobes.c')
-rw-r--r--arch/i386/kernel/kprobes.c16
1 files changed, 14 insertions, 2 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]) {