<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-text-html" lang="x-unicode">
<div class="moz-text-html" lang="x-unicode">
<pre>Hi Herbert,
I'm working on the patch for STM32MP13. </pre>
<div class="moz-cite-prefix">
<pre>On Sat, Mar 11, 2023 at 10:09 AM Herbert Xu <a class="moz-txt-link-rfc2396E" href="mailto:herbert@gondor.apana.org.au"><herbert@gondor.apana.org.au></a> wrote:</pre>
</div>
<blockquote type="cite"
cite="mid:E1pavED-002xbf-LL@formenos.hmeau.com">
<pre class="moz-quote-pre" wrap="">The Crypto API hashing paradigm requires the hardware state to
be exported between *each* request because multiple unrelated
hashes may be processed concurrently.
The stm32 hardware is capable of producing the hardware hashing
state but it was only doing it in the export function. This is
not only broken for export as you can't export a kernel pointer
and reimport it, but it also means that concurrent hashing was
fundamentally broken.
Fix this by moving the saving and restoring of hardware hash
state between each and every hashing request.
Fixes: 8a1012d3f2ab ("crypto: stm32 - Support for STM32 HASH module")
Reported-by: Li kunyu <a class="moz-txt-link-rfc2396E" href="mailto:kunyu@nfschina.com"><kunyu@nfschina.com></a>
Signed-off-by: Herbert Xu <a class="moz-txt-link-rfc2396E" href="mailto:herbert@gondor.apana.org.au"><herbert@gondor.apana.org.au></a>
---
drivers/crypto/stm32/stm32-hash.c | 164 ++++++++++++--------------------------
1 file changed, 56 insertions(+), 108 deletions(-)
diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index f898ec62b459..17183f631bb4 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -135,7 +135,7 @@ struct stm32_hash_state {
u8 buffer[HASH_BUFLEN] __aligned(4);
/* hash state */
- u32 *hw_context;
+ u32 hw_context[3 + HASH_CSR_REGISTER_NUMBER];
};
</pre>
</blockquote>
<pre>The version of HASH implemented in the STM32MP13 provides new algorithms (SHA512, SHA3, ...).
Because of that, the constant HASH_CSR_REGISTER_NUMBER increases (from 54 to 103).
Hence, the size of stm32_hash_state is equal to 688 which is bigger than HASH_MAX_STATESIZE(=512)
and the driver fails to register the algorithms.
Is there any reasons why HASH_MAX_STATESIZE is set to 512 ?
I only see it used to define static arrays, so maybe it could be set to 1024.
BR
Thomas Bourgoin
</pre>
</div>
<pre>
</pre>
</div>
</body>
</html>