i386: hvf: Fix register refs if REX is present
commitb4e1af8961bf9b0d415abdf3e4908168daea6059
authorRoman Bolshakov <r.bolshakov@yadro.com>
Thu, 18 Oct 2018 13:44:01 +0000 (18 16:44 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Oct 2018 11:44:12 +0000 (19 13:44 +0200)
tree1626da7b6b3fc871b8c23bf6bc6f3b44466bfa77
parent6b7a98303b53b0cd94c2755b1f5c0734bbaa5347
i386: hvf: Fix register refs if REX is present

According to Intel(R)64 and IA-32 Architectures Software Developer's
Manual, the following one-byte registers should be fetched when REX
prefix is present (sorted by reg encoding index):
AL, CL, DL, BL, SPL, BPL, SIL, DIL, R8L - R15L

The first 8 are fetched if REX.R is zero, the last 8 if non-zero.

The following registers should be fetched for instructions without REX
prefix (also sorted by reg encoding index):
AL, CL, DL, BL, AH, CH, DH, BH

Current emulation code doesn't handle accesses to SPL, BPL, SIL, DIL
when REX is present, thefore an instruction 40883e "mov %dil,(%rsi)" is
decoded as "mov %bh,(%rsi)".

That caused an infinite loop in vp_reset:
https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg03293.html

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Message-Id: <20181018134401.44471-1-r.bolshakov@yadro.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/hvf/x86_decode.c
target/i386/hvf/x86_decode.h