Commit 3c40cdb0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull crypto fixes from Herbert Xu:
 "This fixes a potential scheduling latency problem for the algorithms
  used by WireGuard"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: arch/nhpoly1305 - process in explicit 4k chunks
  crypto: arch/lib - limit simd usage to 4k chunks
parents dc56c5ac a9a8ba90
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -91,9 +91,17 @@ void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
		return;
	}

	do {
		unsigned int todo = min_t(unsigned int, bytes, SZ_4K);

		kernel_neon_begin();
	chacha_doneon(state, dst, src, bytes, nrounds);
		chacha_doneon(state, dst, src, todo, nrounds);
		kernel_neon_end();

		bytes -= todo;
		src += todo;
		dst += todo;
	} while (bytes);
}
EXPORT_SYMBOL(chacha_crypt_arch);

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static int nhpoly1305_neon_update(struct shash_desc *desc,
		return crypto_nhpoly1305_update(desc, src, srclen);

	do {
		unsigned int n = min_t(unsigned int, srclen, PAGE_SIZE);
		unsigned int n = min_t(unsigned int, srclen, SZ_4K);

		kernel_neon_begin();
		crypto_nhpoly1305_update_helper(desc, src, n, _nh_neon);
+11 −4
Original line number Diff line number Diff line
@@ -160,13 +160,20 @@ void poly1305_update_arch(struct poly1305_desc_ctx *dctx, const u8 *src,
		unsigned int len = round_down(nbytes, POLY1305_BLOCK_SIZE);

		if (static_branch_likely(&have_neon) && do_neon) {
			do {
				unsigned int todo = min_t(unsigned int, len, SZ_4K);

				kernel_neon_begin();
			poly1305_blocks_neon(&dctx->h, src, len, 1);
				poly1305_blocks_neon(&dctx->h, src, todo, 1);
				kernel_neon_end();

				len -= todo;
				src += todo;
			} while (len);
		} else {
			poly1305_blocks_arm(&dctx->h, src, len, 1);
		}
			src += len;
		}
		nbytes %= POLY1305_BLOCK_SIZE;
	}

+11 −3
Original line number Diff line number Diff line
@@ -87,9 +87,17 @@ void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
	    !crypto_simd_usable())
		return chacha_crypt_generic(state, dst, src, bytes, nrounds);

	do {
		unsigned int todo = min_t(unsigned int, bytes, SZ_4K);

		kernel_neon_begin();
	chacha_doneon(state, dst, src, bytes, nrounds);
		chacha_doneon(state, dst, src, todo, nrounds);
		kernel_neon_end();

		bytes -= todo;
		src += todo;
		dst += todo;
	} while (bytes);
}
EXPORT_SYMBOL(chacha_crypt_arch);

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static int nhpoly1305_neon_update(struct shash_desc *desc,
		return crypto_nhpoly1305_update(desc, src, srclen);

	do {
		unsigned int n = min_t(unsigned int, srclen, PAGE_SIZE);
		unsigned int n = min_t(unsigned int, srclen, SZ_4K);

		kernel_neon_begin();
		crypto_nhpoly1305_update_helper(desc, src, n, _nh_neon);
Loading