qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stevie Lavern <stevie.lavern@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Bug] x86 EFLAGS refresh is not happening correctly
Date: Thu, 5 Aug 2021 13:33:50 +0200	[thread overview]
Message-ID: <380cef7a-fe5c-9252-e791-400c44486c2c@redhat.com> (raw)
In-Reply-To: <0d982751-7dfe-9a45-df5b-fbe57d36ccef@redhat.com>

On 05/08/21 13:24, Paolo Bonzini wrote:
> On 05/08/21 11:51, Stevie Lavern wrote:
>>
>> Shouldn't it be:
>> eflags = cpu_cc_compute_all(env, CC_OP) | (env->df & DF_MASK);
>> as eflags is entirely reevaluated by "cpu_cc_compute_all" ?
> 
> No, both are wrong.  env->eflags contains flags other than the 
> arithmetic flags (OF/SF/ZF/AF/PF/CF) and those have to be preserved.
> 
> The right code is in helper_read_eflags.  You can move it into 
> cpu_compute_eflags, and make helper_read_eflags use it.

Ah, actually the two are really the same, the TF/VM bits do not apply to 
cpu_compute_eflags so it's correct.

What seems wrong is migration of the EFLAGS register.  There should be 
code in cpu_pre_save and cpu_post_load to special-case it and setup 
CC_DST/CC_OP as done in cpu_load_eflags.

Also, cpu_load_eflags should assert that update_mask does not include 
any of the arithmetic flags.

Paolo


  reply	other threads:[~2021-08-05 11:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05  9:51 [Bug] x86 EFLAGS refresh is not happening correctly Stevie Lavern
2021-08-05 11:24 ` Paolo Bonzini
2021-08-05 11:33   ` Paolo Bonzini [this message]
2021-08-05 12:47     ` Stevie Lavern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=380cef7a-fe5c-9252-e791-400c44486c2c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stevie.lavern@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).