All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Froyd <froydnj@mozilla.com>
To: froydnj@gmail.com
Subject: [Qemu-devel] [PATCH] target-i386: fix translation of sse {, u}comis{s, d} instructions
Date: Wed, 25 Sep 2013 16:20:27 -0400	[thread overview]
Message-ID: <E1VOwIk-0006Fg-4Z@eggs.gnu.org> (raw)

While the generic SSE translation codepath contains special logic to use
32-bit or 64-bit memory operands for some instructions, this logic doesn't
catch the SSE {,u}comis{s,d} instructions.  This oversight leads to too
many bytes being read when those instructions use memory operands, which
can in turn lead to page faults.

The fix is simple: add a special case for these instructions.  It did not
fit cleanly into the existing case, so some cut-and-paste was necesary.

Signed-off-by: Nathan Froyd <froydnj@mozilla.com>
---
 target-i386/translate.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/target-i386/translate.c b/target-i386/translate.c
index be74ebc..687859a 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -4576,6 +4576,16 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b,
                         /* 64 bit access */
                         gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_t0.XMM_D(0)));
                     }
+                } else if (b1 <= 1 && (b == 0x2e || b == 0x2f)) {
+                    /* specific case for SSE *comis{s,d} instructions */
+                    if (b1 == 0) {
+                        /* 32 bit access */
+                        gen_op_ld_T0_A0(OT_LONG + s->mem_index);
+                        tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_t0.XMM_L(0)));
+                    } else {
+                        /* 64 bit access */
+                        gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_t0.XMM_D(0)));
+                    }
                 } else {
                     gen_ldo_env_A0(s->mem_index, op2_offset);
                 }
-- 
1.7.10.4

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-25 20:20 Nathan Froyd [this message]
2013-09-26 14:15 ` [Qemu-devel] [PATCH] target-i386: fix translation of sse {, u}comis{s, d} instructions Richard Henderson

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=E1VOwIk-0006Fg-4Z@eggs.gnu.org \
    --to=froydnj@mozilla.com \
    --cc=froydnj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.