[Qemu-devel] [PATCH v5 01/28] fpu/softfloat: Fix conversion from uint64 to float128

Richard Henderson posted 28 patches 7 years, 5 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v5 01/28] fpu/softfloat: Fix conversion from uint64 to float128
Posted by Richard Henderson 7 years, 5 months ago
From: Petr Tesarik <ptesarik@suse.com>

The significand is passed to normalizeRoundAndPackFloat128() as high
first, low second. The current code passes the integer first, so the
result is incorrectly shifted left by 64 bits.

This bug affects the emulation of s390x instruction CXLGBR (convert
from logical 64-bit binary-integer operand to extended BFP result).

Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
Message-Id: <20180511071052.1443-1-ptesarik@suse.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 fpu/softfloat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index bc0f52fa54..d07419324a 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3147,7 +3147,7 @@ float128 uint64_to_float128(uint64_t a, float_status *status)
     if (a == 0) {
         return float128_zero;
     }
-    return normalizeRoundAndPackFloat128(0, 0x406E, a, 0, status);
+    return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status);
 }
 
 
-- 
2.17.0


Re: [Qemu-devel] [PATCH v5 01/28] fpu/softfloat: Fix conversion from uint64 to float128
Posted by Alex Bennée 7 years, 5 months ago
Richard Henderson <richard.henderson@linaro.org> writes:

> From: Petr Tesarik <ptesarik@suse.com>
>
> The significand is passed to normalizeRoundAndPackFloat128() as high
> first, low second. The current code passes the integer first, so the
> result is incorrectly shifted left by 64 bits.
>
> This bug affects the emulation of s390x instruction CXLGBR (convert
> from logical 64-bit binary-integer operand to extended BFP result).
>
> Cc: qemu-stable@nongnu.org
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> Message-Id: <20180511071052.1443-1-ptesarik@suse.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  fpu/softfloat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index bc0f52fa54..d07419324a 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -3147,7 +3147,7 @@ float128 uint64_to_float128(uint64_t a, float_status *status)
>      if (a == 0) {
>          return float128_zero;
>      }
> -    return normalizeRoundAndPackFloat128(0, 0x406E, a, 0, status);
> +    return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status);

This brings back memories :-/

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

--
Alex Bennée