2013-10-01 12:34:52

by Oliver Neukum

[permalink] [raw]
Subject: [PATCH] sha256_ssse3: also test for BMI2

From: Oliver Neukum <[email protected]>

The AVX2 implementation also uses BMI2 instructions,
but doesn't test for their availability. The assumption
that AVX2 and BMI2 always go together is false. Some
Haswells have AVX2 but not BMI2.

Signed-off-by: Oliver Neukum <[email protected]>
---
arch/x86/crypto/sha256_ssse3_glue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/crypto/sha256_ssse3_glue.c b/arch/x86/crypto/sha256_ssse3_glue.c
index 50226c4..e52947f 100644
--- a/arch/x86/crypto/sha256_ssse3_glue.c
+++ b/arch/x86/crypto/sha256_ssse3_glue.c
@@ -281,7 +281,7 @@ static int __init sha256_ssse3_mod_init(void)
/* allow AVX to override SSSE3, it's a little faster */
if (avx_usable()) {
#ifdef CONFIG_AS_AVX2
- if (boot_cpu_has(X86_FEATURE_AVX2))
+ if (boot_cpu_has(X86_FEATURE_AVX2) && boot_cpu_has(X86_FEATURE_BMI2))
sha256_transform_asm = sha256_transform_rorx;
else
#endif
--
1.8.3.1


2013-10-07 07:11:26

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] sha256_ssse3: also test for BMI2

On Tue, Oct 01, 2013 at 02:34:46PM +0200, [email protected] wrote:
> From: Oliver Neukum <[email protected]>
>
> The AVX2 implementation also uses BMI2 instructions,
> but doesn't test for their availability. The assumption
> that AVX2 and BMI2 always go together is false. Some
> Haswells have AVX2 but not BMI2.
>
> Signed-off-by: Oliver Neukum <[email protected]>

Patch applied.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt