Commit 2c25ddb57a4f591f32e64d8d857bb7a67da8aa98
1 parent
c08b3c7621
Exists in
smarc_8mq_lf_v2020.04
and in
4 other branches
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) (cherry picked from commit f48835f0b6b801cb267b4c27a50136c93dfd3bcf)
Showing 2 changed files with 23 additions and 3 deletions Side-by-side Diff
arch/arm/mach-imx/spl.c
... | ... | @@ -349,6 +349,20 @@ |
349 | 349 | } |
350 | 350 | #endif |
351 | 351 | |
352 | +void* board_spl_fit_buffer_addr(ulong fit_size, int bl_len) | |
353 | +{ | |
354 | + int align_len = ARCH_DMA_MINALIGN - 1; | |
355 | + | |
356 | + /* Some devices like SDP, NOR, NAND, SPI are using bl_len =1, so their fit address | |
357 | + * is different with SD/MMC, this cause mismatch with signed address. Thus, adjust | |
358 | + * the bl_len to align with SD/MMC. | |
359 | + */ | |
360 | + if (bl_len < 512) | |
361 | + bl_len = 512; | |
362 | + | |
363 | + return (void *)((CONFIG_SYS_TEXT_BASE - fit_size - bl_len - | |
364 | + align_len) & ~align_len); | |
365 | +} | |
352 | 366 | #endif |
353 | 367 | |
354 | 368 | #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT) |
common/spl/spl_fit.c
... | ... | @@ -33,6 +33,13 @@ |
33 | 33 | return size; |
34 | 34 | } |
35 | 35 | |
36 | +__weak void* board_spl_fit_buffer_addr(ulong fit_size, int bl_len) | |
37 | +{ | |
38 | + int align_len = ARCH_DMA_MINALIGN - 1; | |
39 | + return (void *)((CONFIG_SYS_TEXT_BASE - fit_size - bl_len - | |
40 | + align_len) & ~align_len); | |
41 | +} | |
42 | + | |
36 | 43 | static int find_node_from_desc(const void *fit, int node, const char *str) |
37 | 44 | { |
38 | 45 | int child; |
... | ... | @@ -514,7 +521,7 @@ |
514 | 521 | struct spl_image_info image_info; |
515 | 522 | int node = -1; |
516 | 523 | int images, ret; |
517 | - int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1; | |
524 | + int base_offset; | |
518 | 525 | int index = 0; |
519 | 526 | int firmware_node; |
520 | 527 | |
... | ... | @@ -545,8 +552,7 @@ |
545 | 552 | * For FIT with data embedded, data is loaded as part of FIT image. |
546 | 553 | * For FIT with external data, data is not loaded in this step. |
547 | 554 | */ |
548 | - hsize = (size + info->bl_len + align_len) & ~align_len; | |
549 | - fit = spl_get_load_buffer(-hsize, hsize); | |
555 | + fit = board_spl_fit_buffer_addr(size, info->bl_len); | |
550 | 556 | sectors = get_aligned_image_size(info, size, 0); |
551 | 557 | count = info->read(info, sector, sectors, fit); |
552 | 558 | debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n", |