crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem
authorIlya Lesokhin <ilyal@mellanox.com>
Tue, 13 Dec 2016 14:32:06 +0000 (16:32 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 27 Dec 2016 09:48:48 +0000 (17:48 +0800)
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>
arch/x86/crypto/aesni-intel_glue.c

index 31c34ee131f34505872a018b75a8489f1ac9c854..36ca1502630cc95204c7e336541338c3656f4c63 100644 (file)
@@ -740,9 +740,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);
@@ -822,9 +824,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);