]> rtime.felk.cvut.cz Git - zynq/linux.git/blobdiff - arch/x86/crypto/glue_helper.c
Apply preempt_rt patch-4.9-rt1.patch.xz
[zynq/linux.git] / arch / x86 / crypto / glue_helper.c
index 6a85598931b5d6879e362df005bcf3fc48850642..3a506ce7ed930eeb9af5e363da8bae74fa3d5b5d 100644 (file)
@@ -39,7 +39,7 @@ static int __glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
        void *ctx = crypto_blkcipher_ctx(desc->tfm);
        const unsigned int bsize = 128 / 8;
        unsigned int nbytes, i, func_bytes;
-       bool fpu_enabled = false;
+       bool fpu_enabled;
        int err;
 
        err = blkcipher_walk_virt(desc, walk);
@@ -49,7 +49,7 @@ static int __glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
                u8 *wdst = walk->dst.virt.addr;
 
                fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-                                            desc, fpu_enabled, nbytes);
+                                            desc, false, nbytes);
 
                for (i = 0; i < gctx->num_funcs; i++) {
                        func_bytes = bsize * gctx->funcs[i].num_blocks;
@@ -71,10 +71,10 @@ static int __glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
                }
 
 done:
+               glue_fpu_end(fpu_enabled);
                err = blkcipher_walk_done(desc, walk, nbytes);
        }
 
-       glue_fpu_end(fpu_enabled);
        return err;
 }
 
@@ -194,7 +194,7 @@ int glue_cbc_decrypt_128bit(const struct common_glue_ctx *gctx,
                            struct scatterlist *src, unsigned int nbytes)
 {
        const unsigned int bsize = 128 / 8;
-       bool fpu_enabled = false;
+       bool fpu_enabled;
        struct blkcipher_walk walk;
        int err;
 
@@ -203,12 +203,12 @@ int glue_cbc_decrypt_128bit(const struct common_glue_ctx *gctx,
 
        while ((nbytes = walk.nbytes)) {
                fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-                                            desc, fpu_enabled, nbytes);
+                                            desc, false, nbytes);
                nbytes = __glue_cbc_decrypt_128bit(gctx, desc, &walk);
+               glue_fpu_end(fpu_enabled);
                err = blkcipher_walk_done(desc, &walk, nbytes);
        }
 
-       glue_fpu_end(fpu_enabled);
        return err;
 }
 EXPORT_SYMBOL_GPL(glue_cbc_decrypt_128bit);
@@ -277,7 +277,7 @@ int glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
                          struct scatterlist *src, unsigned int nbytes)
 {
        const unsigned int bsize = 128 / 8;
-       bool fpu_enabled = false;
+       bool fpu_enabled;
        struct blkcipher_walk walk;
        int err;
 
@@ -286,13 +286,12 @@ int glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
 
        while ((nbytes = walk.nbytes) >= bsize) {
                fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-                                            desc, fpu_enabled, nbytes);
+                                            desc, false, nbytes);
                nbytes = __glue_ctr_crypt_128bit(gctx, desc, &walk);
+               glue_fpu_end(fpu_enabled);
                err = blkcipher_walk_done(desc, &walk, nbytes);
        }
 
-       glue_fpu_end(fpu_enabled);
-
        if (walk.nbytes) {
                glue_ctr_crypt_final_128bit(
                        gctx->funcs[gctx->num_funcs - 1].fn_u.ctr, desc, &walk);
@@ -347,7 +346,7 @@ int glue_xts_crypt_128bit(const struct common_glue_ctx *gctx,
                          void *tweak_ctx, void *crypt_ctx)
 {
        const unsigned int bsize = 128 / 8;
-       bool fpu_enabled = false;
+       bool fpu_enabled;
        struct blkcipher_walk walk;
        int err;
 
@@ -360,21 +359,21 @@ int glue_xts_crypt_128bit(const struct common_glue_ctx *gctx,
 
        /* set minimum length to bsize, for tweak_fn */
        fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-                                    desc, fpu_enabled,
+                                    desc, false,
                                     nbytes < bsize ? bsize : nbytes);
-
        /* calculate first value of T */
        tweak_fn(tweak_ctx, walk.iv, walk.iv);
+       glue_fpu_end(fpu_enabled);
 
        while (nbytes) {
+               fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
+                               desc, false, nbytes);
                nbytes = __glue_xts_crypt_128bit(gctx, crypt_ctx, desc, &walk);
 
+               glue_fpu_end(fpu_enabled);
                err = blkcipher_walk_done(desc, &walk, nbytes);
                nbytes = walk.nbytes;
        }
-
-       glue_fpu_end(fpu_enabled);
-
        return err;
 }
 EXPORT_SYMBOL_GPL(glue_xts_crypt_128bit);