[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240429060640.2451685-5-jiajie.ho@starfivetech.com>
Date: Mon, 29 Apr 2024 14:06:40 +0800
From: Jia Jie Ho <jiajie.ho@...rfivetech.com>
To: Herbert Xu <herbert@...dor.apana.org.au>,
"David S . Miller" <davem@...emloft.net>,
linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH -next 4/4] 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@...rfivetech.com>
---
drivers/crypto/starfive/jh7110-aes.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/starfive/jh7110-aes.c b/drivers/crypto/starfive/jh7110-aes.c
index 9d6e2f936f03..86a1a1fa9f8f 100644
--- a/drivers/crypto/starfive/jh7110-aes.c
+++ b/drivers/crypto/starfive/jh7110-aes.c
@@ -314,7 +314,7 @@ static int starfive_aes_read_authtag(struct starfive_cryp_ctx *ctx)
cryp->total_in, cryp->authsize, 1);
} else {
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;
@@ -753,14 +753,16 @@ static bool starfive_aes_check_unaligned(struct starfive_cryp_dev *cryp,
int i;
for_each_sg(src, tsg, sg_nents(src), i)
- if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
- !sg_is_last(tsg))
+ if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
+ (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
+ !sg_is_last(tsg)))
return true;
if (src != dst)
for_each_sg(dst, tsg, sg_nents(dst), i)
- if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
- !sg_is_last(tsg))
+ if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
+ (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
+ !sg_is_last(tsg)))
return true;
return false;
--
2.40.1
Powered by blists - more mailing lists