[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 20/27] s390x/tcg: Handle SET FPC AND LOAD FPC 3-bit B
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 20/27] s390x/tcg: Handle SET FPC AND LOAD FPC 3-bit BFP rounding modes |
Date: |
Mon, 4 Mar 2019 13:02:03 +0100 |
From: David Hildenbrand <address@hidden>
We already forward the 3 bits correctly in the translation functions. We
also have to handle them properly and check for specification
exceptions.
Setting an invalid rounding mode (BFP only, all DFP rounding modes)
results in a specification exception. Setting unassigned bits in the
fpc, results in a specification exception.
This fixes LOAD FPC (AND SIGNAL), SET FPC (AND SIGNAL). Also for,
SET BFP ROUNDING MODE, 3-bit rounding mode is now explicitly checked.
Note: TCG_CALL_NO_WG is required for sfpc handler, as we now inject
exceptions.
We won't be modeling abscence of the "floating-point extension facility"
for now, not necessary as most take the facility for granted without
checking.
z14 PoP, 9-23, "LOAD FPC"
When the floating-point extension facility is
installed, bits 29-31 of the second operand must
specify a valid BFP rounding mode and bits 6-7,
14-15, 24, and 28 must be zero; otherwise, a
specification exception is recognized.
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/fpu_helper.c | 22 ++++++++++++++++++----
target/s390x/helper.h | 2 +-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c
index 7508c0748e63..4dc70ec60f60 100644
--- a/target/s390x/fpu_helper.c
+++ b/target/s390x/fpu_helper.c
@@ -753,21 +753,30 @@ uint64_t HELPER(sqxb)(CPUS390XState *env, uint64_t ah,
uint64_t al)
return RET128(ret);
}
-static const int fpc_to_rnd[4] = {
+static const int fpc_to_rnd[8] = {
float_round_nearest_even,
float_round_to_zero,
float_round_up,
- float_round_down
+ float_round_down,
+ -1,
+ -1,
+ -1,
+ float_round_to_odd,
};
/* set fpc */
void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc)
{
+ if (fpc_to_rnd[fpc & 0x7] == -1 || fpc & 0x03030088u ||
+ (!s390_has_feat(S390_FEAT_FLOATING_POINT_EXT) && fpc & 0x4)) {
+ s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC());
+ }
+
/* Install everything in the main FPC. */
env->fpc = fpc;
/* Install the rounding mode in the shadow fpu_status. */
- set_float_rounding_mode(fpc_to_rnd[fpc & 3], &env->fpu_status);
+ set_float_rounding_mode(fpc_to_rnd[fpc & 0x7], &env->fpu_status);
}
/* set fpc and signal */
@@ -776,12 +785,17 @@ void HELPER(sfas)(CPUS390XState *env, uint64_t fpc)
uint32_t signalling = env->fpc;
uint32_t s390_exc;
+ if (fpc_to_rnd[fpc & 0x7] == -1 || fpc & 0x03030088u ||
+ (!s390_has_feat(S390_FEAT_FLOATING_POINT_EXT) && fpc & 0x4)) {
+ s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC());
+ }
+
/*
* FPC is set to the FPC operand with a bitwise OR of the signalling
* flags.
*/
env->fpc = fpc | (signalling & 0x00ff0000);
- set_float_rounding_mode(fpc_to_rnd[fpc & 3], &env->fpu_status);
+ set_float_rounding_mode(fpc_to_rnd[fpc & 0x7], &env->fpu_status);
/*
* If any signaling flag is enabled in the new FPC mask, a
diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index 6260b5049621..a99b067c9c50 100644
--- a/target/s390x/helper.h
+++ b/target/s390x/helper.h
@@ -104,7 +104,7 @@ DEF_HELPER_4(trtr, i32, env, i32, i64, i64)
DEF_HELPER_5(trXX, i32, env, i32, i32, i32, i32)
DEF_HELPER_4(cksm, i64, env, i64, i64, i64)
DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_NO_RWG_SE, i32, env, i32, i64, i64, i64)
-DEF_HELPER_FLAGS_2(sfpc, TCG_CALL_NO_RWG, void, env, i64)
+DEF_HELPER_FLAGS_2(sfpc, TCG_CALL_NO_WG, void, env, i64)
DEF_HELPER_FLAGS_2(sfas, TCG_CALL_NO_WG, void, env, i64)
DEF_HELPER_FLAGS_1(popcnt, TCG_CALL_NO_RWG_SE, i64, i64)
DEF_HELPER_2(stfle, i32, env, i64)
--
2.17.2
- [qemu-s390x] [PULL 09/27] s390x/tcg: Factor out vec_full_reg_offset(), (continued)
- [qemu-s390x] [PULL 09/27] s390x/tcg: Factor out vec_full_reg_offset(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 11/27] s390x/tcg: Implement LOAD LENGTHENED short HFP to long HFP, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 12/27] s390x/tcg: Implement LOAD COUNT TO BLOCK BOUNDARY, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 13/27] s390x/tcg: Fix TEST DATA CLASS instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 14/27] s390x/tcg: Fix rounding from float128 to uint64_t/uint32_t, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 15/27] s390x/tcg: Factor out conversion of softfloat exceptions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 17/27] s390x/tcg: Hide IEEE underflows in some scenarios, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 16/27] s390x/tcg: Fix parts of IEEE exception handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 18/27] s390x/tcg: Refactor SET FPC AND SIGNAL handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 19/27] s390x/tcg: Fix simulated-IEEE exceptions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 20/27] s390x/tcg: Handle SET FPC AND LOAD FPC 3-bit BFP rounding modes,
Cornelia Huck <=
- [qemu-s390x] [PULL 21/27] s390x/tcg: Check for exceptions in SET BFP ROUNDING MODE, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 23/27] s390x/tcg: Prepare for IEEE-inexact-exception control (XxC), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 22/27] s390x/tcg: Refactor saving/restoring the bfp rounding mode, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 26/27] s390x/tcg: Handle all rounding modes overwritten by BFP instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 24/27] s390x/tcg: Implement XxC and checks for most FP instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 25/27] s390x/tcg: Implement rounding mode and XxC for LOAD ROUNDED, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 27/27] s390x: Add floating-point extension facility to "qemu" cpu model, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 03/27] s390x/tcg: Save vregs to extended mchk save area, Cornelia Huck, 2019/03/04
- Re: [qemu-s390x] [PULL 00/27] s390x updates, Peter Maydell, 2019/03/04