Re: [PATCH 2/7] crypto: stm32 - add new algorithms support

From: Linus Walleij
Date: Thu Jul 06 2023 - 18:10:16 EST


Hi Thomas,

thanks for your patch! I overall like the looks of
the end result.

On Thu, Jul 6, 2023 at 9:38 AM Thomas BOURGOIN
<thomas.bourgoin@xxxxxxxxxxx> wrote:

> From: Thomas Bourgoin <thomas.bourgoin@xxxxxxxxxxx>
>
> Add the all SHA-2 (up to 512) and SHA-3 algorithm support.
> Update compatible table to add stm32mp13.
>
> Signed-off-by: Thomas Bourgoin <thomas.bourgoin@xxxxxxxxxxx>

I testes to apply this and boot the Skomer (U8500, Samsung
GT-S7710) This patch regresses the ux500 hash like this:

[ 3.612426] stm32-hash a03c2000.hash: allocated hmac(sha256) fallback
[ 4.236755] stm32-hash a03c2000.hash: allocated sha256 fallback
[ 4.269287] alg: ahash: stm32-sha256 test failed (wrong result) on
test vector 4, cfg="init+update+final aligned buffer"
[ 4.280273] alg: self-tests for sha256 using stm32-sha256 failed (rc=-22)
[ 4.280273] ------------[ cut here ]------------
[ 4.291748] WARNING: CPU: 0 PID: 100 at crypto/testmgr.c:5936
alg_test.part.0+0x4d0/0x4e0
[ 4.299987] alg: self-tests for sha256 using stm32-sha256 failed (rc=-22)
[ 4.299987] Modules linked in:
[ 4.309906] CPU: 0 PID: 100 Comm: cryptomgr_test Not tainted
6.4.0-rc1-00014-g3c85f4ad9472 #274
[ 4.318603] Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
[ 4.325561] unwind_backtrace from show_stack+0x10/0x14
[ 4.330810] show_stack from dump_stack_lvl+0x40/0x4c
[ 4.335876] dump_stack_lvl from __warn+0x94/0xc0
[ 4.340606] __warn from warn_slowpath_fmt+0x118/0x164
[ 4.345733] warn_slowpath_fmt from alg_test.part.0+0x4d0/0x4e0
[ 4.351684] alg_test.part.0 from cryptomgr_test+0x18/0x38
[ 4.357177] cryptomgr_test from kthread+0xd0/0xd4
[ 4.361968] kthread from ret_from_fork+0x14/0x2c
[ 4.366668] Exception stack(0xf0df5fb0 to 0xf0df5ff8)
[ 4.371734] 5fa0: 00000000
00000000 00000000 00000000
[ 4.379913] 5fc0: 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000
[ 4.388061] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 4.394744] ---[ end trace 0000000000000000 ]---
[ 4.669372] stm32-hash a03c2000.hash: allocated hmac(sha1) fallback
[ 5.131622] stm32-hash a03c2000.hash: allocated sha1 fallback
[ 5.156005] alg: ahash: stm32-sha1 test failed (wrong result) on
test vector 3, cfg="init+update+final aligned buffer"
[ 5.166778] alg: self-tests for sha1 using stm32-sha1 failed (rc=-22)
[ 5.166778] ------------[ cut here ]------------
[ 5.177947] WARNING: CPU: 0 PID: 115 at crypto/testmgr.c:5936
alg_test.part.0+0x4d0/0x4e0
[ 5.186187] alg: self-tests for sha1 using stm32-sha1 failed (rc=-22)
[ 5.186187] Modules linked in:
[ 5.195739] CPU: 0 PID: 115 Comm: cryptomgr_test Tainted: G
W 6.4.0-rc1-00014-g3c85f4ad9472 #274
[ 5.205902] Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
[ 5.212860] unwind_backtrace from show_stack+0x10/0x14
[ 5.218109] show_stack from dump_stack_lvl+0x40/0x4c
[ 5.223175] dump_stack_lvl from __warn+0x94/0xc0
[ 5.227874] __warn from warn_slowpath_fmt+0x118/0x164
[ 5.233032] warn_slowpath_fmt from alg_test.part.0+0x4d0/0x4e0
[ 5.238952] alg_test.part.0 from cryptomgr_test+0x18/0x38
[ 5.244445] cryptomgr_test from kthread+0xd0/0xd4
[ 5.249267] kthread from ret_from_fork+0x14/0x2c
[ 5.253967] Exception stack(0xf0f21fb0 to 0xf0f21ff8)
[ 5.259002] 1fa0: 00000000
00000000 00000000 00000000
[ 5.267181] 1fc0: 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000
[ 5.275360] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 5.282012] ---[ end trace 0000000000000000 ]---

This worked before the patch (verified).

> drivers/crypto/stm32/Kconfig | 2 +
> drivers/crypto/stm32/stm32-hash.c | 666 ++++++++++++++++++++++++------

The patch is a bit big so it is hard to see the problem, do you
think you can break it into increments?

Yours,
Linus Walleij