Skip to contentSkip to conversation

Fix LP#1841442 for powerpc

PATCH Applied Richard Henderson 3 participants 4 messages Aug 26, 2019 – Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

cover Fix LP#1841442 for powerpc

I only attempt to fix this bug for powerpc at the moment.

For x86_64... there is no existing attempt to handle fp exceptions at all. It will be quite the job to fix.

r~

Richard Henderson (1):
target/ppc: Fix do_float_check_status vs inexact

 target/ppc/fpu_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 target/ppc: Fix do_float_check_status vs inexact

The underflow and inexact exceptions are not mutually exclusive. Check for both of them. Tidy the reset of FPSCR[FI].

---
 target/ppc/fpu_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
target/ppc/fpu_helper.c +3 -7
index 07bc9051b0..2e023c5204 100644
@@ -630,19 +630,15 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)
 {
     CPUState *cs = env_cpu(env);
     int status = get_float_exception_flags(&env->fp_status);
-    bool inexact_happened = false;
 
     if (status & float_flag_overflow) {
         float_overflow_excp(env);
     } else if (status & float_flag_underflow) {
         float_underflow_excp(env);
-    } else if (status & float_flag_inexact) {
-        float_inexact_excp(env);
-        inexact_happened = true;
     }
-
-    /* if the inexact flag was not set */
-    if (inexact_happened == false) {
+    if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    } else {
         env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
     }
 
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/1] target/ppc: Fix do_float_check_status vs inexact

Quoted 6 lines · Richard Henderson

The underflow and inexact exceptions are not mutually exclusive. Check for both of them. Tidy the reset of FPSCR[FI].

Thanks, Richard!

There seems to be a similar problem with underflow. I'll narrow down a test case, and I guess I'll just open a new bug report.

PC

Quoted 32 lines
---
 target/ppc/fpu_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
target/ppc/fpu_helper.c +3 -7
index 07bc9051b0..2e023c5204 100644
@@ -630,19 +630,15 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)
 {
     CPUState *cs = env_cpu(env);
     int status = get_float_exception_flags(&env->fp_status);
-    bool inexact_happened = false;
 
     if (status & float_flag_overflow) {
         float_overflow_excp(env);
     } else if (status & float_flag_underflow) {
         float_underflow_excp(env);
-    } else if (status & float_flag_inexact) {
-        float_inexact_excp(env);
-        inexact_happened = true;
     }
-
-    /* if the inexact flag was not set */
-    if (inexact_happened == false) {
+    if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    } else {
         env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
     }
 
Applied
#3 lore raw

Re: [Qemu-devel] [PATCH 1/1] target/ppc: Fix do_float_check_status vs inexact

In reply to Richard Henderson
Quoted 6 lines · Richard Henderson

The underflow and inexact exceptions are not mutually exclusive. Check for both of them. Tidy the reset of FPSCR[FI].

Applied to ppc-for-4.2, thanks.

Quoted 31 lines
---
 target/ppc/fpu_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
target/ppc/fpu_helper.c +3 -7
index 07bc9051b0..2e023c5204 100644
@@ -630,19 +630,15 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)
 {
     CPUState *cs = env_cpu(env);
     int status = get_float_exception_flags(&env->fp_status);
-    bool inexact_happened = false;
 
     if (status & float_flag_overflow) {
         float_overflow_excp(env);
     } else if (status & float_flag_underflow) {
         float_underflow_excp(env);
-    } else if (status & float_flag_inexact) {
-        float_inexact_excp(env);
-        inexact_happened = true;
     }
-
-    /* if the inexact flag was not set */
-    if (inexact_happened == false) {
+    if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    } else {
         env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
     }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson