Skip to content

Commit 559ad0f

Browse files
minipliherbertx
authored andcommitted
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: Mathias Krause <minipli@googlemail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c762be6 commit 559ad0f

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎arch/x86/crypto/aesni-intel_asm.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/linkage.h>
3333
#include <asm/inst.h>
3434

35+
#ifdef __x86_64__
3536
.data
3637
POLY: .octa 0xC2000000000000000000000000000001
3738
TWOONE: .octa 0x00000001000000000000000000000001
@@ -84,6 +85,7 @@ enc: .octa 0x2
8485
#define arg8 STACK_OFFSET+16(%r14)
8586
#define arg9 STACK_OFFSET+24(%r14)
8687
#define arg10 STACK_OFFSET+32(%r14)
88+
#endif
8789

8890

8991
#define STATE1 %xmm0
@@ -130,6 +132,7 @@ enc: .octa 0x2
130132
#endif
131133

132134

135+
#ifdef __x86_64__
133136
/* GHASH_MUL MACRO to implement: Data*HashKey mod (128,127,126,121,0)
134137
*
135138
*
@@ -1255,7 +1258,7 @@ _return_T_done_encrypt:
12551258
pop %r13
12561259
pop %r12
12571260
ret
1258-
1261+
#endif
12591262

12601263

12611264
_key_expansion_128:

‎arch/x86/crypto/aesni-intel_glue.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out,
9797
#ifdef CONFIG_X86_64
9898
asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out,
9999
const u8 *in, unsigned int len, u8 *iv);
100-
#endif
101100

102101
/* asmlinkage void aesni_gcm_enc()
103102
* 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)
149148
PTR_ALIGN((u8 *)
150149
crypto_tfm_ctx(crypto_aead_tfm(tfm)), AESNI_ALIGN);
151150
}
151+
#endif
152152

153153
static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx)
154154
{
@@ -822,6 +822,7 @@ static struct crypto_alg ablk_xts_alg = {
822822
};
823823
#endif
824824

825+
#ifdef CONFIG_X86_64
825826
static int rfc4106_init(struct crypto_tfm *tfm)
826827
{
827828
struct cryptd_aead *cryptd_tfm;
@@ -1237,6 +1238,7 @@ static struct crypto_alg __rfc4106_alg = {
12371238
},
12381239
},
12391240
};
1241+
#endif
12401242

12411243
static int __init aesni_init(void)
12421244
{
@@ -1264,6 +1266,10 @@ static int __init aesni_init(void)
12641266
goto blk_ctr_err;
12651267
if ((err = crypto_register_alg(&ablk_ctr_alg)))
12661268
goto ablk_ctr_err;
1269+
if ((err = crypto_register_alg(&__rfc4106_alg)))
1270+
goto __aead_gcm_err;
1271+
if ((err = crypto_register_alg(&rfc4106_alg)))
1272+
goto aead_gcm_err;
12671273
#ifdef HAS_CTR
12681274
if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg)))
12691275
goto ablk_rfc3686_ctr_err;
@@ -1281,19 +1287,9 @@ static int __init aesni_init(void)
12811287
if ((err = crypto_register_alg(&ablk_xts_alg)))
12821288
goto ablk_xts_err;
12831289
#endif
1284-
err = crypto_register_alg(&__rfc4106_alg);
1285-
if (err)
1286-
goto __aead_gcm_err;
1287-
err = crypto_register_alg(&rfc4106_alg);
1288-
if (err)
1289-
goto aead_gcm_err;
12901290
return err;
12911291

1292-
aead_gcm_err:
1293-
crypto_unregister_alg(&__rfc4106_alg);
1294-
__aead_gcm_err:
12951292
#ifdef HAS_XTS
1296-
crypto_unregister_alg(&ablk_xts_alg);
12971293
ablk_xts_err:
12981294
#endif
12991295
#ifdef HAS_PCBC
@@ -1309,6 +1305,10 @@ static int __init aesni_init(void)
13091305
crypto_unregister_alg(&ablk_rfc3686_ctr_alg);
13101306
ablk_rfc3686_ctr_err:
13111307
#endif
1308+
crypto_unregister_alg(&rfc4106_alg);
1309+
aead_gcm_err:
1310+
crypto_unregister_alg(&__rfc4106_alg);
1311+
__aead_gcm_err:
13121312
crypto_unregister_alg(&ablk_ctr_alg);
13131313
ablk_ctr_err:
13141314
crypto_unregister_alg(&blk_ctr_alg);
@@ -1331,8 +1331,6 @@ static int __init aesni_init(void)
13311331

13321332
static void __exit aesni_exit(void)
13331333
{
1334-
crypto_unregister_alg(&__rfc4106_alg);
1335-
crypto_unregister_alg(&rfc4106_alg);
13361334
#ifdef HAS_XTS
13371335
crypto_unregister_alg(&ablk_xts_alg);
13381336
#endif
@@ -1346,6 +1344,8 @@ static void __exit aesni_exit(void)
13461344
#ifdef HAS_CTR
13471345
crypto_unregister_alg(&ablk_rfc3686_ctr_alg);
13481346
#endif
1347+
crypto_unregister_alg(&rfc4106_alg);
1348+
crypto_unregister_alg(&__rfc4106_alg);
13491349
crypto_unregister_alg(&ablk_ctr_alg);
13501350
crypto_unregister_alg(&blk_ctr_alg);
13511351
#endif

0 commit comments

Comments
 (0)