Skip to content

Commit

Permalink
crypto: aes-ni - Do not sleep when using the FPU
Browse files Browse the repository at this point in the history
Because AES-NI instructions will touch XMM state, corresponding code
must be enclosed within kernel_fpu_begin/end, which used
preempt_disable/enable. So sleep should be prevented between
kernel_fpu_begin/end.

Signed-off-by: Huang Ying <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
yhuang-intel authored and herbertx committed Jun 18, 2009
1 parent e6efaa0 commit 9251b64
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/crypto/aesni-intel_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ static int ecb_encrypt(struct blkcipher_desc *desc,

blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;

kernel_fpu_begin();
while ((nbytes = walk.nbytes)) {
Expand All @@ -221,6 +222,7 @@ static int ecb_decrypt(struct blkcipher_desc *desc,

blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;

kernel_fpu_begin();
while ((nbytes = walk.nbytes)) {
Expand Down Expand Up @@ -266,6 +268,7 @@ static int cbc_encrypt(struct blkcipher_desc *desc,

blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;

kernel_fpu_begin();
while ((nbytes = walk.nbytes)) {
Expand All @@ -289,6 +292,7 @@ static int cbc_decrypt(struct blkcipher_desc *desc,

blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;

kernel_fpu_begin();
while ((nbytes = walk.nbytes)) {
Expand Down

0 comments on commit 9251b64

Please sign in to comment.