Commit 2d6f0600 authored by Leonidas Da Silva Barbosa's avatar Leonidas Da Silva Barbosa Committed by Herbert Xu

crypto: vmx - Adding enable_kernel_vsx() to access VSX instructions

vmx-crypto driver make use of some VSX instructions which are
only available if VSX is enabled. Running in cases where VSX
are not enabled vmx-crypto fails in a VSX exception.

In order to fix this enable_kernel_vsx() was added to turn on
VSX instructions for vmx-crypto.
Signed-off-by: default avatarLeonidas S. Barbosa <leosilva@linux.vnet.ibm.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 72cd7b44
...@@ -84,6 +84,7 @@ static int p8_aes_setkey(struct crypto_tfm *tfm, const u8 *key, ...@@ -84,6 +84,7 @@ static int p8_aes_setkey(struct crypto_tfm *tfm, const u8 *key,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key); ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
pagefault_enable(); pagefault_enable();
...@@ -103,6 +104,7 @@ static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) ...@@ -103,6 +104,7 @@ static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
aes_p8_encrypt(src, dst, &ctx->enc_key); aes_p8_encrypt(src, dst, &ctx->enc_key);
pagefault_enable(); pagefault_enable();
preempt_enable(); preempt_enable();
...@@ -119,6 +121,7 @@ static void p8_aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) ...@@ -119,6 +121,7 @@ static void p8_aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
aes_p8_decrypt(src, dst, &ctx->dec_key); aes_p8_decrypt(src, dst, &ctx->dec_key);
pagefault_enable(); pagefault_enable();
preempt_enable(); preempt_enable();
......
...@@ -85,6 +85,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key, ...@@ -85,6 +85,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key); ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
pagefault_enable(); pagefault_enable();
...@@ -115,6 +116,7 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc, ...@@ -115,6 +116,7 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
blkcipher_walk_init(&walk, dst, src, nbytes); blkcipher_walk_init(&walk, dst, src, nbytes);
ret = blkcipher_walk_virt(desc, &walk); ret = blkcipher_walk_virt(desc, &walk);
...@@ -155,6 +157,7 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc, ...@@ -155,6 +157,7 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
blkcipher_walk_init(&walk, dst, src, nbytes); blkcipher_walk_init(&walk, dst, src, nbytes);
ret = blkcipher_walk_virt(desc, &walk); ret = blkcipher_walk_virt(desc, &walk);
......
...@@ -82,6 +82,7 @@ static int p8_aes_ctr_setkey(struct crypto_tfm *tfm, const u8 *key, ...@@ -82,6 +82,7 @@ static int p8_aes_ctr_setkey(struct crypto_tfm *tfm, const u8 *key,
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
pagefault_enable(); pagefault_enable();
...@@ -100,6 +101,7 @@ static void p8_aes_ctr_final(struct p8_aes_ctr_ctx *ctx, ...@@ -100,6 +101,7 @@ static void p8_aes_ctr_final(struct p8_aes_ctr_ctx *ctx,
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
aes_p8_encrypt(ctrblk, keystream, &ctx->enc_key); aes_p8_encrypt(ctrblk, keystream, &ctx->enc_key);
pagefault_enable(); pagefault_enable();
...@@ -131,6 +133,7 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc, ...@@ -131,6 +133,7 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc,
while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) { while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) {
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
aes_p8_ctr32_encrypt_blocks(walk.src.virt.addr, aes_p8_ctr32_encrypt_blocks(walk.src.virt.addr,
walk.dst.virt.addr, walk.dst.virt.addr,
(nbytes & (nbytes &
......
...@@ -119,6 +119,7 @@ static int p8_ghash_setkey(struct crypto_shash *tfm, const u8 *key, ...@@ -119,6 +119,7 @@ static int p8_ghash_setkey(struct crypto_shash *tfm, const u8 *key,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
enable_kernel_fp(); enable_kernel_fp();
gcm_init_p8(ctx->htable, (const u64 *) key); gcm_init_p8(ctx->htable, (const u64 *) key);
pagefault_enable(); pagefault_enable();
...@@ -149,6 +150,7 @@ static int p8_ghash_update(struct shash_desc *desc, ...@@ -149,6 +150,7 @@ static int p8_ghash_update(struct shash_desc *desc,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
enable_kernel_fp(); enable_kernel_fp();
gcm_ghash_p8(dctx->shash, ctx->htable, gcm_ghash_p8(dctx->shash, ctx->htable,
dctx->buffer, GHASH_DIGEST_SIZE); dctx->buffer, GHASH_DIGEST_SIZE);
...@@ -163,6 +165,7 @@ static int p8_ghash_update(struct shash_desc *desc, ...@@ -163,6 +165,7 @@ static int p8_ghash_update(struct shash_desc *desc,
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
enable_kernel_fp(); enable_kernel_fp();
gcm_ghash_p8(dctx->shash, ctx->htable, src, len); gcm_ghash_p8(dctx->shash, ctx->htable, src, len);
pagefault_enable(); pagefault_enable();
...@@ -193,6 +196,7 @@ static int p8_ghash_final(struct shash_desc *desc, u8 *out) ...@@ -193,6 +196,7 @@ static int p8_ghash_final(struct shash_desc *desc, u8 *out)
preempt_disable(); preempt_disable();
pagefault_disable(); pagefault_disable();
enable_kernel_altivec(); enable_kernel_altivec();
enable_kernel_vsx();
enable_kernel_fp(); enable_kernel_fp();
gcm_ghash_p8(dctx->shash, ctx->htable, gcm_ghash_p8(dctx->shash, ctx->htable,
dctx->buffer, GHASH_DIGEST_SIZE); dctx->buffer, GHASH_DIGEST_SIZE);
......
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