Skip to content

Commit 50fb570

Browse files
Ilya Lesokhinherbertx
authored andcommitted
crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f262c77 commit 50fb570

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,11 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
740740
*((__be32 *)(iv+12)) = counter;
741741

742742
if (sg_is_last(req->src) &&
743-
req->src->offset + req->src->length <= PAGE_SIZE &&
743+
(!PageHighMem(sg_page(req->src)) ||
744+
req->src->offset + req->src->length <= PAGE_SIZE) &&
744745
sg_is_last(req->dst) &&
745-
req->dst->offset + req->dst->length <= PAGE_SIZE) {
746+
(!PageHighMem(sg_page(req->dst)) ||
747+
req->dst->offset + req->dst->length <= PAGE_SIZE)) {
746748
one_entry_in_sg = 1;
747749
scatterwalk_start(&src_sg_walk, req->src);
748750
assoc = scatterwalk_map(&src_sg_walk);
@@ -822,9 +824,11 @@ static int helper_rfc4106_decrypt(struct aead_request *req)
822824
*((__be32 *)(iv+12)) = counter;
823825

824826
if (sg_is_last(req->src) &&
825-
req->src->offset + req->src->length <= PAGE_SIZE &&
827+
(!PageHighMem(sg_page(req->src)) ||
828+
req->src->offset + req->src->length <= PAGE_SIZE) &&
826829
sg_is_last(req->dst) &&
827-
req->dst->offset + req->dst->length <= PAGE_SIZE) {
830+
(!PageHighMem(sg_page(req->dst)) ||
831+
req->dst->offset + req->dst->length <= PAGE_SIZE)) {
828832
one_entry_in_sg = 1;
829833
scatterwalk_start(&src_sg_walk, req->src);
830834
assoc = scatterwalk_map(&src_sg_walk);

0 commit comments

Comments
 (0)