x86/insn,uprobes,alternative: Unify insn_is_nop()
authorPeter Zijlstra <peterz@infradead.org>
Fri, 5 Sep 2025 08:24:47 +0000 (10:24 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 16 Oct 2025 09:13:47 +0000 (11:13 +0200)
commit8a5c6cbfe4a35c6a22d2f8bbaf49b8cc3f45fcc6
tree0d963feafee2ea519b5cb4558c6c42fda1270e13
parent866cf36bfee4fba6a492d2dcc5133f857e3446b0
x86/insn,uprobes,alternative: Unify insn_is_nop()

Both uprobes and alternatives have insn_is_nop() variants, unify them
and make sure insn_is_nop() works for both x86_64 and i386.

Specifically, uprobe must not compare userspace instructions to kernel
nops as that does not work right in the compat case.

For the uprobe case we therefore must recognise common 32bit and 64bit
nops. Because uprobe will consume the instruction as a nop, it must
not mistakenly claim a non-nop instruction to be a nop. Eg. 'REX.b3
NOP' is 'xchg %r8,%rax' - not a nop.

For the kernel case similar constraints apply, is it used to optimize
NOPs by replacing strings of short(er) nops with longer nops. Must not
claim an instruction is a nop if it really isn't. Not recognising a
nop is non-fatal.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
arch/x86/include/asm/insn-eval.h
arch/x86/kernel/alternative.c
arch/x86/kernel/uprobes.c
arch/x86/lib/insn-eval.c