[PATCH 0/2] x86: Fix insn decoder to support 0xEA as UD

Masami Hiramatsu (Google) posted 2 patches 9 months, 2 weeks ago
arch/x86/include/asm/inat.h                |    6 +++
arch/x86/lib/insn.c                        |    7 +++-
arch/x86/lib/x86-opcode-map.txt            |   56 ++++++++++++++--------------
arch/x86/tools/gen-insn-attr-x86.awk       |    7 ++++
tools/arch/x86/include/asm/inat.h          |    6 +++
tools/arch/x86/lib/insn.c                  |    7 +++-
tools/arch/x86/lib/x86-opcode-map.txt      |   56 ++++++++++++++--------------
tools/arch/x86/tools/gen-insn-attr-x86.awk |    7 ++++
8 files changed, 94 insertions(+), 58 deletions(-)
[PATCH 0/2] x86: Fix insn decoder to support 0xEA as UD
Posted by Masami Hiramatsu (Google) 9 months, 2 weeks ago
Hi,

Peter found that the current x86 instruction decoder reports the 0xEA
instruction as "JMP Ap" always. But objdump says that is invalid on
64bit mode. Thus there is a difference of lenght of 0xEA between
objdump and x86 insn decoder.

I found the opcodes which have (i64) superscript are invalid in 64bit
mode, if it is not paired with (o64). Thus this stops decoding such
instructions if insn->x86_64 is set.

With this fix, the single "0xEA" is correctly decoded as 1 byte
instruction in 64bit mode.
------
printf "0:\tea\t\n" | insn_decoder_test -y -v
insn_decoder_test: success: Decoded and checked 1 instructions
------

In this series, I also found a bug in previous (!REX2) tag. The first
commit fixes that.

---

Masami Hiramatsu (Google) (2):
      x86: Fix opcode map (!REX2) superscript tags
      x86: Stop decoding i64 instructions in x86-64 mode at opcode


 arch/x86/include/asm/inat.h                |    6 +++
 arch/x86/lib/insn.c                        |    7 +++-
 arch/x86/lib/x86-opcode-map.txt            |   56 ++++++++++++++--------------
 arch/x86/tools/gen-insn-attr-x86.awk       |    7 ++++
 tools/arch/x86/include/asm/inat.h          |    6 +++
 tools/arch/x86/lib/insn.c                  |    7 +++-
 tools/arch/x86/lib/x86-opcode-map.txt      |   56 ++++++++++++++--------------
 tools/arch/x86/tools/gen-insn-attr-x86.awk |    7 ++++
 8 files changed, 94 insertions(+), 58 deletions(-)

--
Masami Hiramatsu (Google) <mhiramat@kernel.org>