1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-23 00:20:52 -05:00

crypto: starfive - Use fallback for unaligned dma access

Dma address mapping fails on unaligned scatterlist offset. Use sw
fallback for these cases.

Signed-off-by: Jia Jie Ho <jiajie.ho@starfivetech.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Jia Jie Ho 2024-04-29 14:06:40 +08:00 committed by Herbert Xu
parent d7f01649f4
commit f8c423bab9

View file

@ -314,7 +314,7 @@ static int starfive_aes_read_authtag(struct starfive_cryp_ctx *ctx)
cryp->total_in, cryp->authsize, 1); cryp->total_in, cryp->authsize, 1);
} else { } else {
if (crypto_memneq(cryp->tag_in, cryp->tag_out, cryp->authsize)) if (crypto_memneq(cryp->tag_in, cryp->tag_out, cryp->authsize))
return dev_err_probe(cryp->dev, -EBADMSG, "Failed tag verification\n"); return -EBADMSG;
} }
return 0; return 0;
@ -753,14 +753,16 @@ static bool starfive_aes_check_unaligned(struct starfive_cryp_dev *cryp,
int i; int i;
for_each_sg(src, tsg, sg_nents(src), i) for_each_sg(src, tsg, sg_nents(src), i)
if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) && if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
!sg_is_last(tsg)) (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
!sg_is_last(tsg)))
return true; return true;
if (src != dst) if (src != dst)
for_each_sg(dst, tsg, sg_nents(dst), i) for_each_sg(dst, tsg, sg_nents(dst), i)
if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) && if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
!sg_is_last(tsg)) (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
!sg_is_last(tsg)))
return true; return true;
return false; return false;