lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170724120604.GS6973@jhogan-linux.le.imgtec.org>
Date:   Mon, 24 Jul 2017 13:06:04 +0100
From:   James Hogan <james.hogan@...tec.com>
To:     Aleksandar Markovic <aleksandar.markovic@...rk.com>
CC:     <linux-mips@...ux-mips.org>,
        Aleksandar Markovic <aleksandar.markovic@...tec.com>,
        Miodrag Dinic <miodrag.dinic@...tec.com>,
        Goran Ferenc <goran.ferenc@...tec.com>,
        Douglas Leung <douglas.leung@...tec.com>,
        <linux-kernel@...r.kernel.org>,
        Paul Burton <paul.burton@...tec.com>,
        Petar Jovanovic <petar.jovanovic@...tec.com>,
        Raghu Gandham <raghu.gandham@...tec.com>,
        Ralf Baechle <ralf@...ux-mips.org>
Subject: Re: [PATCH v3 16/16] MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Clean up
 maddf_flags enumeration

On Fri, Jul 21, 2017 at 04:09:14PM +0200, Aleksandar Markovic wrote:
> From: Aleksandar Markovic <aleksandar.markovic@...tec.com>
> 
> Fix definition and usage of maddf_flags enumeration. Avoid duplicate
> definition and apply more common capitalization.
> 
> This patch does not change any scenario. It just make MADDF and MSUBF
> emulation code more readable and easier to maintain, and hopefully
> also prevents future bugs.
> 
> Signed-off-by: Miodrag Dinic <miodrag.dinic@...tec.com>
> Signed-off-by: Goran Ferenc <goran.ferenc@...tec.com>
> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@...tec.com>

Reviewed-by: James Hogan <james.hogan@...tec.com>

Cheers
James

