[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.0.2 15/22] target/arm: Fix FJCVTZS vs flush-to-zero
From: |
Michael Tokarev |
Subject: |
[Stable-9.0.2 15/22] target/arm: Fix FJCVTZS vs flush-to-zero |
Date: |
Fri, 5 Jul 2024 00:00:45 +0300 |
From: Richard Henderson <richard.henderson@linaro.org>
Input denormals cause the Javascript inexact bit
(output to Z) to be set.
Cc: qemu-stable@nongnu.org
Fixes: 6c1f6f2733a ("target/arm: Implement ARMv8.3-JSConv")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2375
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20240625183536.1672454-4-richard.henderson@linaro.org
[PMM: fixed hardcoded tab in test case]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 7619129f0d4a14d918227c5c47ad7433662e9ccc)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 3e5e37abbe..ff59bc5522 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -1121,8 +1121,8 @@ const FloatRoundMode arm_rmode_to_sf_map[] = {
uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus)
{
float_status *status = vstatus;
- uint32_t inexact, frac;
- uint32_t e_old, e_new;
+ uint32_t frac, e_old, e_new;
+ bool inexact;
e_old = get_float_exception_flags(status);
set_float_exception_flags(0, status);
@@ -1130,13 +1130,13 @@ uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus)
e_new = get_float_exception_flags(status);
set_float_exception_flags(e_old | e_new, status);
- if (value == float64_chs(float64_zero)) {
- /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */
- inexact = 1;
- } else {
- /* Normal inexact or overflow or NaN */
- inexact = e_new & (float_flag_inexact | float_flag_invalid);
- }
+ /* Normal inexact, denormal with flush-to-zero, or overflow or NaN */
+ inexact = e_new & (float_flag_inexact |
+ float_flag_input_denormal |
+ float_flag_invalid);
+
+ /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */
+ inexact |= value == float64_chs(float64_zero);
/* Pack the result and the env->ZF representation of Z together. */
return deposit64(frac, 32, 32, inexact);
diff --git a/tests/tcg/aarch64/Makefile.target
b/tests/tcg/aarch64/Makefile.target
index 70d728ae9a..4ecbca6a41 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -41,8 +41,9 @@ endif
# Pauth Tests
ifneq ($(CROSS_CC_HAS_ARMV8_3),)
-AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
+AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 test-2375
pauth-%: CFLAGS += -march=armv8.3-a
+test-2375: CFLAGS += -march=armv8.3-a
run-pauth-1: QEMU_OPTS += -cpu max
run-pauth-2: QEMU_OPTS += -cpu max
# Choose a cpu with FEAT_Pauth but without FEAT_FPAC for pauth-[45].
diff --git a/tests/tcg/aarch64/test-2375.c b/tests/tcg/aarch64/test-2375.c
new file mode 100644
index 0000000000..84c7e7de71
--- /dev/null
+++ b/tests/tcg/aarch64/test-2375.c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (c) 2024 Linaro Ltd */
+/* See https://gitlab.com/qemu-project/qemu/-/issues/2375 */
+
+#include <assert.h>
+
+int main(void)
+{
+ int r, z;
+
+ asm("msr fpcr, %2\n\t"
+ "fjcvtzs %w0, %d3\n\t"
+ "cset %1, eq"
+ : "=r"(r), "=r"(z)
+ : "r"(0x01000000L), /* FZ = 1 */
+ "w"(0xfcff00L)); /* denormal */
+
+ assert(r == 0);
+ assert(z == 0);
+ return 0;
+}
--
2.39.2
- [Stable-9.0.2 06/22] stdvga: fix screen blanking, (continued)
- [Stable-9.0.2 06/22] stdvga: fix screen blanking, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 07/22] accel/tcg: Fix typo causing tb->page_addr[1] to not be recorded, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 05/22] hw/audio/virtio-snd: Always use little endian audio format, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 08/22] linux-user: Make TARGET_NR_setgroups affect only the current thread, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 09/22] target/sparc: use signed denominator in sdiv helper, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 10/22] tcg/loongarch64: Fix tcg_out_movi vs some pcrel pointers, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 12/22] tests: Update our CI to use CentOS Stream 9 instead of 8, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 11/22] migration: Fix file migration with fdset, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 14/22] target/arm: Fix VCMLA Dd, Dn, Dm[idx], Michael Tokarev, 2024/07/04
- [Stable-9.0.2 13/22] i386/cpu: fixup number of addressable IDs for processor cores in the physical package, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 15/22] target/arm: Fix FJCVTZS vs flush-to-zero,
Michael Tokarev <=
- [Stable-9.0.2 19/22] iotests/244: Don't store data-file with protocol in image, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 18/22] qcow2: Don't open data_file with BDRV_O_NO_IO, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 16/22] hw/core: allow parameter=1 for SMP topology on any machine, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 17/22] tests: add testing of parameter=1 for SMP topology, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 20/22] iotests/270: Don't store data-file with json: prefix in image, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 21/22] block: Parse filenames only when explicitly requested, Michael Tokarev, 2024/07/04
- [Stable-9.0.2 22/22] tcg/optimize: Fix TCG_COND_TST* simplification of setcond2, Michael Tokarev, 2024/07/04