hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/arch/x86/crypto/glue_helper.c
....@@ -38,7 +38,7 @@
3838 void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
3939 const unsigned int bsize = 128 / 8;
4040 struct skcipher_walk walk;
41
- bool fpu_enabled = false;
41
+ bool fpu_enabled;
4242 unsigned int nbytes;
4343 int err;
4444
....@@ -51,7 +51,7 @@
5151 unsigned int i;
5252
5353 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
54
- &walk, fpu_enabled, nbytes);
54
+ &walk, false, nbytes);
5555 for (i = 0; i < gctx->num_funcs; i++) {
5656 func_bytes = bsize * gctx->funcs[i].num_blocks;
5757
....@@ -69,10 +69,9 @@
6969 if (nbytes < bsize)
7070 break;
7171 }
72
+ glue_fpu_end(fpu_enabled);
7273 err = skcipher_walk_done(&walk, nbytes);
7374 }
74
-
75
- glue_fpu_end(fpu_enabled);
7675 return err;
7776 }
7877 EXPORT_SYMBOL_GPL(glue_ecb_req_128bit);
....@@ -115,7 +114,7 @@
115114 void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
116115 const unsigned int bsize = 128 / 8;
117116 struct skcipher_walk walk;
118
- bool fpu_enabled = false;
117
+ bool fpu_enabled;
119118 unsigned int nbytes;
120119 int err;
121120
....@@ -129,7 +128,7 @@
129128 u128 last_iv;
130129
131130 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
132
- &walk, fpu_enabled, nbytes);
131
+ &walk, false, nbytes);
133132 /* Start of the last block. */
134133 src += nbytes / bsize - 1;
135134 dst += nbytes / bsize - 1;
....@@ -161,10 +160,10 @@
161160 done:
162161 u128_xor(dst, dst, (u128 *)walk.iv);
163162 *(u128 *)walk.iv = last_iv;
163
+ glue_fpu_end(fpu_enabled);
164164 err = skcipher_walk_done(&walk, nbytes);
165165 }
166166
167
- glue_fpu_end(fpu_enabled);
168167 return err;
169168 }
170169 EXPORT_SYMBOL_GPL(glue_cbc_decrypt_req_128bit);
....@@ -175,7 +174,7 @@
175174 void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
176175 const unsigned int bsize = 128 / 8;
177176 struct skcipher_walk walk;
178
- bool fpu_enabled = false;
177
+ bool fpu_enabled;
179178 unsigned int nbytes;
180179 int err;
181180
....@@ -189,7 +188,7 @@
189188 le128 ctrblk;
190189
191190 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
192
- &walk, fpu_enabled, nbytes);
191
+ &walk, false, nbytes);
193192
194193 be128_to_le128(&ctrblk, (be128 *)walk.iv);
195194
....@@ -213,10 +212,9 @@
213212 }
214213
215214 le128_to_be128((be128 *)walk.iv, &ctrblk);
215
+ glue_fpu_end(fpu_enabled);
216216 err = skcipher_walk_done(&walk, nbytes);
217217 }
218
-
219
- glue_fpu_end(fpu_enabled);
220218
221219 if (nbytes) {
222220 le128 ctrblk;
....@@ -278,7 +276,7 @@
278276 {
279277 const unsigned int bsize = 128 / 8;
280278 struct skcipher_walk walk;
281
- bool fpu_enabled = false;
279
+ bool fpu_enabled;
282280 unsigned int nbytes;
283281 int err;
284282
....@@ -289,20 +287,23 @@
289287
290288 /* set minimum length to bsize, for tweak_fn */
291289 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
292
- &walk, fpu_enabled,
290
+ &walk, false,
293291 nbytes < bsize ? bsize : nbytes);
294292
295293 /* calculate first value of T */
296294 tweak_fn(tweak_ctx, walk.iv, walk.iv);
297295
298296 while (nbytes) {
297
+ fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
298
+ &walk, fpu_enabled,
299
+ nbytes < bsize ? bsize : nbytes);
299300 nbytes = __glue_xts_req_128bit(gctx, crypt_ctx, &walk);
300301
302
+ glue_fpu_end(fpu_enabled);
303
+ fpu_enabled = false;
301304 err = skcipher_walk_done(&walk, nbytes);
302305 nbytes = walk.nbytes;
303306 }
304
-
305
- glue_fpu_end(fpu_enabled);
306307
307308 return err;
308309 }