qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: qemu-devel@nongnu.org, laurent@vivier.eu
Cc: amarkovic@wavecomp.com
Subject: [Qemu-devel] [PATCH v16 5/5] linux-user: Handle EXCP_FPE properly for MIPS
Date: Fri, 28 Jun 2019 12:43:38 +0200	[thread overview]
Message-ID: <1561718618-20218-6-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1561718618-20218-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Aleksandar Markovic <amarkovic@wavecomp.com>

Handle EXCP_FPE properly for MIPS in cpu loop.

Note that a vast majority of FP instructions are not affected by
the absence of the code in this patch, as they use alternative code
paths for handling floating point exceptions (see, for example,
invocations of update_fcr31()) - they rely on softfloat library for
keeping track on exceptions that needs to be raised. However, there
are few MIPS FP instructions (an example is CTC1) that use function
do_raise_exception() directly, and they need the case that is added
in this patch to propagate the FPE exception as designed.

The code is based on kernel's function force_fcr31_sig() in
arch/mips/kernel.traps.c.

Reported-by: Yunqiang Su <ysu@wavecomp.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/mips/cpu_loop.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index 43ba267..0ba894f 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -540,6 +540,23 @@ done_syscall:
             info.si_code = TARGET_ILL_ILLOPC;
             queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
             break;
+        case EXCP_FPE:
+            info.si_signo = TARGET_SIGFPE;
+            info.si_errno = 0;
+            info.si_code = TARGET_FPE_FLTUNK;
+            if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INVALID) {
+                info.si_code = TARGET_FPE_FLTINV;
+            } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_DIV0) {
+                info.si_code = TARGET_FPE_FLTDIV;
+            } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_OVERFLOW) {
+                info.si_code = TARGET_FPE_FLTOVF;
+            } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_UNDERFLOW) {
+                info.si_code = TARGET_FPE_FLTUND;
+            } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INEXACT) {
+                info.si_code = TARGET_FPE_FLTRES;
+            }
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
         /* The code below was inspired by the MIPS Linux kernel trap
          * handling code in arch/mips/kernel/traps.c.
          */
-- 
2.7.4



  parent reply	other threads:[~2019-06-28 10:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 10:43 [Qemu-devel] [PATCH v16 0/5] linux-user: A set of miscellaneous patches Aleksandar Markovic
2019-06-28 10:43 ` [Qemu-devel] [PATCH v16 1/5] linux-user: Add support for translation of statx() syscall Aleksandar Markovic
2019-06-29  0:53   ` Aleksandar Markovic
2019-06-29  4:06     ` Jim Wilson
2019-06-30 15:44       ` Aleksandar Markovic
2019-07-01  8:40   ` Laurent Vivier
2019-06-28 10:43 ` [Qemu-devel] [PATCH v16 2/5] linux-user: Add support for strace for " Aleksandar Markovic
2019-07-01  8:42   ` Laurent Vivier
2019-06-28 10:43 ` [Qemu-devel] [PATCH v16 3/5] linux-user: Fix target_flock structure for MIPS O64 ABI Aleksandar Markovic
2019-07-01  8:42   ` Laurent Vivier
2019-06-28 10:43 ` [Qemu-devel] [PATCH v16 4/5] linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK Aleksandar Markovic
2019-07-01  8:43   ` Laurent Vivier
2019-06-28 10:43 ` Aleksandar Markovic [this message]
2019-07-01  8:44   ` [Qemu-devel] [PATCH v16 5/5] linux-user: Handle EXCP_FPE properly for MIPS Laurent Vivier
2019-07-01  8:46   ` Laurent Vivier
2019-06-28 11:30 ` [Qemu-devel] [PATCH v16 0/5] linux-user: A set of miscellaneous patches no-reply

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=1561718618-20218-6-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=laurent@vivier.eu \
    --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).