
From: Simon Glass <sjg@chromium.org> It isn't necessarily safe to move the kernel (up to) 2MB higher in memory. If the kernel is in a FIT, this may overwrite other data such as the devicetree. Use lmb (where available) as is done with other image relocations. Update the return value to provide more specific information on failure. Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/arm/lib/image.c | 15 +++++++++++---- include/image.h | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c index d78d704cb58..f97276a84c5 100644 --- a/arch/arm/lib/image.c +++ b/arch/arm/lib/image.c @@ -48,7 +48,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, if (!booti_is_valid(ih)) { puts("Bad Linux ARM64 Image magic!\n"); - return 1; + return -EPERM; } /* @@ -73,10 +73,17 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, * images->ep. Otherwise, relocate the image to the base of RAM * since memory below it is not accessible via the linear mapping. */ - if (!force_reloc && (le64_to_cpu(ih->flags) & BIT(3))) - dst = image - text_offset; - else + if (!force_reloc && (le64_to_cpu(ih->flags) & BIT(3))) { + if (IS_ENABLED(CONFIG_LMB)) { + dst = lmb_alloc(image_size, SZ_2M); + if (!dst) + return -ENOSPC; + } else { + dst = image - text_offset; + } + } else { dst = gd->bd->bi_dram[0].start; + } *relocated_addr = ALIGN(dst, SZ_2M) + text_offset; diff --git a/include/image.h b/include/image.h index 7f3ca1088de..a972e3f6921 100644 --- a/include/image.h +++ b/include/image.h @@ -1134,7 +1134,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end); * @start: Returns start address of image * @size : Returns size image * @force_reloc: Ignore image->ep field, always place image to RAM start - * Return: 0 if OK, 1 if the image was not recognised + * Return: 0 if OK, -EPERM image was not recognised, -ENOSPC if there was not + * enough lmb space */ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc); -- 2.43.0