x86/insn: Fix vector instruction decoding on big endian cross-compiles
authorVasily Gorbik <gor@linux.ibm.com>
Fri, 13 Nov 2020 16:09:54 +0000 (17:09 +0100)
committerJosh Poimboeuf <jpoimboe@redhat.com>
Thu, 14 Jan 2021 00:13:17 +0000 (18:13 -0600)
commit5ed934e57e712b676ca62e1904ad672a9fa1505a
tree648beb17a7469cda7287483554316a66bc6dcf93
parent7786032e52cb02982a7154993b5d88c9c7a31ba5
x86/insn: Fix vector instruction decoding on big endian cross-compiles

Running instruction decoder posttest on an s390 host with an x86 target
with allyesconfig shows errors. Instructions used in a couple of kernel
objects could not be correctly decoded on big endian system.

  insn_decoder_test: warning: objdump says 6 bytes, but insn_get_length() says 5
  insn_decoder_test: warning: Found an x86 instruction decoder bug, please report this.
  insn_decoder_test: warning: ffffffff831eb4e1:    62 d1 fd 48 7f 04 24    vmovdqa64 %zmm0,(%r12)
  insn_decoder_test: warning: objdump says 7 bytes, but insn_get_length() says 6
  insn_decoder_test: warning: Found an x86 instruction decoder bug, please report this.
  insn_decoder_test: warning: ffffffff831eb4e8:    62 51 fd 48 7f 44 24 01         vmovdqa64 %zmm8,0x40(%r12)
  insn_decoder_test: warning: objdump says 8 bytes, but insn_get_length() says 6

This is because in a few places instruction field bytes are set directly
with further usage of "value". To address that introduce and use a
insn_set_byte() helper, which correctly updates "value" on big endian
systems.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
arch/x86/include/asm/insn.h
arch/x86/lib/insn.c
tools/arch/x86/include/asm/insn.h
tools/arch/x86/lib/insn.c