Skip to content

Commit 5c73b75

Browse files
Matthew Ogilviemalc
authored andcommitted
target-i386/translate.c: mov to/from crN/drN: ignore mod bits
> This instruction is always treated as a register-to-register (MOD = 11) > instruction, regardless of the encoding of the MOD field in the MODR/M > byte. Also, Microport UNIX System V/386 v 2.1 (ca 1987) runs fine on real Intel 386 and 486 CPU's (at least), but does not run in qemu without this patch. Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net> Signed-off-by: malc <av1474@comtv.ru>
1 parent 145c7c8 commit 5c73b75

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

target-i386/translate.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7551,8 +7551,11 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
75517551
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
75527552
} else {
75537553
modrm = cpu_ldub_code(cpu_single_env, s->pc++);
7554-
if ((modrm & 0xc0) != 0xc0)
7555-
goto illegal_op;
7554+
/* Ignore the mod bits (assume (modrm&0xc0)==0xc0).
7555+
* AMD documentation (24594.pdf) and testing of
7556+
* intel 386 and 486 processors all show that the mod bits
7557+
* are assumed to be 1's, regardless of actual values.
7558+
*/
75567559
rm = (modrm & 7) | REX_B(s);
75577560
reg = ((modrm >> 3) & 7) | rex_r;
75587561
if (CODE64(s))
@@ -7594,8 +7597,11 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
75947597
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
75957598
} else {
75967599
modrm = cpu_ldub_code(cpu_single_env, s->pc++);
7597-
if ((modrm & 0xc0) != 0xc0)
7598-
goto illegal_op;
7600+
/* Ignore the mod bits (assume (modrm&0xc0)==0xc0).
7601+
* AMD documentation (24594.pdf) and testing of
7602+
* intel 386 and 486 processors all show that the mod bits
7603+
* are assumed to be 1's, regardless of actual values.
7604+
*/
75997605
rm = (modrm & 7) | REX_B(s);
76007606
reg = ((modrm >> 3) & 7) | rex_r;
76017607
if (CODE64(s))

0 commit comments

Comments
 (0)