Re: [PATCH v2 05/19] crypto: x86/crc - limit FPU preemption

From: Herbert Xu
Date: Wed Oct 12 2022 - 22:00:28 EST


On Wed, Oct 12, 2022 at 04:59:17PM -0500, Robert Elliott wrote:
>
> @@ -170,9 +179,17 @@ static int __crc32c_pcl_intel_finup(u32 *crcp, const u8 *data, unsigned int len,
> u8 *out)
> {
> if (len >= CRC32C_PCL_BREAKEVEN && crypto_simd_usable()) {
> - kernel_fpu_begin();
> - *(__le32 *)out = ~cpu_to_le32(crc_pcl(data, len, *crcp));
> - kernel_fpu_end();
> + do {
> + unsigned int chunk = min(len, FPU_BYTES);
> +
> + kernel_fpu_begin();
> + *crcp = crc_pcl(data, chunk, *crcp);

How about storing the intermediate result in a local variable
instead of overwriting *crcp?

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt