[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH v2 04/15] s390x/tcg: Fix parts of IEEE exception han
From: |
David Hildenbrand |
Subject: |
[qemu-s390x] [PATCH v2 04/15] s390x/tcg: Fix parts of IEEE exception handling |
Date: |
Wed, 13 Feb 2019 15:33:11 +0100 |
Many things are wrong and some parts cannot be fixed yet. Fix what we
can fix easily and add two FIXMEs:
The fpc flags are not updated in case an exception is actually injected.
Inexact exceptions have to be handled separately, as they are the only
exceptions that can coexist with underflows and overflows.
I reread the horribly complicated chapters in the PoP at least 5 times
and hope I got it right.
For references:
- z14 PoP, 9-18, "IEEE Exceptions"
- z14 PoP, 19-9, Figure 19-8
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
---
target/s390x/fpu_helper.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c
index de02cf792d..dcad9c367a 100644
--- a/target/s390x/fpu_helper.c
+++ b/target/s390x/fpu_helper.c
@@ -63,13 +63,39 @@ static void handle_exceptions(CPUS390XState *env, uintptr_t
retaddr)
env->fpu_status.float_exception_flags = 0;
s390_exc = s390_softfloat_exc_to_ieee(qemu_exc);
- /* Install the exceptions that we raised. */
- env->fpc |= s390_exc << 16;
+ /*
+ * FIXME:
+ * 1. Right now, all inexact conditions are inidicated as
+ * "truncated" (0) and never as "incremented" (1) in the DXC.
+ * 2. Only traps due to invalid/divbyzero are suppressing. Other traps
+ * are completing, meaning the target register has to be written!
+ * This, however will mean that we have to write the register before
+ * triggering the trap - impossible right now.
+ */
+
+ /*
+ * invalid/divbyzero cannot coexist with other conditions.
+ * overflow/underflow however can coexist with inexact, we have to
+ * handle it separatly.
+ */
+ if (s390_exc & ~S390_IEEE_MASK_INEXACT) {
+ if (s390_exc & ~S390_IEEE_MASK_INEXACT & env->fpc >> 24) {
+ /* trap condition - inexact reported along */
+ tcg_s390_data_exception(env, s390_exc, retaddr);
+ }
+ /* nontrap condition - inexact handled differently */
+ env->fpc |= (s390_exc & ~S390_IEEE_MASK_INEXACT) << 16;
+ }
- /* Send signals for enabled exceptions. */
- s390_exc &= env->fpc >> 24;
- if (s390_exc) {
- tcg_s390_data_exception(env, s390_exc, retaddr);
+ /* inexact handling */
+ if (s390_exc & S390_IEEE_MASK_INEXACT) {
+ /* trap condition - overflow/underflow _not_ reported along */
+ if (s390_exc & S390_IEEE_MASK_INEXACT & env->fpc >> 24) {
+ tcg_s390_data_exception(env, s390_exc & S390_IEEE_MASK_INEXACT,
+ retaddr);
+ }
+ /* nontrap condition */
+ env->fpc |= (s390_exc & S390_IEEE_MASK_INEXACT) << 16;
}
}
--
2.17.2
- [qemu-s390x] [PATCH v2 00/15] s390x/tcg: Implement floating-point extension facility, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 02/15] s390x/tcg: Fix rounding from float128 to uint64_t/uin32_t, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 03/15] s390x/tcg: Factor out conversion of softfloat exceptions, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 05/15] s390x/tcg: Hide IEEE underflows in some scenarios, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 06/15] s390x/tcg: Refactor SET FPC AND SIGNAL handling, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 04/15] s390x/tcg: Fix parts of IEEE exception handling,
David Hildenbrand <=
- [qemu-s390x] [PATCH v2 07/15] s390x/tcg: Fix simulated-IEEE exceptions, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 01/15] s390x/tcg: Fix TEST DATA CLASS instructions, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 08/15] s390x/tcg: Handle SET FPC AND LOAD FPC 3-bit BFP rounding modes, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 09/15] s390x/tcg: Check for exceptions in SET BFP ROUNDING MODE, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 10/15] s390x/tcg: Refactor saving/restoring the bfp rounding mode, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 11/15] s390x/tcg: Prepare for IEEE-inexact-exception control (XxC), David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 13/15] s390x/tcg: Implement rounding mode and XxC for LOAD ROUNDED, David Hildenbrand, 2019/02/13
- [qemu-s390x] [PATCH v2 12/15] s390x/tcg: Implement XxC and checks for most FP instructions, David Hildenbrand, 2019/02/13