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 #endif 267 268 if (p) { 269 - if (cur) { 270 /* Kprobe is pending, so we're recursing. */ 271 switch (kcb->kprobe_status) { 272 case KPROBE_HIT_ACTIVE: ··· 297 /* impossible cases */ 298 BUG(); 299 } 300 - } else if (p->ainsn.insn_check_cc(regs->ARM_cpsr)) { 301 /* Probe hit and conditional execution check ok. */ 302 set_current_kprobe(p); 303 kcb->kprobe_status = KPROBE_HIT_ACTIVE; ··· 318 } 319 reset_current_kprobe(); 320 } 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 } 329 } else if (cur) { 330 /* We probably hit a jprobe. Call its break handler. */
··· 266 #endif 267 268 if (p) { 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) { 278 /* Kprobe is pending, so we're recursing. */ 279 switch (kcb->kprobe_status) { 280 case KPROBE_HIT_ACTIVE: ··· 289 /* impossible cases */ 290 BUG(); 291 } 292 + } else { 293 /* Probe hit and conditional execution check ok. */ 294 set_current_kprobe(p); 295 kcb->kprobe_status = KPROBE_HIT_ACTIVE; ··· 310 } 311 reset_current_kprobe(); 312 } 313 } 314 } else if (cur) { 315 /* We probably hit a jprobe. Call its break handler. */