qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Set the correct env->fpip for x86 float instructions [cleane


From: Richard Henderson
Subject: Re: [PATCH] Set the correct env->fpip for x86 float instructions [cleaned]
Date: Tue, 27 Apr 2021 10:49:36 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

On 4/16/21 8:34 AM, Ziqiao Kong wrote:
+++ b/target/i386/tcg/translate.c
@@ -6337,7 +6337,10 @@ static target_ulong disas_insn(DisasContext *s, CPUState 
*cpu)
                  goto unknown_op;
              }
          }
+        tcg_gen_movi_tl(s->tmp0, pc_start - s->cs_base);
+        tcg_gen_st_tl(s->tmp0, cpu_env, offsetof(CPUX86State, fpip));

This placement is wrong because it catches instructions that should not modify FIP, like FINIT.

It might be best to set a flag around this case like

  bool update_fip;

  case 0xd8 .. 0xdf:
    ...
    update_fip = true;
    if (mod != 3) {
        ...
    } else {
        ...
    }
    if (update_fip) {
        ...
    }
    break;

and set update_fip to false for the set of insns that either do not update FIP or clear it (8.1.8 x87 fpu instruction and data (operand) pointers).

I notice you're not saving FCS to go along with this, at least for CPUID.(EAX=07H,ECX=0H):EBX[bit 13] = 0.

And if you're going to this trouble, you might want to think about FDP+FDS as well. It should be about the same amount of effort.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]