qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jaume Marti Farriol <jaume.martif@gmail.com>
To: qemu-devel@nongnu.org
Cc: Jaume Marti Farriol <jaume.martif@gmail.com>
Subject: [Qemu-devel] [PATCH v3 3/3] target-i386: x87 exception pointers using TCG.
Date: Sun,  7 Sep 2014 00:32:00 +0200	[thread overview]
Message-ID: <1410042720-17750-4-git-send-email-jaume.martif@gmail.com> (raw)
In-Reply-To: <1410042720-17750-1-git-send-email-jaume.martif@gmail.com>

This adds tests for the x87 exception pointers.

Signed-off-by: jaume.martif@gmail.com
---
 tests/tcg/test-i386.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 65 insertions(+), 6 deletions(-)

diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index b05572b..bc93918 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -2327,12 +2327,22 @@ struct fpxstate {
     uint16_t fpus;
     uint16_t fptag;
     uint16_t fop;
-    uint32_t fpuip;
-    uint16_t cs_sel;
-    uint16_t dummy0;
-    uint32_t fpudp;
-    uint16_t ds_sel;
-    uint16_t dummy1;
+    union {
+        struct {
+            uint32_t fpuip;
+            uint16_t cs_sel;
+            uint16_t dummy0;
+        } mode_non_64_ins;
+        uint64_t mode_64_fpuip;
+    };
+    union {
+        struct {
+            uint32_t fpudp;
+            uint16_t ds_sel;
+            uint16_t dummy1;
+        } mode_non_64_data;
+        uint64_t mode_64_fpudp;
+    };
     uint32_t mxcsr;
     uint32_t mxcsr_mask;
     uint8_t fpregs1[8 * 16];
@@ -2342,6 +2352,7 @@ struct fpxstate {
 
 static struct fpxstate fpx_state __attribute__((aligned(16)));
 static struct fpxstate fpx_state2 __attribute__((aligned(16)));
+float fxsave_mem_operand;
 
 void test_fxsave(void)
 {
@@ -2362,6 +2373,7 @@ void test_fxsave(void)
         " fld1\n"
         " fldpi\n"
         " fldln2\n"
+        " fmul fxsave_mem_operand\n"
         " fxsave %0\n"
         " fxrstor %0\n"
         " fxsave %1\n"
@@ -2371,6 +2383,18 @@ void test_fxsave(void)
     printf("fpuc=%04x\n", fp->fpuc);
     printf("fpus=%04x\n", fp->fpus);
     printf("fptag=%04x\n", fp->fptag);
+#if defined(__x86_64__)
+    printf("fpuip=%04llx\n", (long long unsigned int) fp->mode_64_fpuip);
+#else
+    printf("fpuip=%04x\n", fp->mode_non_64_ins.fpuip);
+    printf("cs_sel=%04x\n", fp->mode_non_64_ins.cs_sel);
+#endif
+#if defined(__x86_64__)
+    printf("fpudp=%04llx\n", (long long unsigned int) fp->mode_64_fpudp);
+#else
+    printf("fpudp=%04x\n", fp->mode_non_64_data.fpudp);
+    printf("ds_sel=%04x\n", fp->mode_non_64_data.ds_sel);
+#endif
     for(i = 0; i < 3; i++) {
         printf("ST%d: " FMT64X " %04x\n",
                i,
@@ -2687,6 +2711,40 @@ void test_sse(void)
     printf("%-10s A=" FMTLX " R=" FMTLX ":" FMTLX "\n", #op, a, r, rh);  \
 }
 
+struct fnstate {
+    uint16_t fpuc;
+    uint16_t dummy0;
+    uint16_t fpus;
+    uint16_t dummy1;
+    uint16_t fptag;
+    uint16_t dummy2;
+    uint32_t fpuip;
+    uint16_t cs_sel;
+    uint16_t fop;
+    uint32_t fpudp;
+    uint16_t ds_sel;
+};
+
+static struct fnstate fn_state __attribute__((aligned(16)));
+float fnstenv_mem_operand;
+
+void test_fnstenv(void)
+{
+    struct fnstate *fp = &fn_state;
+
+    asm(" fld1\n"
+        " fmul fnstenv_mem_operand\n"
+        " fnstenv %0\n"
+        : "=m" (*(uint32_t *)fp) : );
+    printf("fpuc=%04x\n", fp->fpuc);
+    printf("fpus=%04x\n", fp->fpus);
+    printf("fptag=%04x\n", fp->fptag);
+    printf("fpuip=%04x\n", fp->fpuip);
+    printf("cs_sel=%04x\n", fp->cs_sel);
+    printf("fpudp=%04x\n", fp->fpudp);
+    printf("ds_sel=%04x\n", fp->ds_sel);
+}
+
 void test_conv(void)
 {
     TEST_CONV_RAX(cbw);
@@ -2757,6 +2815,7 @@ int main(int argc, char **argv)
 #endif
     test_enter();
     test_conv();
+    test_fnstenv();
 #ifdef TEST_SSE
     test_sse();
     test_fxsave();
-- 
2.1.0

      parent reply	other threads:[~2014-09-06 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-06 22:31 [Qemu-devel] [PATCH v3 0/3] target-i386: x87 exception pointers using TCG Jaume Marti Farriol
2014-09-06 22:31 ` [Qemu-devel] [PATCH v3 1/3] " Jaume Marti Farriol
2014-09-06 22:31 ` [Qemu-devel] [PATCH v3 2/3] " Jaume Marti Farriol
2014-09-06 23:01   ` Jaume Martí
2014-09-06 22:32 ` Jaume Marti Farriol [this message]

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=1410042720-17750-4-git-send-email-jaume.martif@gmail.com \
    --to=jaume.martif@gmail.com \
    --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).