Re: [RFC PATCH 1/1] x86/kprobes: Use int3 instead of debug trap for single-step

From: Peter Zijlstra
Date: Tue Mar 02 2021 - 04:21:42 EST


On Mon, Mar 01, 2021 at 11:08:15PM +0900, Masami Hiramatsu wrote:

> + default:
> + if ((opcode & 0xf0) == 0x70) {
> + /* 1 byte conditional jump */
> + p->ainsn.emulate_op = kprobe_emulate_jcc;
> + p->ainsn.jcc.type = opcode & 0xf;
> + p->ainsn.rel32 = *(char *)insn->immediate.bytes;
> + }
> }

Would it make sense to write that as:

case 0x70 ... 0x7f:
/* 1 byte conditional jump */
p->ainsn.emulate_op = kprobe_emulate_jcc;
p->ainsn.jcc.type = opcode & 0xf;
p->ainsn.rel32 = *(char *)insn->immediate.bytes;
break;

instead? Preferably right before the 0x0f case :-)