crypto: omap-sham - fix digcnt register handling with export/import
authorTero Kristo <t-kristo@ti.com>
Mon, 7 Sep 2020 07:56:24 +0000 (10:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:07:02 +0000 (09:07 +0100)
[ Upstream commit 3faf757bad75f3fc1b2736f0431e295a073a7423 ]

Running export/import for hashes in peculiar order (mostly done by
openssl) can mess up the internal book keeping of the OMAP SHA core.
Fix by forcibly writing the correct DIGCNT back to hardware. This issue
was noticed while transitioning to openssl 1.1 support.

Fixes: 0d373d603202 ("crypto: omap-sham - Add OMAP4/AM33XX SHAM Support")
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/omap-sham.c

index 4e38b87c3228467581cddb5739a6f93fcaa52957..e34e9561e77d6a76d4fd5c53233b91c653fe202e 100644 (file)
@@ -455,6 +455,9 @@ static void omap_sham_write_ctrl_omap4(struct omap_sham_dev *dd, size_t length,
        struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
        u32 val, mask;
 
+       if (likely(ctx->digcnt))
+               omap_sham_write(dd, SHA_REG_DIGCNT(dd), ctx->digcnt);
+
        /*
         * Setting ALGO_CONST only for the first iteration and
         * CLOSE_HASH only for the last one. Note that flags mode bits