cipher/sha1-avx-amd64.S is for AVX (not AVX2)?

Jussi Kivilinna jussi.kivilinna at iki.fi
Wed Jun 29 13:57:30 CEST 2016


Hello,

On 2016-06-29 03:40, NIIBE Yutaka wrote:
> Hello,
> 
> While looking at this issue:
> 	https://bugs.gnupg.org/gnupg/issue2396
> 
> I found a problem in cipher/sha1-avx-amd64.S.
> 
> While I don't have knowledge of those instructions, it seems for me
> that something like following is needed, for a platform where AVX2 is
> not supported.
> 
> Jussi, could you please confirm?

Yes, '#if' clause in sha1-avx-amd64.S is wrong.

> 
> diff --git a/cipher/sha1-avx-amd64.S b/cipher/sha1-avx-amd64.S
> index 062a45b..70efe95 100644
> --- a/cipher/sha1-avx-amd64.S
> +++ b/cipher/sha1-avx-amd64.S
> @@ -31,8 +31,8 @@
> 
>  #if (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
>       defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && \
> -    defined(HAVE_GCC_INLINE_ASM_BMI2) && \
> -    defined(HAVE_GCC_INLINE_ASM_AVX2) && defined(USE_SHA1)
> +    defined(HAVE_INTEL_SYNTAX_PLATFORM_AS) && \
> +    defined(HAVE_GCC_INLINE_ASM_AVX) && defined(USE_SHA1)

This should be changed to match '#define USE_AVX' part in
'sha1.c':

#if (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
     defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && \
    defined(HAVE_GCC_INLINE_ASM_AVX) && defined(USE_SHA1)

I can make the change on weekend.

-Jussi

> 
>  #ifdef __PIC__
>  #  define RIP (%rip)
> 



More information about the Gcrypt-devel mailing list