From d966a1be7abfa0d4421464ff151fc10fc4c1f292 Mon Sep 17 00:00:00 2001 From: Maneesh Soni Date: Tue, 8 Nov 2011 17:05:35 +0530 Subject: [PATCH] --- yaml --- r: 284771 b: refs/heads/master c: 9233c1ee71bdd3c8a918c8e17026cf3f7d99c90b h: refs/heads/master i: 284769: 35ac05a56abc3250bf7459c511ae432134bc5dc4 284767: 8bd1b11895d5703caa470cdc53aaafb587548ea9 v: v3 --- [refs] | 2 +- trunk/arch/mips/kernel/kprobes.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 64acc6a78f34..7811de58fd7a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 41dde781f50c39cddc8032fc04d6a7d538237737 +refs/heads/master: 9233c1ee71bdd3c8a918c8e17026cf3f7d99c90b diff --git a/trunk/arch/mips/kernel/kprobes.c b/trunk/arch/mips/kernel/kprobes.c index 9fb1876cb0bd..0ab1a5ff1049 100644 --- a/trunk/arch/mips/kernel/kprobes.c +++ b/trunk/arch/mips/kernel/kprobes.c @@ -113,6 +113,30 @@ static int __kprobes insn_has_delayslot(union mips_instruction insn) return 0; } +/* + * insn_has_ll_or_sc function checks whether instruction is ll or sc + * one; putting breakpoint on top of atomic ll/sc pair is bad idea; + * so we need to prevent it and refuse kprobes insertion for such + * instructions; cannot do much about breakpoint in the middle of + * ll/sc pair; it is upto user to avoid those places + */ +static int __kprobes insn_has_ll_or_sc(union mips_instruction insn) +{ + int ret = 0; + + switch (insn.i_format.opcode) { + case ll_op: + case lld_op: + case sc_op: + case scd_op: + ret = 1; + break; + default: + break; + } + return ret; +} + int __kprobes arch_prepare_kprobe(struct kprobe *p) { union mips_instruction insn; @@ -121,6 +145,13 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) insn = p->addr[0]; + if (insn_has_ll_or_sc(insn)) { + pr_notice("Kprobes for ll and sc instructions are not" + "supported\n"); + ret = -EINVAL; + goto out; + } + if (insn_has_delayslot(insn)) { pr_notice("Kprobes for branch and jump instructions are not" "supported\n");