[PATCH v4 32/41] linux-user/openrisc: Adjust signal for EXCP_RANGE, EXCP_FPE

Richard Henderson posted 41 patches 4 years, 4 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Cornelia Huck <cohuck@redhat.com>, David Hildenbrand <david@redhat.com>, Taylor Simpson <tsimpson@quicinc.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Thomas Huth <thuth@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Laurent Vivier <laurent@vivier.eu>, Paolo Bonzini <pbonzini@redhat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Aurelien Jarno <aurelien@aurel32.net>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Richard Henderson <richard.henderson@linaro.org>
[PATCH v4 32/41] linux-user/openrisc: Adjust signal for EXCP_RANGE, EXCP_FPE
Posted by Richard Henderson 4 years, 4 months ago
The kernel vectors both of these through unhandled_exception, which
results in force_sig(SIGSEGV).  This isn't very useful for userland
when enabling overflow traps or fpu traps, but c'est la vie.

Cc: Stafford Horne <shorne@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/openrisc/cpu_loop.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c
index f6360db47c..de5417a262 100644
--- a/linux-user/openrisc/cpu_loop.c
+++ b/linux-user/openrisc/cpu_loop.c
@@ -56,13 +56,17 @@ void cpu_loop(CPUOpenRISCState *env)
             break;
         case EXCP_DPF:
         case EXCP_IPF:
-        case EXCP_RANGE:
             info.si_signo = TARGET_SIGSEGV;
             info.si_errno = 0;
             info.si_code = TARGET_SEGV_MAPERR;
             info._sifields._sigfault._addr = env->pc;
             queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
             break;
+        case EXCP_RANGE:
+        case EXCP_FPE:
+            /* ??? The kernel vectors both of these to unhandled_exception. */
+            force_sig(TARGET_SIGSEGV);
+            break;
         case EXCP_ALIGN:
             info.si_signo = TARGET_SIGBUS;
             info.si_errno = 0;
@@ -77,13 +81,6 @@ void cpu_loop(CPUOpenRISCState *env)
             info._sifields._sigfault._addr = env->pc;
             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 = 0;
-            info._sifields._sigfault._addr = env->pc;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
         case EXCP_INTERRUPT:
             /* We processed the pending cpu work above.  */
             break;
-- 
2.25.1


Re: [PATCH v4 32/41] linux-user/openrisc: Adjust signal for EXCP_RANGE, EXCP_FPE
Posted by Stafford Horne 4 years, 4 months ago
On Wed, Oct 06, 2021 at 10:22:58AM -0700, Richard Henderson wrote:
> The kernel vectors both of these through unhandled_exception, which
> results in force_sig(SIGSEGV).  This isn't very useful for userland
> when enabling overflow traps or fpu traps, but c'est la vie.

Thanks for looking into it.  I am happy to accept kernel patches ;), otherwise
these are now on my todo list.  The FPU support is already something I am
looking to take care of as mentioned before, but that is after I finish getting
the glibc port upstreamed.

That said,

Reviewed-by: Stafford Horne <shorne@gmail.com>

> Cc: Stafford Horne <shorne@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/openrisc/cpu_loop.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c
> index f6360db47c..de5417a262 100644
> --- a/linux-user/openrisc/cpu_loop.c
> +++ b/linux-user/openrisc/cpu_loop.c
> @@ -56,13 +56,17 @@ void cpu_loop(CPUOpenRISCState *env)
>              break;
>          case EXCP_DPF:
>          case EXCP_IPF:
> -        case EXCP_RANGE:
>              info.si_signo = TARGET_SIGSEGV;
>              info.si_errno = 0;
>              info.si_code = TARGET_SEGV_MAPERR;
>              info._sifields._sigfault._addr = env->pc;
>              queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
>              break;
> +        case EXCP_RANGE:
> +        case EXCP_FPE:
> +            /* ??? The kernel vectors both of these to unhandled_exception. */
> +            force_sig(TARGET_SIGSEGV);
> +            break;
>          case EXCP_ALIGN:
>              info.si_signo = TARGET_SIGBUS;
>              info.si_errno = 0;
> @@ -77,13 +81,6 @@ void cpu_loop(CPUOpenRISCState *env)
>              info._sifields._sigfault._addr = env->pc;
>              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 = 0;
> -            info._sifields._sigfault._addr = env->pc;
> -            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
> -            break;
>          case EXCP_INTERRUPT:
>              /* We processed the pending cpu work above.  */
>              break;
> -- 
> 2.25.1
>