Re: [v2 PATCH] crypto: stm32 - Save and restore between each request

From: Linus Walleij
Date: Sat Feb 25 2023 - 18:15:57 EST


On Sat, Feb 25, 2023 at 1:01 AM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:

> I tested this on the Ux500 and sadly this happens
> already in probe():
(...)
> [ 2.828815] stm32-hash a03c2000.hash: Algo 0 : 0 failed
> [ 2.834144] stm32-hash: probe of a03c2000.hash failed with error -22

It turns out that this is because this:

- /* Export Context */
- u32 *hw_context;
+ /* hash state */
+ u32 hw_context[3 + HASH_CSR_REGISTER_NUMBER];

Makes struct stm32_hash_request_ctx 580 bytes
and that fails sanity check in ahash.c because
HASH_MAX_STATESIZE is 512.

I don't know the story behind why HASH_MAX_STATESIZE
is 512, the stm32 hash state contains a buffer of 256 bytes
so I guess either that buffer is a bit big or
HASH_MAX_STATESIZE is a bit small?

I'm happy to try to change either to make this fit.

Yours,
Linus Walleij