[PATCH 1/3] hwf-ppc: add detection for PowerISA 3.00
Shawn Landden
shawn at git.icu
Sat Aug 31 04:10:26 CEST 2019
30.08.2019, 18:50, "Jussi Kivilinna via Gcrypt-devel" <gcrypt-devel at gnupg.org>:
> * src/g10lib.h (HWF_PPC_ARCH_3_00): New.
> * src/hwf-ppc.c (feature_map_s): Remove unused 'feature_match'.
> (PPC_FEATURE2_ARCH_3_00): New.
> (ppc_features, get_hwcap): Add PowerISA 3.00.
Ahh, I see that Power 9 has different performance characteristics. I was wondering what this was for. I am working on GHASH now.
> * src/hwfeatures.c (hwflist): Rename "ppc-crypto" to "ppc-vcrypto"; Add
> "ppc-arch_3_00".
> --
>
> Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
> ---
> 0 files changed
>
> diff --git a/src/g10lib.h b/src/g10lib.h
> index 41e18c137..bbdaf58be 100644
> --- a/src/g10lib.h
> +++ b/src/g10lib.h
> @@ -237,6 +237,7 @@ char **_gcry_strtokenize (const char *string, const char *delim);
> #define HWF_ARM_PMULL (1 << 21)
>
> #define HWF_PPC_VCRYPTO (1 << 22)
> +#define HWF_PPC_ARCH_3_00 (1 << 23)
>
> gpg_err_code_t _gcry_disable_hw_feature (const char *name);
> void _gcry_detect_hw_features (void);
> diff --git a/src/hwf-ppc.c b/src/hwf-ppc.c
> index 1bf2edf70..2ed60c0f1 100644
> --- a/src/hwf-ppc.c
> +++ b/src/hwf-ppc.c
> @@ -70,7 +70,6 @@ struct feature_map_s
> {
> unsigned int hwcap_flag;
> unsigned int hwcap2_flag;
> - const char *feature_match;
> unsigned int hwf_flag;
> };
>
> @@ -87,12 +86,16 @@ struct feature_map_s
> #ifndef PPC_FEATURE2_VEC_CRYPTO
> # define PPC_FEATURE2_VEC_CRYPTO 0x02000000
> #endif
> +#ifndef PPC_FEATURE2_ARCH_3_00
> +# define PPC_FEATURE2_ARCH_3_00 0x00800000
> +#endif
>
> static const struct feature_map_s ppc_features[] =
> {
> #ifdef ENABLE_PPC_CRYPTO_SUPPORT
> - { 0, PPC_FEATURE2_VEC_CRYPTO, " crypto", HWF_PPC_VCRYPTO },
> + { 0, PPC_FEATURE2_VEC_CRYPTO, HWF_PPC_VCRYPTO },
> #endif
> + { 0, PPC_FEATURE2_ARCH_3_00, HWF_PPC_ARCH_3_00 },
> };
> #endif
>
> @@ -114,22 +117,23 @@ get_hwcap(unsigned int *hwcap, unsigned int *hwcap2)
> }
>
> #if 0 // TODO: configure.ac detection for __builtin_cpu_supports
> -#if defined(__GLIBC__) && defined(__GNUC__)
> -#if __GNUC__ >= 6
> - /* Returns 0 if glibc support doesn't exist, so we can
> - * only trust positive results. This function will need updating
> - * if we ever need more than one cpu feature.
> - */
> - // TODO: fix, false if ENABLE_PPC_CRYPTO_SUPPORT
> - if (sizeof(ppc_features)/sizeof(ppc_features[0]) == 0) {
> - if (__builtin_cpu_supports("vcrypto")) {
> - stored_hwcap = 0;
> - stored_hwcap2 = PPC_FEATURE2_VEC_CRYPTO;
> - hwcap_initialized = 1;
> - return 0;
> + // TODO: move to 'detect_ppc_builtin_cpu_supports'
> +#if defined(__GLIBC__) && defined(__GNUC__) && __GNUC__ >= 6
> + /* __builtin_cpu_supports returns 0 if glibc support doesn't exist, so
> + * we can only trust positive results. */
> +#ifdef ENABLE_PPC_CRYPTO_SUPPORT
> + if (__builtin_cpu_supports("vcrypto")) /* TODO: Configure.ac */
> + {
> + stored_hwcap2 |= PPC_FEATURE2_VEC_CRYPTO;
> + hwcap_initialized = 1;
> }
> - }
> #endif
> +
> + if (__builtin_cpu_supports("arch_3_00")) /* TODO: Configure.ac */
> + {
> + stored_hwcap2 |= PPC_FEATURE2_ARCH_3_00;
> + hwcap_initialized = 1;
> + }
> #endif
> #endif
>
> @@ -188,6 +192,7 @@ get_hwcap(unsigned int *hwcap, unsigned int *hwcap2)
> err = 0;
>
> fclose(f);
> +
> *hwcap = stored_hwcap;
> *hwcap2 = stored_hwcap2;
> return err;
> diff --git a/src/hwfeatures.c b/src/hwfeatures.c
> index fe5137538..1021bd3b1 100644
> --- a/src/hwfeatures.c
> +++ b/src/hwfeatures.c
> @@ -67,7 +67,8 @@ static struct
> { HWF_ARM_SHA2, "arm-sha2" },
> { HWF_ARM_PMULL, "arm-pmull" },
> #elif defined(HAVE_CPU_ARCH_PPC)
> - { HWF_PPC_VCRYPTO, "ppc-crypto" },
> + { HWF_PPC_VCRYPTO, "ppc-vcrypto" },
> + { HWF_PPC_ARCH_3_00, "ppc-arch_3_00" },
> #endif
> };
>
> _______________________________________________
> Gcrypt-devel mailing list
> Gcrypt-devel at gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
--
Shawn Landden
More information about the Gcrypt-devel
mailing list