On Sat, Apr 26, 2025 at 06:50:43PM +0800, Herbert Xu wrote:
> Eric Biggers <ebigg...@kernel.org> wrote:
> >
> > +void sha256_blocks_arch(u32 state[SHA256_STATE_WORDS],
> > +                       const u8 *data, size_t nblocks)
> > +{
> > +       if (static_branch_likely(&have_sha256_x86) && crypto_simd_usable()) 
> > {
> > +               kernel_fpu_begin();
> > +               static_call(sha256_blocks_x86)(state, data, nblocks);
> > +               kernel_fpu_end();
> > +       } else {
> > +               sha256_blocks_generic(state, data, nblocks);
> > +       }
> 
> Why did you restore the SIMD fallback path? Please provide a real
> use-case for doing SHA2 in a hardirq or I'll just remove it again.

The SHA-256 library functions currently work in any context, and this patch
series preserves that behavior.  Changing that would be a separate change.

But also as I've explained before, for the library API the performance benefit
of removing the crypto_simd_usable() doesn't seem to be worth the footgun that
would be introduced.  Your position is, effectively, that if someone calls one
of the sha256*() functions from a hardirq, we should sometimes corrupt a random
task's FPU registers.  That's a really bad bug that is very difficult to
root-cause.  My position is that we should make it just work as expected.

Yes, no one *should* be doing SHA-256 in a hardirq.  But I don't think that
means we should corrupt a random task's FPU registers if someone doesn't follow
best practices, when we can easily make the API just work as expected.

- Eric

Reply via email to