Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753554AbdGXKjY (ORCPT ); Mon, 24 Jul 2017 06:39:24 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:8905 "EHLO imgpgp01.kl.imgtec.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751900AbdGXKjQ (ORCPT ); Mon, 24 Jul 2017 06:39:16 -0400 X-PGP-Universal: processed; by imgpgp01.kl.imgtec.org on Mon, 24 Jul 2017 12:50:28 +0100 Date: Mon, 24 Jul 2017 11:39:14 +0100 From: James Hogan To: Aleksandar Markovic CC: , Aleksandar Markovic , Douglas Leung , Miodrag Dinic , Goran Ferenc , , Paul Burton , Petar Jovanovic , Raghu Gandham , Ralf Baechle Subject: Re: [PATCH v3 12/16] MIPS: math-emu: .: Fix some cases of infinite inputs Message-ID: <20170724103914.GQ6973@jhogan-linux.le.imgtec.org> References: <1500646206-2436-1-git-send-email-aleksandar.markovic@rt-rk.com> <1500646206-2436-13-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6KCWwYHA2nAj8wHB" Content-Disposition: inline In-Reply-To: <1500646206-2436-13-git-send-email-aleksandar.markovic@rt-rk.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [192.168.154.110] X-ESG-ENCRYPT-TAG: 3d264444 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5467 Lines: 140 --6KCWwYHA2nAj8wHB Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 21, 2017 at 04:09:10PM +0200, Aleksandar Markovic wrote: > From: Aleksandar Markovic >=20 > Fix the cases of . when any of two multiplicands is > infinity. The correct behavior in such cases is affected by the nature > of third input. Cases of addition of infinities with opposite signs > and subtraction of infinities with same signs may arise and must be > handles separately. Also, the value od flags argument (that determines s/handles/handled/? s/od/of/ > whether the instruction is MADDF or MSUBF) affects the outcome. >=20 > The relevant examples: >=20 > MADDF.S fd,fs,ft: > If fs contains +inf, ft contains +inf, and fd contains -inf, fd is > going to contain indef (without this patch, it used to contain > -inf). > > MSUBF.S fd,fs,ft: > If fs contains +inf, ft contains 1.0, and fd contains +0.0, fd is > going to contain -inf (without this patch, it used to contain +inf). >=20 Same fixes/stable notes as previous patch. > Signed-off-by: Douglas Leung > Signed-off-by: Miodrag Dinic > Signed-off-by: Goran Ferenc > Signed-off-by: Aleksandar Markovic Reviewed-by: James Hogan Cheers James > --- > arch/mips/math-emu/dp_maddf.c | 21 ++++++++++++++++++++- > arch/mips/math-emu/sp_maddf.c | 21 ++++++++++++++++++++- > 2 files changed, 40 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c > index 4f2e783..45f815d 100644 > --- a/arch/mips/math-emu/dp_maddf.c > +++ b/arch/mips/math-emu/dp_maddf.c > @@ -85,7 +85,26 @@ static union ieee754dp _dp_maddf(union ieee754dp z, un= ion ieee754dp x, > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): > - return ieee754dp_inf(xs ^ ys); > + if ((zc =3D=3D IEEE754_CLASS_INF) && > + ((!(flags & maddf_negate_product) && (zs !=3D (xs ^ ys))) || > + ((flags & maddf_negate_product) && (zs =3D=3D (xs ^ ys))))) { > + /* > + * Cases of addition of infinities with opposite signs > + * or subtraction of infinities with same signs. > + */ > + ieee754_setcx(IEEE754_INVALID_OPERATION); > + return ieee754dp_indef(); > + } > + /* > + * z is here either not infinity, or infinity of the same sign > + * as maddf_negate_product * x * y. So, the result must be > + * infinity, and its sign is determined only by the value of > + * (flags & maddf_negate_product) and the signs of x and y. > + */ > + if (flags & maddf_negate_product) > + return ieee754dp_inf(1 ^ (xs ^ ys)); > + else > + return ieee754dp_inf(xs ^ ys); > =20 > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): > diff --git a/arch/mips/math-emu/sp_maddf.c b/arch/mips/math-emu/sp_maddf.c > index 9fd2035..76856d7 100644 > --- a/arch/mips/math-emu/sp_maddf.c > +++ b/arch/mips/math-emu/sp_maddf.c > @@ -86,7 +86,26 @@ static union ieee754sp _sp_maddf(union ieee754sp z, un= ion ieee754sp x, > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): > - return ieee754sp_inf(xs ^ ys); > + if ((zc =3D=3D IEEE754_CLASS_INF) && > + ((!(flags & maddf_negate_product) && (zs !=3D (xs ^ ys))) || > + ((flags & maddf_negate_product) && (zs =3D=3D (xs ^ ys))))) { > + /* > + * Cases of addition of infinities with opposite signs > + * or subtraction of infinities with same signs. > + */ > + ieee754_setcx(IEEE754_INVALID_OPERATION); > + return ieee754sp_indef(); > + } > + /* > + * z is here either not infinity, or infinity of the same sign > + * as maddf_negate_product * x * y. So, the result must be > + * infinity, and its sign is determined only by the value of > + * (flags & maddf_negate_product) and the signs of x and y. > + */ > + if (flags & maddf_negate_product) > + return ieee754sp_inf(1 ^ (xs ^ ys)); > + else > + return ieee754sp_inf(xs ^ ys); > =20 > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): > --=20 > 2.7.4 >=20 --6KCWwYHA2nAj8wHB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd80NauSabkiESfLYbAtpk944dnoFAll1zlEACgkQbAtpk944 dnrAAxAAlJ+g+wpxNjMGliaZUbO8dKzChBnp7upYuC/2O3mLxD05rgrCPfeqlj4Z /ShrSwgWeO20dugVyGyJ7wlKryYBw6z0Jk83VfscWk5wdyGmVhyfXCUvvf5oyhNL XpQoRiePdg00n3m/nFWTU3Py4R4dsk1E784wQnsZwUyUHXbT9UwTJrYktAqIBJEN iECuBcndPFWbS8fLbX8SfYlHcMtFH+KSKh7sBdJMYwerU00d6I2fOPnzX2szEWBy EE8sghoETiBKMUCRtd4JwVjGXBDzVj4EFCxPzTLXRcq/qocS+fN1C+33hKDM9zpS 2MB+UuBx8dll75FtAOWpY7wpTdmbN/ZDKYI+WbvWMwtshkT4HZMuPkzA4HGlMW4h 2YUVRJUVMiI0116+bO6P9Sw1c0evFytYncZahzN1ipK5OQPegxQRz/RLAEygzI9q K3zCrIzKlzqRhf9ohUQORTelHj+WW12TA2yya3wBgN/4K3OGMFozdh/4SsPv8xpV oZX17o+YkF12rlBueNQzthon+aZVeRAo7l+kwjub4WD5smSWBNI1Zs6SzdFjF25O LP0D/wnlfrvlptUjv9ZDihVrlkABi3SF8XFYt70psy8+/nHDbqGcduKGvpRxwiRH dbplNF2myc4OB0c51TRyAhhI6lTDoI9BPIRZP8bfE66e97oYfRI= =JJ5B -----END PGP SIGNATURE----- --6KCWwYHA2nAj8wHB--