[U-Boot] [PATCH v1 6/9] crypto: fsl: Allocate memory for descriptor from main memory
York Sun
york.sun at nxp.com
Mon May 15 16:16:06 UTC 2017
When U-Boot runs at EL2 on ARMv8, OCRAM is in secure world on some
SoCs by default. Allocation of memory from OCRAM causes failure in
this case. Since main memory is available, allocating memory
from heap is successful.
Signed-off-by: Sumit Garg <sumit.garg at nxp.com>
Signed-off-by: York Sun <york.sun at nxp.com>
---
drivers/crypto/fsl/fsl_rsa.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c
index 32c059f..5192267 100644
--- a/drivers/crypto/fsl/fsl_rsa.c
+++ b/drivers/crypto/fsl/fsl_rsa.c
@@ -48,8 +48,14 @@ int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
{
uint32_t keylen;
struct pk_in_params pkin;
- uint32_t desc[MAX_CAAM_DESCSIZE];
- int ret;
+ uint32_t *desc;
+ int ret = 0;
+
+ desc = malloc(MAX_CAAM_DESCSIZE);
+ if (!desc) {
+ printf("RSA DESC: malloc failed for RSA descriptor\n");
+ return -ENOMEM;
+ }
/* Length in bytes */
keylen = prop->num_bits / 8;
@@ -66,10 +72,11 @@ int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
ret = run_descriptor_jr(desc);
if (ret) {
debug("%s: RSA failed to verify: %d\n", __func__, ret);
- return -EFAULT;
+ ret = -EFAULT;
}
+ free(desc);
- return 0;
+ return ret;
}
static const struct mod_exp_ops fsl_mod_exp_ops = {
--
2.7.4
More information about the U-Boot
mailing list