Patchwork softfloat: Fix shift128Right for shift counts 64..127

login
register
mail settings
Submitter Peter Maydell
Date June 2, 2013, 3:17 p.m.
Message ID <1370186269-24353-1-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/248114/
State New
Headers show

Comments

Peter Maydell - June 2, 2013, 3:17 p.m.
shift128Right would give the wrong result for a shift count
between 64 and 127. This was never noticed because all of
our uses of this function are guaranteed not to use shift
counts in this range.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Found by code inspection. This contribution can be licensed
under either the softfloat-2a or -2b license.

 fpu/softfloat-macros.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Paolo Bonzini - June 3, 2013, 9:14 a.m.
Il 02/06/2013 17:17, Peter Maydell ha scritto:
> shift128Right would give the wrong result for a shift count
> between 64 and 127. This was never noticed because all of
> our uses of this function are guaranteed not to use shift
> counts in this range.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Found by code inspection. This contribution can be licensed
> under either the softfloat-2a or -2b license.
> 
>  fpu/softfloat-macros.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fpu/softfloat-macros.h b/fpu/softfloat-macros.h
> index b5164af..9b09545 100644
> --- a/fpu/softfloat-macros.h
> +++ b/fpu/softfloat-macros.h
> @@ -168,7 +168,7 @@ INLINE void
>          z0 = a0>>count;
>      }
>      else {
> -        z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
> +        z1 = (count < 128) ? (a0 >> (count & 63)) : 0;
>          z0 = 0;
>      }
>      *z1Ptr = z1;
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Anthony Liguori - June 10, 2013, 9:48 p.m.
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/fpu/softfloat-macros.h b/fpu/softfloat-macros.h
index b5164af..9b09545 100644
--- a/fpu/softfloat-macros.h
+++ b/fpu/softfloat-macros.h
@@ -168,7 +168,7 @@  INLINE void
         z0 = a0>>count;
     }
     else {
-        z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
+        z1 = (count < 128) ? (a0 >> (count & 63)) : 0;
         z0 = 0;
     }
     *z1Ptr = z1;