qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [BUG/PATCH] Fix i386 SSE status flag corruption
Date: Mon, 30 Sep 2013 22:20:57 +0100	[thread overview]
Message-ID: <1380576057.18603.465.camel@ted> (raw)

This is a combination of bug report and patch. I'm not sure if you'll want to fix it 
like this but it illustrates the problem and should be easy to fix based on this.

When we restore the mxcsr register with FXRSTOR, we need to update the various SSE
status flags in CPUX86State by calling update_sse_status(). If we don't, we end up 
using the status bits from some other context with interesting results.

I used a function prototype since it makes the fix clear, some code rearrangement
might be needed ultimately.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Index: qemu-1.5.0/target-i386/fpu_helper.c
===================================================================
--- qemu-1.5.0.orig/target-i386/fpu_helper.c	2013-09-30 18:46:39.283377648 +0000
+++ qemu-1.5.0/target-i386/fpu_helper.c	2013-09-30 18:46:56.895377232 +0000
@@ -1149,6 +1149,8 @@
     }
 }
 
+static void update_sse_status(CPUX86State *env);
+
 void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64)
 {
     int i, fpus, fptag, nb_xmm_regs;
@@ -1180,6 +1182,7 @@
     if (env->cr[4] & CR4_OSFXSR_MASK) {
         /* XXX: finish it */
         env->mxcsr = cpu_ldl_data(env, ptr + 0x18);
+        update_sse_status(env);
         /* cpu_ldl_data(env, ptr + 0x1c); */
         if (env->hflags & HF_CS64_MASK) {
             nb_xmm_regs = 16;

             reply	other threads:[~2013-09-30 21:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 21:20 Richard Purdie [this message]
2013-10-13 15:44 ` [Qemu-devel] [BUG/PATCH] Fix i386 SSE status flag corruption Richard Purdie

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=1380576057.18603.465.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=qemu-devel@nongnu.org \
    /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).