Skip to content

Commit 8c87553

Browse files
ebiggersherbertx
authored andcommitted
crypto: starfive - remove unnecessary alignmask for ahashes
The crypto API's support for alignmasks for ahash algorithms is nearly useless, as its only effect is to cause the API to align the key and result buffers. The drivers that happen to be specifying an alignmask for ahash rarely actually need it. When they do, it's easily fixable, especially considering that these buffers cannot be used for DMA. In preparation for removing alignmask support from ahash, this patch makes the starfive driver no longer use it. This driver did actually rely on it, but only for storing to the result buffer using int stores in starfive_hash_copy_hash(). This patch makes starfive_hash_copy_hash() use put_unaligned() instead. (It really should use a specific endianness, but that's an existing bug.) Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2d91a83 commit 8c87553

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/crypto/starfive/jh7110-hash.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static int starfive_hash_copy_hash(struct ahash_request *req)
209209
data = (u32 *)req->result;
210210

211211
for (count = 0; count < mlen; count++)
212-
data[count] = readl(ctx->cryp->base + STARFIVE_HASH_SHARDR);
212+
put_unaligned(readl(ctx->cryp->base + STARFIVE_HASH_SHARDR),
213+
&data[count]);
213214

214215
return 0;
215216
}
@@ -628,7 +629,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
628629
CRYPTO_ALG_NEED_FALLBACK,
629630
.cra_blocksize = SHA224_BLOCK_SIZE,
630631
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
631-
.cra_alignmask = 3,
632632
.cra_module = THIS_MODULE,
633633
}
634634
},
@@ -658,7 +658,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
658658
CRYPTO_ALG_NEED_FALLBACK,
659659
.cra_blocksize = SHA224_BLOCK_SIZE,
660660
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
661-
.cra_alignmask = 3,
662661
.cra_module = THIS_MODULE,
663662
}
664663
},
@@ -687,7 +686,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
687686
CRYPTO_ALG_NEED_FALLBACK,
688687
.cra_blocksize = SHA256_BLOCK_SIZE,
689688
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
690-
.cra_alignmask = 3,
691689
.cra_module = THIS_MODULE,
692690
}
693691
},
@@ -717,7 +715,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
717715
CRYPTO_ALG_NEED_FALLBACK,
718716
.cra_blocksize = SHA256_BLOCK_SIZE,
719717
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
720-
.cra_alignmask = 3,
721718
.cra_module = THIS_MODULE,
722719
}
723720
},
@@ -746,7 +743,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
746743
CRYPTO_ALG_NEED_FALLBACK,
747744
.cra_blocksize = SHA384_BLOCK_SIZE,
748745
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
749-
.cra_alignmask = 3,
750746
.cra_module = THIS_MODULE,
751747
}
752748
},
@@ -776,7 +772,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
776772
CRYPTO_ALG_NEED_FALLBACK,
777773
.cra_blocksize = SHA384_BLOCK_SIZE,
778774
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
779-
.cra_alignmask = 3,
780775
.cra_module = THIS_MODULE,
781776
}
782777
},
@@ -805,7 +800,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
805800
CRYPTO_ALG_NEED_FALLBACK,
806801
.cra_blocksize = SHA512_BLOCK_SIZE,
807802
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
808-
.cra_alignmask = 3,
809803
.cra_module = THIS_MODULE,
810804
}
811805
},
@@ -835,7 +829,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
835829
CRYPTO_ALG_NEED_FALLBACK,
836830
.cra_blocksize = SHA512_BLOCK_SIZE,
837831
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
838-
.cra_alignmask = 3,
839832
.cra_module = THIS_MODULE,
840833
}
841834
},
@@ -864,7 +857,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
864857
CRYPTO_ALG_NEED_FALLBACK,
865858
.cra_blocksize = SM3_BLOCK_SIZE,
866859
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
867-
.cra_alignmask = 3,
868860
.cra_module = THIS_MODULE,
869861
}
870862
},
@@ -894,7 +886,6 @@ static struct ahash_engine_alg algs_sha2_sm3[] = {
894886
CRYPTO_ALG_NEED_FALLBACK,
895887
.cra_blocksize = SM3_BLOCK_SIZE,
896888
.cra_ctxsize = sizeof(struct starfive_cryp_ctx),
897-
.cra_alignmask = 3,
898889
.cra_module = THIS_MODULE,
899890
}
900891
},

0 commit comments

Comments
 (0)