Re: [PATCH crypto-stable] crypto: arch/lib - limit simd usage to PAGE_SIZE chunks

From: Jason A. Donenfeld
Date: Wed Apr 22 2020 - 03:32:48 EST


On Tue, Apr 21, 2020 at 10:04 PM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> Seems this should just be a 'while' loop?
>
> while (bytes) {
> unsigned int todo = min_t(unsigned int, PAGE_SIZE, bytes);
>
> kernel_neon_begin();
> chacha_doneon(state, dst, src, todo, nrounds);
> kernel_neon_end();
>
> bytes -= todo;
> src += todo;
> dst += todo;
> }

The for(;;) is how it's done elsewhere in the kernel (that this patch
doesn't touch), because then we can break out of the loop before
having to increment src and dst unnecessarily. Likely a pointless
optimization as probably the compiler can figure out how to avoid
that. But maybe it can't. If you have a strong preference, I can
reactor everything to use `while (bytes)`, but if you don't care,
let's keep this as-is. Opinion?

Jason