From: jiajie.ho Date: Wed, 10 Aug 2022 07:39:41 +0000 (+0800) Subject: CR_1675:crypto:starfive: Add iv_out read after encryption X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b34565c3762cab6eba7551fbfd519aa682094693;p=platform%2Fkernel%2Flinux-starfive.git CR_1675:crypto:starfive: Add iv_out read after encryption Add iv_out read required by Linux Self Test from hw engine after AES encryption has been completed. Signed-off-by: jiajie.ho --- diff --git a/drivers/crypto/starfive/jh7110/jh7110-aes.c b/drivers/crypto/starfive/jh7110/jh7110-aes.c index 1aa8573..19cd4ea 100644 --- a/drivers/crypto/starfive/jh7110/jh7110-aes.c +++ b/drivers/crypto/starfive/jh7110/jh7110-aes.c @@ -257,6 +257,19 @@ static int jh7110_cryp_hw_write_iv(struct jh7110_sec_ctx *ctx, u32 *iv) return 0; } +static void jh7110_cryp_hw_get_iv(struct jh7110_sec_ctx *ctx, u32 *iv) +{ + struct jh7110_sec_dev *sdev = ctx->sdev; + + if (!iv) + return; + + iv[0] = jh7110_sec_read(sdev, JH7110_AES_IV0); + iv[1] = jh7110_sec_read(sdev, JH7110_AES_IV1); + iv[2] = jh7110_sec_read(sdev, JH7110_AES_IV2); + iv[3] = jh7110_sec_read(sdev, JH7110_AES_IV3); +} + static void jh7110_cryp_hw_write_ctr(struct jh7110_sec_ctx *ctx, u32 *ctr) { struct jh7110_sec_dev *sdev = ctx->sdev; @@ -538,6 +551,9 @@ static int jh7110_cryp_finish_req(struct jh7110_sec_ctx *ctx, int err) err = jh7110_cryp_read_auth_tag(ctx); } + if (!err && (is_cbc(rctx) || is_ctr(rctx))) + jh7110_cryp_hw_get_iv(ctx, (void *)rctx->req.sreq->iv); + if (is_gcm(rctx) || is_ccm(rctx)) crypto_finalize_aead_request(ctx->sdev->engine, rctx->req.areq, err); else