* [BUGFIX 2/3] crypto: Remove CRYPTO_TFM_REQ_MAY_SLEEP flag in AES-NI accelerated ecb/cbc mode
@ 2009-06-15 9:04 Huang Ying
2009-06-18 11:40 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Huang Ying @ 2009-06-15 9:04 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-kernel, linux-crypto
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 <ying.huang@intel.com>
---
arch/x86/crypto/aesni-intel_glue.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -198,6 +198,7 @@ static int ecb_encrypt(struct blkcipher_
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)) {
@@ -221,6 +222,7 @@ static int ecb_decrypt(struct blkcipher_
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)) {
@@ -266,6 +268,7 @@ static int cbc_encrypt(struct blkcipher_
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)) {
@@ -289,6 +292,7 @@ static int cbc_decrypt(struct blkcipher_
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)) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUGFIX 2/3] crypto: Remove CRYPTO_TFM_REQ_MAY_SLEEP flag in AES-NI accelerated ecb/cbc mode
2009-06-15 9:04 [BUGFIX 2/3] crypto: Remove CRYPTO_TFM_REQ_MAY_SLEEP flag in AES-NI accelerated ecb/cbc mode Huang Ying
@ 2009-06-18 11:40 ` Herbert Xu
2009-06-19 0:55 ` Huang Ying
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2009-06-18 11:40 UTC (permalink / raw)
To: Huang Ying; +Cc: linux-kernel, linux-crypto
On Mon, Jun 15, 2009 at 05:04:57PM +0800, Huang Ying wrote:
> 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 <ying.huang@intel.com>
I'll apply this for now. But it would be much better to allow
sleeping in this case.
Couldn't we simply move the kernel_fpu_begin/end inside the loop?
It shouldn't be too expensive when it runs the 2nd time since it
doesn't have to save anything, right?
Cheer,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUGFIX 2/3] crypto: Remove CRYPTO_TFM_REQ_MAY_SLEEP flag in AES-NI accelerated ecb/cbc mode
2009-06-18 11:40 ` Herbert Xu
@ 2009-06-19 0:55 ` Huang Ying
0 siblings, 0 replies; 3+ messages in thread
From: Huang Ying @ 2009-06-19 0:55 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-kernel, linux-crypto
On Thu, 2009-06-18 at 19:40 +0800, Herbert Xu wrote:
> On Mon, Jun 15, 2009 at 05:04:57PM +0800, Huang Ying wrote:
> > 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 <ying.huang@intel.com>
>
> I'll apply this for now. But it would be much better to allow
> sleeping in this case.
>
> Couldn't we simply move the kernel_fpu_begin/end inside the loop?
> It shouldn't be too expensive when it runs the 2nd time since it
> doesn't have to save anything, right?
I will test the performance difference.
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-19 0:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15 9:04 [BUGFIX 2/3] crypto: Remove CRYPTO_TFM_REQ_MAY_SLEEP flag in AES-NI accelerated ecb/cbc mode Huang Ying
2009-06-18 11:40 ` Herbert Xu
2009-06-19 0:55 ` Huang Ying
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).