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(-)
@@ -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;
@@ -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);