Skip to contentSkip to conversation

crypto/fsl: fsl_rsa: Fix dcache issue in the driver

PATCH Superseded Gaurav Jain 1 participant 1 message Apr 29, 2022 Crypto API

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 crypto/fsl: fsl_rsa: Fix dcache issue in the driver

From: Ye Li <[email protected]>

issue:
CAAM fails with key error when perform Modular Exponentiation using PKHA Block in CAAM

Fix:
add flush and invalidate dcache for keys, signature and output decrypted data processed by CAAM.

Fixes 34276478f7 (DM: crypto/fsl - Add Freescale rsa DM driver)
---
 drivers/crypto/fsl/fsl_rsa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/crypto/fsl/fsl_rsa.c +9 -0
index 897ee855ea..38d4d5ddc4 100644
@@ -36,12 +36,21 @@ int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
 
 	inline_cnstr_jobdesc_pkha_rsaexp(desc, &pkin, out, sig_len);
 
+	flush_dcache_range((ulong)sig, (ulong)sig + sig_len);
+	flush_dcache_range((ulong)prop->modulus, (ulong)(prop->modulus) + keylen);
+	flush_dcache_range((ulong)prop->public_exponent,
+			   (ulong)(prop->public_exponent) + prop->exp_len);
+	flush_dcache_range((ulong)desc, (ulong)desc + (sizeof(uint32_t) * MAX_CAAM_DESCSIZE));
+	flush_dcache_range((ulong)out, (ulong)out + sig_len);
+
 	ret = run_descriptor_jr(desc);
 	if (ret) {
 		debug("%s: RSA failed to verify: %d\n", __func__, ret);
 		return -EFAULT;
 	}
 
+	invalidate_dcache_range((ulong)out, (ulong)out + sig_len);
+
 	return 0;
 }
 
Signature · 1 line
2.25.1