> ---
>  arch/mips/math-emu/dp_maddf.c   | 19 ++++++++-----------
>  arch/mips/math-emu/ieee754int.h |  4 ++++
>  arch/mips/math-emu/sp_maddf.c   | 19 ++++++++-----------
>  3 files changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c
> index 68b55c8..d36f01a 100644
> --- a/arch/mips/math-emu/dp_maddf.c
> +++ b/arch/mips/math-emu/dp_maddf.c
> @@ -14,9 +14,6 @@
>  
>  #include "ieee754dp.h"
>  
> -enum maddf_flags {
> -	maddf_negate_product	= 1 << 0,
> -};
>  
>  /* 128 bits shift right logical with rounding. */
>  void srl128(u64 *hptr, u64 *lptr, int count)
> @@ -111,8 +108,8 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
>  	case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM):
>  	case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
>  		if ((zc == IEEE754_CLASS_INF) &&
> -		    ((!(flags & maddf_negate_product) && (zs != (xs ^ ys))) ||
> -		     ((flags & maddf_negate_product) && (zs == (xs ^ ys))))) {
> +		    ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) ||
> +		     ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) {
>  			/*
>  			 * Cases of addition of infinities with opposite signs
>  			 * or subtraction of infinities with same signs.
> @@ -124,9 +121,9 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
>  		 * 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.
> +		 * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y.
>  		 */
> -		if (flags & maddf_negate_product)
> +		if (flags & MADDF_NEGATE_PRODUCT)
>  			return ieee754dp_inf(1 ^ (xs ^ ys));
>  		else
>  			return ieee754dp_inf(xs ^ ys);
> @@ -140,8 +137,8 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
>  			return ieee754dp_inf(zs);
>  		/* Handle cases +0 + (-0) and similar ones. */
>  		if (zc == IEEE754_CLASS_ZERO) {
> -			if ((!(flags & maddf_negate_product) && (zs == (xs ^ ys))) ||
> -			    ((flags & maddf_negate_product) && (zs != (xs ^ ys))))
> +			if ((!(flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))) ||
> +			    ((flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))))
>  				return z;
>  			else
>  				return ieee754dp_zero(ieee754_csr.rm == FPU_CSR_RD);
> @@ -184,7 +181,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
>  
>  	re = xe + ye;
>  	rs = xs ^ ys;
> -	if (flags & maddf_negate_product)
> +	if (flags & MADDF_NEGATE_PRODUCT)
>  		rs ^= 1;
>  
>  	/* shunt to top of word */
> @@ -335,5 +332,5 @@ union ieee754dp ieee754dp_maddf(union ieee754dp z, union ieee754dp x,
>  union ieee754dp ieee754dp_msubf(union ieee754dp z, union ieee754dp x,
>  				union ieee754dp y)
>  {
> -	return _dp_maddf(z, x, y, maddf_negate_product);
> +	return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
>  }
> diff --git a/arch/mips/math-emu/ieee754int.h b/arch/mips/math-emu/ieee754int.h
> index 8bc2f69..dd2071f 100644
> --- a/arch/mips/math-emu/ieee754int.h
> +++ b/arch/mips/math-emu/ieee754int.h
> @@ -26,6 +26,10 @@
>  
>  #define CLPAIR(x, y)	((x)*6+(y))
>  
> +enum maddf_flags {
> +	MADDF_NEGATE_PRODUCT	= 1 << 0,
> +};
> +
>  static inline void ieee754_clearcx(void)
>  {
>  	ieee754_csr.cx = 0;
> diff --git a/arch/mips/math-emu/sp_maddf.c b/arch/mips/math-emu/sp_maddf.c
> index b380189..715cc47 100644
> --- a/arch/mips/math-emu/sp_maddf.c
> +++ b/arch/mips/math-emu/sp_maddf.c
> @@ -14,9 +14,6 @@
>  
>  #include "ieee754sp.h"
>  
> -enum maddf_flags {
> -	maddf_negate_product	= 1 << 0,
> -};
>  
>  static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
>  				 union ieee754sp y, enum maddf_flags flags)
> @@ -81,8 +78,8 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
>  	case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM):
>  	case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
>  		if ((zc == IEEE754_CLASS_INF) &&
> -		    ((!(flags & maddf_negate_product) && (zs != (xs ^ ys))) ||
> -		     ((flags & maddf_negate_product) && (zs == (xs ^ ys))))) {
> +		    ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) ||
> +		     ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) {
>  			/*
>  			 * Cases of addition of infinities with opposite signs
>  			 * or subtraction of infinities with same signs.
> @@ -94,9 +91,9 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
>  		 * 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.
> +		 * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y.
>  		 */
> -		if (flags & maddf_negate_product)
> +		if (flags & MADDF_NEGATE_PRODUCT)
>  			return ieee754sp_inf(1 ^ (xs ^ ys));
>  		else
>  			return ieee754sp_inf(xs ^ ys);
> @@ -110,8 +107,8 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
>  			return ieee754sp_inf(zs);
>  		/* Handle cases +0 + (-0) and similar ones. */
>  		if (zc == IEEE754_CLASS_ZERO) {
> -			if ((!(flags & maddf_negate_product) && (zs == (xs ^ ys))) ||
> -			    ((flags & maddf_negate_product) && (zs != (xs ^ ys))))
> +			if ((!(flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))) ||
> +			    ((flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))))
>  				return z;
>  			else
>  				return ieee754sp_zero(ieee754_csr.rm == FPU_CSR_RD);
> @@ -156,7 +153,7 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
>  
>  	re = xe + ye;
>  	rs = xs ^ ys;
> -	if (flags & maddf_negate_product)
> +	if (flags & MADDF_NEGATE_PRODUCT)
>  		rs ^= 1;
>  
>  	/* Multiple 24 bit xm and ym to give 48 bit results */
> @@ -255,5 +252,5 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
>  union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x,
>  				union ieee754sp y)
>  {
> -	return _sp_maddf(z, x, y, maddf_negate_product);
> +	return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
>  }
> -- 
> 2.7.4
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