All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem
@ 2016-12-13 14:32 Ilya Lesokhin
  2016-12-13 19:07 ` Dave Watson
  2016-12-27 10:05 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Lesokhin @ 2016-12-13 14:32 UTC (permalink / raw)
  To: linux-crypto, tadeusz.struk, herbert, davejwatson
  Cc: tls-fpga-sw-dev, Ilya Lesokhin

In the common case of !PageHighMem we can do zero copy crypto
even if sg crosses a pages boundary.

Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
---
 arch/x86/crypto/aesni-intel_glue.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index b1ab0cb..b494ad7 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -903,9 +903,11 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
 	*((__be32 *)(iv+12)) = counter;
 
 	if (sg_is_last(req->src) &&
-	    req->src->offset + req->src->length <= PAGE_SIZE &&
+	    (!PageHighMem(sg_page(req->src)) ||
+	    req->src->offset + req->src->length <= PAGE_SIZE) &&
 	    sg_is_last(req->dst) &&
-	    req->dst->offset + req->dst->length <= PAGE_SIZE) {
+	    (!PageHighMem(sg_page(req->dst)) ||
+	    req->dst->offset + req->dst->length <= PAGE_SIZE)) {
 		one_entry_in_sg = 1;
 		scatterwalk_start(&src_sg_walk, req->src);
 		assoc = scatterwalk_map(&src_sg_walk);
@@ -990,9 +992,11 @@ static int helper_rfc4106_decrypt(struct aead_request *req)
 	*((__be32 *)(iv+12)) = counter;
 
 	if (sg_is_last(req->src) &&
-	    req->src->offset + req->src->length <= PAGE_SIZE &&
+	    (!PageHighMem(sg_page(req->src)) ||
+	    req->src->offset + req->src->length <= PAGE_SIZE) &&
 	    sg_is_last(req->dst) &&
-	    req->dst->offset + req->dst->length <= PAGE_SIZE) {
+	    (!PageHighMem(sg_page(req->dst)) ||
+	    req->dst->offset + req->dst->length <= PAGE_SIZE)) {
 		one_entry_in_sg = 1;
 		scatterwalk_start(&src_sg_walk, req->src);
 		assoc = scatterwalk_map(&src_sg_walk);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem
  2016-12-13 14:32 [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem Ilya Lesokhin
@ 2016-12-13 19:07 ` Dave Watson
  2016-12-27 10:05 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Watson @ 2016-12-13 19:07 UTC (permalink / raw)
  To: Ilya Lesokhin; +Cc: linux-crypto, tadeusz.struk, herbert, tls-fpga-sw-dev

On 12/13/16 04:32 PM, Ilya Lesokhin wrote:
> --- a/arch/x86/crypto/aesni-intel_glue.c
> +++ b/arch/x86/crypto/aesni-intel_glue.c
> @@ -903,9 +903,11 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
>  	*((__be32 *)(iv+12)) = counter;
>  
>  	if (sg_is_last(req->src) &&
> -	    req->src->offset + req->src->length <= PAGE_SIZE &&
> +	    (!PageHighMem(sg_page(req->src)) ||
> +	    req->src->offset + req->src->length <= PAGE_SIZE) &&
>  	    sg_is_last(req->dst) &&
> -	    req->dst->offset + req->dst->length <= PAGE_SIZE) {
> +	    (!PageHighMem(sg_page(req->dst)) ||
> +	    req->dst->offset + req->dst->length <= PAGE_SIZE)) {
>  		one_entry_in_sg = 1;
>  		scatterwalk_start(&src_sg_walk, req->src);
>  		assoc = scatterwalk_map(&src_sg_walk);

I was also experimenting with a similar patch that loosened up the
restrictions here, checking for highmem.  Note that you can go even
further and check the AAD, data, and TAG all separately, the current
aesni crypto routines take them as separate buffers.  (This might fix
the RFC5288 patch AAD size issue?)

Long term it would be nice to improve the asm routines instead to
support scatter / gather IO and any AAD len, as the newer intel
routines do:

https://github.com/01org/isa-l_crypto/tree/master/aes

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem
  2016-12-13 14:32 [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem Ilya Lesokhin
  2016-12-13 19:07 ` Dave Watson
@ 2016-12-27 10:05 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2016-12-27 10:05 UTC (permalink / raw)
  To: Ilya Lesokhin; +Cc: linux-crypto, tadeusz.struk, davejwatson, tls-fpga-sw-dev

On Tue, Dec 13, 2016 at 04:32:06PM +0200, Ilya Lesokhin wrote:
> In the common case of !PageHighMem we can do zero copy crypto
> even if sg crosses a pages boundary.
> 
> Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <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

end of thread, other threads:[~2016-12-27 10:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 14:32 [PATCH] crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem Ilya Lesokhin
2016-12-13 19:07 ` Dave Watson
2016-12-27 10:05 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.