arm: kprobes: Skip single-stepping in recursing path if possible

Kprobes/arm skips single-stepping (moreover handling the event)
if the conditional instruction must not be executed. This
also apply the rule when we hit the recursing kprobe, so
that kprobe does not count nmissed up in that case.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Jon Medhurst <tixy@linaro.org>

authored by Masami Hiramatsu and committed by Jon Medhurst 91fc862c f3fbd7ec

+10 -9
+10 -9
arch/arm/probes/kprobes/core.c
··· 266 266 #endif 267 267 268 268 if (p) { 269 - if (cur) { 269 + if (!p->ainsn.insn_check_cc(regs->ARM_cpsr)) { 270 + /* 271 + * Probe hit but conditional execution check failed, 272 + * so just skip the instruction and continue as if 273 + * nothing had happened. 274 + * In this case, we can skip recursing check too. 275 + */ 276 + singlestep_skip(p, regs); 277 + } else if (cur) { 270 278 /* Kprobe is pending, so we're recursing. */ 271 279 switch (kcb->kprobe_status) { 272 280 case KPROBE_HIT_ACTIVE: ··· 297 289 /* impossible cases */ 298 290 BUG(); 299 291 } 300 - } else if (p->ainsn.insn_check_cc(regs->ARM_cpsr)) { 292 + } else { 301 293 /* Probe hit and conditional execution check ok. */ 302 294 set_current_kprobe(p); 303 295 kcb->kprobe_status = KPROBE_HIT_ACTIVE; ··· 318 310 } 319 311 reset_current_kprobe(); 320 312 } 321 - } else { 322 - /* 323 - * Probe hit but conditional execution check failed, 324 - * so just skip the instruction and continue as if 325 - * nothing had happened. 326 - */ 327 - singlestep_skip(p, regs); 328 313 } 329 314 } else if (cur) { 330 315 /* We probably hit a jprobe. Call its break handler. */