
Hi Sumit, Fabio, York,
On Fri, Jan 05, 2018 at 06:47:36AM +0000, Sumit Garg wrote:
Hi Clemens, York, Fabio,
-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Fabio Estevam Sent: Friday, January 05, 2018 3:27 AM To: York Sun york.sun@nxp.com Cc: Breno Matheus Lima breno.lima@nxp.com; u-boot@lists.denx.de; clemens.gruber@pqgruber.com; Fabio Estevam fabio.estevam@nxp.com Subject: [U-Boot] [PATCH v2] crypto/fsl: fix BLOB encapsulation and decapsulation
<snip>
int blob_decap(u8 *key_mod, u8 *src, u8 *dst, u32 len) {
- int ret, i = 0;
ALLOC_CACHE_ALIGN_BUFFER(u8, aligned_key_mod, 16);
u8 *aligned_src, *aligned_dst;
int ret, size, i = 0; u32 *desc;
printf("\nDecapsulating blob to get data\n");
- desc = malloc(sizeof(int) * MAX_CAAM_DESCSIZE);
- desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE); if (!desc) { debug("Not enough memory for descriptor allocation\n");
return -1;
}return -ENOMEM;
- inline_cnstr_jobdesc_blob_decap(desc, key_mod, src, dst, len);
- aligned_src = malloc_cache_aligned(BLOB_SIZE(len));
- aligned_dst = malloc_cache_aligned(len);
Please don't use malloc here as these blob_encap and blob_decap commands are used to blobify or deblobify images of maximum sizes upto 32 MB.
But u-boot malloc pool is of size:
/* Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2048 * 1024)
So please remove malloc from this patch for source and destination images as it will fail for larger images.
I could use ALLOC_CACHE_ALIGN_BUFFER to store the aligned_src and _dst buffers on the stack instead of the malloc pool.
Or would you rather remove the copying and require the caller of blob_encap/_decap to pass correctly aligned addresses?
York: Should I send a v3 or a fixup patch ontop of v2.
Thanks, Clemens