From 3e934b99c81800f8699f4c958a2559e4a774b473 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 30 Apr 2020 07:22:48 -0400 Subject: [PATCH] softfloat: Fix BAD_SHIFT from normalizeFloatx80Subnormal All other calls to normalize*Subnormal detect zero input before the call -- this is the only outlier. This case can happen with +0.0 + +0.0 = +0.0 or -0.0 + -0.0 = -0.0, so return a zero of the correct sign. Reported-by: Coverity (CID 1421991) Backports commit 2f311075b7a74124098effc72290767b02869561 from qemu --- qemu/fpu/softfloat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu/fpu/softfloat.c b/qemu/fpu/softfloat.c index 241da0b1..13a01713 100644 --- a/qemu/fpu/softfloat.c +++ b/qemu/fpu/softfloat.c @@ -5818,6 +5818,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign, zSig1 = 0; zSig0 = aSig + bSig; if ( aExp == 0 ) { + if (zSig0 == 0) { + return packFloatx80(zSign, 0, 0); + } normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 ); goto roundAndPack; }