OSDN Git Service

x86/insn: Add an insn_decode() API
authorBorislav Petkov <bp@suse.de>
Tue, 3 Nov 2020 16:28:30 +0000 (17:28 +0100)
committerBorislav Petkov <bp@suse.de>
Mon, 15 Mar 2021 10:05:47 +0000 (11:05 +0100)
commit93281c4a96572a34504244969b938e035204778d
tree9557117b6c67303c51f9a9d07a14d26976ee1b25
parentd30c7b820be5c4777fe6c3b0c21f9d0064251e51
x86/insn: Add an insn_decode() API

Users of the instruction decoder should use this to decode instruction
bytes. For that, have insn*() helpers return an int value to denote
success/failure. When there's an error fetching the next insn byte and
the insn falls short, return -ENODATA to denote that.

While at it, make insn_get_opcode() more stricter as to whether what has
seen so far is a valid insn and if not.

Copy linux/kconfig.h for the tools-version of the decoder so that it can
use IS_ENABLED().

Also, cast the INSN_MODE_KERN dummy define value to (enum insn_mode)
for tools use of the decoder because perf tool builds with -Werror and
errors out with -Werror=sign-compare otherwise.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lkml.kernel.org/r/20210304174237.31945-5-bp@alien8.de
arch/x86/include/asm/insn.h
arch/x86/lib/insn.c
tools/arch/x86/include/asm/insn.h
tools/arch/x86/lib/insn.c
tools/include/linux/kconfig.h [new file with mode: 0644]