Commit c2b3e9b15700ca611fe9399f086c3b035ea2f763

Authored by Ye Li
1 parent 6fc914b2da

MLK-20467 imx8m: Fix issue for booting signed image through uuu

The SPL loads the FIT image FDT part to an address related with the device
block length. This length is 512 for SD/MMC and is 1 for other devices
like SDP, NOR, NAND, SPI, etc.
When signing FIT image, we use fixed address caculated by SD/MMC block length
to sign FDT part. Thus, when booting through uuu, this causes mismatch and
gets authentication failed.

Fix the issue by providing a override function for this FIT buffer address.
When secure boot is enabled, adjust the addresses of other devices to be same
with SD/MMC.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 710efd3ccb99e144bd30af8e1ee46459b4a54dd6)

Showing 2 changed files with 24 additions and 3 deletions Side-by-side Diff

arch/arm/mach-imx/spl.c
... ... @@ -295,6 +295,21 @@
295 295 hang();
296 296 }
297 297 }
  298 +
  299 +void* board_spl_fit_buffer_addr(ulong fit_size, int bl_len)
  300 +{
  301 + int align_len = ARCH_DMA_MINALIGN - 1;
  302 +
  303 + /* Some devices like SDP, NOR, NAND, SPI are using bl_len =1, so their fit address
  304 + * is different with SD/MMC, this cause mismatch with signed address. Thus, adjust
  305 + * the bl_len to align with SD/MMC.
  306 + */
  307 + if (bl_len < 512)
  308 + bl_len = 512;
  309 +
  310 + return (void *)((CONFIG_SYS_TEXT_BASE - fit_size - bl_len -
  311 + align_len) & ~align_len);
  312 +}
298 313 #endif
299 314  
300 315 #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT)
common/spl/spl_fit.c
... ... @@ -25,6 +25,13 @@
25 25 return size;
26 26 }
27 27  
  28 +__weak void* board_spl_fit_buffer_addr(ulong fit_size, int bl_len)
  29 +{
  30 + int align_len = ARCH_DMA_MINALIGN - 1;
  31 + return (void *)((CONFIG_SYS_TEXT_BASE - fit_size - bl_len -
  32 + align_len) & ~align_len);
  33 +}
  34 +
28 35 #ifdef CONFIG_DUAL_BOOTLOADER
29 36 extern int spl_fit_get_rbindex(const void *fit, int images);
30 37 #endif
... ... @@ -369,7 +376,7 @@
369 376 struct spl_image_info image_info;
370 377 int node = -1;
371 378 int images, ret;
372   - int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
  379 + int base_offset;
373 380 int index = 0;
374 381  
375 382 /*
... ... @@ -399,8 +406,7 @@
399 406 * For FIT with data embedded, data is loaded as part of FIT image.
400 407 * For FIT with external data, data is not loaded in this step.
401 408 */
402   - fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len -
403   - align_len) & ~align_len);
  409 + fit = board_spl_fit_buffer_addr(size, info->bl_len);
404 410 sectors = get_aligned_image_size(info, size, 0);
405 411 count = info->read(info, sector, sectors, fit);
406 412 debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n",