Since mv_hash_final_fallback() uses ctx->state, read out the digest state register before calling it.
Unified · Split
| @@ -423,6 +423,15 @@ out: · 422 unmodified lines | |||
| 423 | return rc; | 423 | return rc; |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | static void mv_save_digest_state(struct mv_req_hash_ctx *ctx) | ||
| 427 | { | ||
| 428 | ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A); | ||
| 429 | ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B); | ||
| 430 | ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C); | ||
| 431 | ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D); | ||
| 432 | ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E); | ||
| 433 | } | ||
| 434 | |||
| 426 | static void mv_hash_algo_completion(void) | 435 | static void mv_hash_algo_completion(void) |
| 427 | { | 436 | { |
| 428 | struct ahash_request *req = ahash_request_cast(cpg->cur_req); | 437 | struct ahash_request *req = ahash_request_cast(cpg->cur_req); |
| @@ -437,14 +446,12 @@ static void mv_hash_algo_completion(void) · 8 unmodified lines | |||
| 437 | memcpy(req->result, cpg->sram + SRAM_DIGEST_BUF, | 446 | memcpy(req->result, cpg->sram + SRAM_DIGEST_BUF, |
| 438 | crypto_ahash_digestsize(crypto_ahash_reqtfm | 447 | crypto_ahash_digestsize(crypto_ahash_reqtfm |
| 439 | (req))); | 448 | (req))); |
| 440 | } else | 449 | } else { |
| 450 | mv_save_digest_state(ctx); | ||
| 441 | mv_hash_final_fallback(req); | 451 | mv_hash_final_fallback(req); |
| 452 | } | ||
| 442 | } else { | 453 | } else { |
| 443 | ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A); | 454 | mv_save_digest_state(ctx); |
| 444 | ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B); | ||
| 445 | ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C); | ||
| 446 | ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D); | ||
| 447 | ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E); | ||
| 448 | } | 455 | } |
| 449 | } | 456 | } |
| 450 | 457 | ||