aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/kprobes.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ppc64/kernel/kprobes.c')
-rw-r--r--arch/ppc64/kernel/kprobes.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/arch/ppc64/kernel/kprobes.c b/arch/ppc64/kernel/kprobes.c
index 103daaf73573..e950a2058a19 100644
--- a/arch/ppc64/kernel/kprobes.c
+++ b/arch/ppc64/kernel/kprobes.c
@@ -45,12 +45,17 @@ static struct pt_regs jprobe_saved_regs;
45 45
46int arch_prepare_kprobe(struct kprobe *p) 46int arch_prepare_kprobe(struct kprobe *p)
47{ 47{
48 int ret = 0;
48 kprobe_opcode_t insn = *p->addr; 49 kprobe_opcode_t insn = *p->addr;
49 50
50 if (IS_MTMSRD(insn) || IS_RFID(insn)) 51 if ((unsigned long)p->addr & 0x03) {
51 /* cannot put bp on RFID/MTMSRD */ 52 printk("Attempt to register kprobe at an unaligned address\n");
52 return 1; 53 ret = -EINVAL;
53 return 0; 54 } else if (IS_MTMSRD(insn) || IS_RFID(insn)) {
55 printk("Cannot register a kprobe on rfid or mtmsrd\n");
56 ret = -EINVAL;
57 }
58 return ret;
54} 59}
55 60
56void arch_copy_kprobe(struct kprobe *p) 61void arch_copy_kprobe(struct kprobe *p)
@@ -172,8 +177,6 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs)
172 ret = emulate_step(regs, p->ainsn.insn[0]); 177 ret = emulate_step(regs, p->ainsn.insn[0]);
173 if (ret == 0) 178 if (ret == 0)
174 regs->nip = (unsigned long)p->addr + 4; 179 regs->nip = (unsigned long)p->addr + 4;
175
176 regs->msr &= ~MSR_SE;
177} 180}
178 181
179static inline int post_kprobe_handler(struct pt_regs *regs) 182static inline int post_kprobe_handler(struct pt_regs *regs)
@@ -210,6 +213,7 @@ static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
210 213
211 if (kprobe_status & KPROBE_HIT_SS) { 214 if (kprobe_status & KPROBE_HIT_SS) {
212 resume_execution(current_kprobe, regs); 215 resume_execution(current_kprobe, regs);
216 regs->msr &= ~MSR_SE;
213 regs->msr |= kprobe_saved_msr; 217 regs->msr |= kprobe_saved_msr;
214 218
215 unlock_kprobes(); 219 unlock_kprobes();
@@ -233,8 +237,6 @@ int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val,
233 */ 237 */
234 preempt_disable(); 238 preempt_disable();
235 switch (val) { 239 switch (val) {
236 case DIE_IABR_MATCH:
237 case DIE_DABR_MATCH:
238 case DIE_BPT: 240 case DIE_BPT:
239 if (kprobe_handler(args->regs)) 241 if (kprobe_handler(args->regs))
240 ret = NOTIFY_STOP; 242 ret = NOTIFY_STOP;