Changeset View
Changeset View
Standalone View
Standalone View
src/hwfeatures.c
Show All 36 Lines | |||||
/* A table to map hardware features to a string. */ | /* A table to map hardware features to a string. */ | ||||
static struct | static struct | ||||
{ | { | ||||
unsigned int flag; | unsigned int flag; | ||||
const char *desc; | const char *desc; | ||||
} hwflist[] = | } hwflist[] = | ||||
{ | { | ||||
#if defined(HAVE_CPU_ARCH_X86) | |||||
{ HWF_PADLOCK_RNG, "padlock-rng" }, | { HWF_PADLOCK_RNG, "padlock-rng" }, | ||||
{ HWF_PADLOCK_AES, "padlock-aes" }, | { HWF_PADLOCK_AES, "padlock-aes" }, | ||||
{ HWF_PADLOCK_SHA, "padlock-sha" }, | { HWF_PADLOCK_SHA, "padlock-sha" }, | ||||
{ HWF_PADLOCK_MMUL, "padlock-mmul"}, | { HWF_PADLOCK_MMUL, "padlock-mmul"}, | ||||
{ HWF_INTEL_CPU, "intel-cpu" }, | { HWF_INTEL_CPU, "intel-cpu" }, | ||||
{ HWF_INTEL_FAST_SHLD, "intel-fast-shld" }, | { HWF_INTEL_FAST_SHLD, "intel-fast-shld" }, | ||||
{ HWF_INTEL_BMI2, "intel-bmi2" }, | { HWF_INTEL_BMI2, "intel-bmi2" }, | ||||
{ HWF_INTEL_SSSE3, "intel-ssse3" }, | { HWF_INTEL_SSSE3, "intel-ssse3" }, | ||||
{ HWF_INTEL_SSE4_1, "intel-sse4.1" }, | { HWF_INTEL_SSE4_1, "intel-sse4.1" }, | ||||
{ HWF_INTEL_PCLMUL, "intel-pclmul" }, | { HWF_INTEL_PCLMUL, "intel-pclmul" }, | ||||
{ HWF_INTEL_AESNI, "intel-aesni" }, | { HWF_INTEL_AESNI, "intel-aesni" }, | ||||
{ HWF_INTEL_RDRAND, "intel-rdrand" }, | { HWF_INTEL_RDRAND, "intel-rdrand" }, | ||||
{ HWF_INTEL_AVX, "intel-avx" }, | { HWF_INTEL_AVX, "intel-avx" }, | ||||
{ HWF_INTEL_AVX2, "intel-avx2" }, | { HWF_INTEL_AVX2, "intel-avx2" }, | ||||
{ HWF_INTEL_FAST_VPGATHER, "intel-fast-vpgather" }, | { HWF_INTEL_FAST_VPGATHER, "intel-fast-vpgather" }, | ||||
{ HWF_INTEL_RDTSC, "intel-rdtsc" }, | { HWF_INTEL_RDTSC, "intel-rdtsc" }, | ||||
{ HWF_INTEL_SHAEXT, "intel-shaext" }, | { HWF_INTEL_SHAEXT, "intel-shaext" }, | ||||
#elif defined(HAVE_CPU_ARCH_ARM) | |||||
{ HWF_ARM_NEON, "arm-neon" }, | { HWF_ARM_NEON, "arm-neon" }, | ||||
{ HWF_ARM_AES, "arm-aes" }, | { HWF_ARM_AES, "arm-aes" }, | ||||
{ HWF_ARM_SHA1, "arm-sha1" }, | { HWF_ARM_SHA1, "arm-sha1" }, | ||||
{ HWF_ARM_SHA2, "arm-sha2" }, | { HWF_ARM_SHA2, "arm-sha2" }, | ||||
{ HWF_ARM_PMULL, "arm-pmull" } | { HWF_ARM_PMULL, "arm-pmull" }, | ||||
#elif defined(HAVE_CPU_ARCH_PPC) | |||||
{ HWF_PPC_VCRYPTO, "ppc-crypto" }, | |||||
#endif | |||||
}; | }; | ||||
/* A bit vector with the hardware features which shall not be used. | /* A bit vector with the hardware features which shall not be used. | ||||
This variable must be set prior to any initialization. */ | This variable must be set prior to any initialization. */ | ||||
static unsigned int disabled_hw_features; | static unsigned int disabled_hw_features; | ||||
/* A bit vector describing the hardware features currently | /* A bit vector describing the hardware features currently | ||||
available. */ | available. */ | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | if (fips_mode ()) | ||||
return; /* Hardware support is not to be evaluated. */ | return; /* Hardware support is not to be evaluated. */ | ||||
parse_hwf_deny_file (); | parse_hwf_deny_file (); | ||||
#if defined (HAVE_CPU_ARCH_X86) | #if defined (HAVE_CPU_ARCH_X86) | ||||
{ | { | ||||
hw_features = _gcry_hwf_detect_x86 (); | hw_features = _gcry_hwf_detect_x86 (); | ||||
} | } | ||||
#endif /* HAVE_CPU_ARCH_X86 */ | #elif defined (HAVE_CPU_ARCH_ARM) | ||||
#if defined (HAVE_CPU_ARCH_ARM) | |||||
{ | { | ||||
hw_features = _gcry_hwf_detect_arm (); | hw_features = _gcry_hwf_detect_arm (); | ||||
} | } | ||||
#endif /* HAVE_CPU_ARCH_ARM */ | #elif defined (HAVE_CPU_ARCH_PPC) | ||||
{ | |||||
hw_features = _gcry_hwf_detect_ppc (); | |||||
} | |||||
#endif | |||||
hw_features &= ~disabled_hw_features; | hw_features &= ~disabled_hw_features; | ||||
} | } |