Commit 559ad0ff authored by Mathias Krause's avatar Mathias Krause Committed by Herbert Xu

crypto: aesni-intel - Fixed build error on x86-32

Exclude AES-GCM code for x86-32 due to heavy usage of 64-bit registers
not available on x86-32.

While at it, fixed unregister order in aesni_exit().
Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c762be63
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/inst.h> #include <asm/inst.h>
#ifdef __x86_64__
.data .data
POLY: .octa 0xC2000000000000000000000000000001 POLY: .octa 0xC2000000000000000000000000000001
TWOONE: .octa 0x00000001000000000000000000000001 TWOONE: .octa 0x00000001000000000000000000000001
...@@ -84,6 +85,7 @@ enc: .octa 0x2 ...@@ -84,6 +85,7 @@ enc: .octa 0x2
#define arg8 STACK_OFFSET+16(%r14) #define arg8 STACK_OFFSET+16(%r14)
#define arg9 STACK_OFFSET+24(%r14) #define arg9 STACK_OFFSET+24(%r14)
#define arg10 STACK_OFFSET+32(%r14) #define arg10 STACK_OFFSET+32(%r14)
#endif
#define STATE1 %xmm0 #define STATE1 %xmm0
...@@ -130,6 +132,7 @@ enc: .octa 0x2 ...@@ -130,6 +132,7 @@ enc: .octa 0x2
#endif #endif
#ifdef __x86_64__
/* GHASH_MUL MACRO to implement: Data*HashKey mod (128,127,126,121,0) /* GHASH_MUL MACRO to implement: Data*HashKey mod (128,127,126,121,0)
* *
* *
...@@ -1255,7 +1258,7 @@ _return_T_done_encrypt: ...@@ -1255,7 +1258,7 @@ _return_T_done_encrypt:
pop %r13 pop %r13
pop %r12 pop %r12
ret ret
#endif
_key_expansion_128: _key_expansion_128:
......
...@@ -97,7 +97,6 @@ asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out, ...@@ -97,7 +97,6 @@ asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out,
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out, asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out,
const u8 *in, unsigned int len, u8 *iv); const u8 *in, unsigned int len, u8 *iv);
#endif
/* asmlinkage void aesni_gcm_enc() /* asmlinkage void aesni_gcm_enc()
* void *ctx, AES Key schedule. Starts on a 16 byte boundary. * void *ctx, AES Key schedule. Starts on a 16 byte boundary.
...@@ -149,6 +148,7 @@ aesni_rfc4106_gcm_ctx *aesni_rfc4106_gcm_ctx_get(struct crypto_aead *tfm) ...@@ -149,6 +148,7 @@ aesni_rfc4106_gcm_ctx *aesni_rfc4106_gcm_ctx_get(struct crypto_aead *tfm)
PTR_ALIGN((u8 *) PTR_ALIGN((u8 *)
crypto_tfm_ctx(crypto_aead_tfm(tfm)), AESNI_ALIGN); crypto_tfm_ctx(crypto_aead_tfm(tfm)), AESNI_ALIGN);
} }
#endif
static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx) static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx)
{ {
...@@ -822,6 +822,7 @@ static struct crypto_alg ablk_xts_alg = { ...@@ -822,6 +822,7 @@ static struct crypto_alg ablk_xts_alg = {
}; };
#endif #endif
#ifdef CONFIG_X86_64
static int rfc4106_init(struct crypto_tfm *tfm) static int rfc4106_init(struct crypto_tfm *tfm)
{ {
struct cryptd_aead *cryptd_tfm; struct cryptd_aead *cryptd_tfm;
...@@ -1237,6 +1238,7 @@ static struct crypto_alg __rfc4106_alg = { ...@@ -1237,6 +1238,7 @@ static struct crypto_alg __rfc4106_alg = {
}, },
}, },
}; };
#endif
static int __init aesni_init(void) static int __init aesni_init(void)
{ {
...@@ -1264,6 +1266,10 @@ static int __init aesni_init(void) ...@@ -1264,6 +1266,10 @@ static int __init aesni_init(void)
goto blk_ctr_err; goto blk_ctr_err;
if ((err = crypto_register_alg(&ablk_ctr_alg))) if ((err = crypto_register_alg(&ablk_ctr_alg)))
goto ablk_ctr_err; goto ablk_ctr_err;
if ((err = crypto_register_alg(&__rfc4106_alg)))
goto __aead_gcm_err;
if ((err = crypto_register_alg(&rfc4106_alg)))
goto aead_gcm_err;
#ifdef HAS_CTR #ifdef HAS_CTR
if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg))) if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg)))
goto ablk_rfc3686_ctr_err; goto ablk_rfc3686_ctr_err;
...@@ -1281,19 +1287,9 @@ static int __init aesni_init(void) ...@@ -1281,19 +1287,9 @@ static int __init aesni_init(void)
if ((err = crypto_register_alg(&ablk_xts_alg))) if ((err = crypto_register_alg(&ablk_xts_alg)))
goto ablk_xts_err; goto ablk_xts_err;
#endif #endif
err = crypto_register_alg(&__rfc4106_alg);
if (err)
goto __aead_gcm_err;
err = crypto_register_alg(&rfc4106_alg);
if (err)
goto aead_gcm_err;
return err; return err;
aead_gcm_err:
crypto_unregister_alg(&__rfc4106_alg);
__aead_gcm_err:
#ifdef HAS_XTS #ifdef HAS_XTS
crypto_unregister_alg(&ablk_xts_alg);
ablk_xts_err: ablk_xts_err:
#endif #endif
#ifdef HAS_PCBC #ifdef HAS_PCBC
...@@ -1309,6 +1305,10 @@ static int __init aesni_init(void) ...@@ -1309,6 +1305,10 @@ static int __init aesni_init(void)
crypto_unregister_alg(&ablk_rfc3686_ctr_alg); crypto_unregister_alg(&ablk_rfc3686_ctr_alg);
ablk_rfc3686_ctr_err: ablk_rfc3686_ctr_err:
#endif #endif
crypto_unregister_alg(&rfc4106_alg);
aead_gcm_err:
crypto_unregister_alg(&__rfc4106_alg);
__aead_gcm_err:
crypto_unregister_alg(&ablk_ctr_alg); crypto_unregister_alg(&ablk_ctr_alg);
ablk_ctr_err: ablk_ctr_err:
crypto_unregister_alg(&blk_ctr_alg); crypto_unregister_alg(&blk_ctr_alg);
...@@ -1331,8 +1331,6 @@ static int __init aesni_init(void) ...@@ -1331,8 +1331,6 @@ static int __init aesni_init(void)
static void __exit aesni_exit(void) static void __exit aesni_exit(void)
{ {
crypto_unregister_alg(&__rfc4106_alg);
crypto_unregister_alg(&rfc4106_alg);
#ifdef HAS_XTS #ifdef HAS_XTS
crypto_unregister_alg(&ablk_xts_alg); crypto_unregister_alg(&ablk_xts_alg);
#endif #endif
...@@ -1346,6 +1344,8 @@ static void __exit aesni_exit(void) ...@@ -1346,6 +1344,8 @@ static void __exit aesni_exit(void)
#ifdef HAS_CTR #ifdef HAS_CTR
crypto_unregister_alg(&ablk_rfc3686_ctr_alg); crypto_unregister_alg(&ablk_rfc3686_ctr_alg);
#endif #endif
crypto_unregister_alg(&rfc4106_alg);
crypto_unregister_alg(&__rfc4106_alg);
crypto_unregister_alg(&ablk_ctr_alg); crypto_unregister_alg(&ablk_ctr_alg);
crypto_unregister_alg(&blk_ctr_alg); crypto_unregister_alg(&blk_ctr_alg);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment