Commit eb4f8e25 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/kprobes: Remove redundant code

At the time being we have something like

	if (something) {
		p = get();
		if (p) {
			if (something_wrong)
				goto out;
			...
			return;
		} else if (a != b) {
			if (some_error)
				goto out;
			...
		}
		goto out;
	}
	p = get();
	if (!p) {
		if (a != b) {
			if (some_error)
				goto out;
			...
		}
		goto out;
	}

This is similar to

	p = get();
	if (!p) {
		if (a != b) {
			if (some_error)
				goto out;
			...
		}
		goto out;
	}
	if (something) {
		if (something_wrong)
			goto out;
		...
		return;
	}
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
[mpe: Reflow the comment that was moved]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/07a17425743600460ce35fa9432d42487a825583.1582099499.git.christophe.leroy@c-s.fr
parent 6eeb9b3b
...@@ -271,23 +271,45 @@ int kprobe_handler(struct pt_regs *regs) ...@@ -271,23 +271,45 @@ int kprobe_handler(struct pt_regs *regs)
preempt_disable(); preempt_disable();
kcb = get_kprobe_ctlblk(); kcb = get_kprobe_ctlblk();
p = get_kprobe(addr);
if (!p) {
if (*addr != BREAKPOINT_INSTRUCTION) {
/*
* PowerPC has multiple variants of the "trap"
* instruction. If the current instruction is a
* trap variant, it could belong to someone else
*/
kprobe_opcode_t cur_insn = *addr;
if (is_trap(cur_insn))
goto no_kprobe;
/*
* The breakpoint instruction was removed right
* after we hit it. Another cpu has removed
* either a probepoint or a debugger breakpoint
* at this address. In either case, no further
* handling of this interrupt is appropriate.
*/
ret = 1;
}
/* Not one of ours: let kernel handle it */
goto no_kprobe;
}
/* Check we're not actually recursing */ /* Check we're not actually recursing */
if (kprobe_running()) { if (kprobe_running()) {
p = get_kprobe(addr);
if (p) {
kprobe_opcode_t insn = *p->ainsn.insn; kprobe_opcode_t insn = *p->ainsn.insn;
if (kcb->kprobe_status == KPROBE_HIT_SS && if (kcb->kprobe_status == KPROBE_HIT_SS && is_trap(insn)) {
is_trap(insn)) {
/* Turn off 'trace' bits */ /* Turn off 'trace' bits */
regs->msr &= ~MSR_SINGLESTEP; regs->msr &= ~MSR_SINGLESTEP;
regs->msr |= kcb->kprobe_saved_msr; regs->msr |= kcb->kprobe_saved_msr;
goto no_kprobe; goto no_kprobe;
} }
/* We have reentered the kprobe_handler(), since
* another probe was hit while within the handler. /*
* We here save the original kprobes variables and * We have reentered the kprobe_handler(), since another probe
* just single step on the instruction of the new probe * was hit while within the handler. We here save the original
* without calling any user handlers. * kprobes variables and just single step on the instruction of
* the new probe without calling any user handlers.
*/ */
save_previous_kprobe(kcb); save_previous_kprobe(kcb);
set_current_kprobe(p, regs, kcb); set_current_kprobe(p, regs, kcb);
...@@ -304,43 +326,6 @@ int kprobe_handler(struct pt_regs *regs) ...@@ -304,43 +326,6 @@ int kprobe_handler(struct pt_regs *regs)
} }
prepare_singlestep(p, regs); prepare_singlestep(p, regs);
return 1; return 1;
} else if (*addr != BREAKPOINT_INSTRUCTION) {
/* If trap variant, then it belongs not to us */
kprobe_opcode_t cur_insn = *addr;
if (is_trap(cur_insn))
goto no_kprobe;
/* The breakpoint instruction was removed by
* another cpu right after we hit, no further
* handling of this interrupt is appropriate
*/
ret = 1;
}
goto no_kprobe;
}
p = get_kprobe(addr);
if (!p) {
if (*addr != BREAKPOINT_INSTRUCTION) {
/*
* PowerPC has multiple variants of the "trap"
* instruction. If the current instruction is a
* trap variant, it could belong to someone else
*/
kprobe_opcode_t cur_insn = *addr;
if (is_trap(cur_insn))
goto no_kprobe;
/*
* The breakpoint instruction was removed right
* after we hit it. Another cpu has removed
* either a probepoint or a debugger breakpoint
* at this address. In either case, no further
* handling of this interrupt is appropriate.
*/
ret = 1;
}
/* Not one of ours: let kernel handle it */
goto no_kprobe;
} }
kcb->kprobe_status = KPROBE_HIT_ACTIVE; kcb->kprobe_status = KPROBE_HIT_ACTIVE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment