From 6778948f9de86c3cfaf36725a7c87dcff9ba247f Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 08:20:59 +0000
Subject: [PATCH] kernel_5.10 no rt

---
 kernel/arch/x86/crypto/glue_helper.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/kernel/arch/x86/crypto/glue_helper.c b/kernel/arch/x86/crypto/glue_helper.c
index 6d07747..d3d91a0 100644
--- a/kernel/arch/x86/crypto/glue_helper.c
+++ b/kernel/arch/x86/crypto/glue_helper.c
@@ -24,7 +24,7 @@
 	void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
 	const unsigned int bsize = 128 / 8;
 	struct skcipher_walk walk;
-	bool fpu_enabled;
+	bool fpu_enabled = false;
 	unsigned int nbytes;
 	int err;
 
@@ -37,7 +37,7 @@
 		unsigned int i;
 
 		fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-					     &walk, false, nbytes);
+					     &walk, fpu_enabled, nbytes);
 		for (i = 0; i < gctx->num_funcs; i++) {
 			func_bytes = bsize * gctx->funcs[i].num_blocks;
 
@@ -55,9 +55,10 @@
 			if (nbytes < bsize)
 				break;
 		}
-		glue_fpu_end(fpu_enabled);
 		err = skcipher_walk_done(&walk, nbytes);
 	}
+
+	glue_fpu_end(fpu_enabled);
 	return err;
 }
 EXPORT_SYMBOL_GPL(glue_ecb_req_128bit);
@@ -100,7 +101,7 @@
 	void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
 	const unsigned int bsize = 128 / 8;
 	struct skcipher_walk walk;
-	bool fpu_enabled;
+	bool fpu_enabled = false;
 	unsigned int nbytes;
 	int err;
 
@@ -114,7 +115,7 @@
 		u128 last_iv;
 
 		fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-					     &walk, false, nbytes);
+					     &walk, fpu_enabled, nbytes);
 		/* Start of the last block. */
 		src += nbytes / bsize - 1;
 		dst += nbytes / bsize - 1;
@@ -147,10 +148,10 @@
 done:
 		u128_xor(dst, dst, (u128 *)walk.iv);
 		*(u128 *)walk.iv = last_iv;
-		glue_fpu_end(fpu_enabled);
 		err = skcipher_walk_done(&walk, nbytes);
 	}
 
+	glue_fpu_end(fpu_enabled);
 	return err;
 }
 EXPORT_SYMBOL_GPL(glue_cbc_decrypt_req_128bit);
@@ -161,7 +162,7 @@
 	void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
 	const unsigned int bsize = 128 / 8;
 	struct skcipher_walk walk;
-	bool fpu_enabled;
+	bool fpu_enabled = false;
 	unsigned int nbytes;
 	int err;
 
@@ -175,7 +176,7 @@
 		le128 ctrblk;
 
 		fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-					     &walk, false, nbytes);
+					     &walk, fpu_enabled, nbytes);
 
 		be128_to_le128(&ctrblk, (be128 *)walk.iv);
 
@@ -201,9 +202,10 @@
 		}
 
 		le128_to_be128((be128 *)walk.iv, &ctrblk);
-		glue_fpu_end(fpu_enabled);
 		err = skcipher_walk_done(&walk, nbytes);
 	}
+
+	glue_fpu_end(fpu_enabled);
 
 	if (nbytes) {
 		le128 ctrblk;
@@ -304,13 +306,7 @@
 	tweak_fn(tweak_ctx, walk.iv, walk.iv);
 
 	while (nbytes) {
-		fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-					     &walk, fpu_enabled,
-					     nbytes < bsize ? bsize : nbytes);
 		nbytes = __glue_xts_req_128bit(gctx, crypt_ctx, &walk);
-
-		glue_fpu_end(fpu_enabled);
-		fpu_enabled = false;
 
 		err = skcipher_walk_done(&walk, nbytes);
 		nbytes = walk.nbytes;

--
Gitblit v1.6.2