[U-Boot] [PATCH 2/2] arm64: booti: allow to place kernel image anywhere in physical memory

Masahiro Yamada yamada.masahiro at socionext.com
Wed Feb 22 02:34:26 UTC 2017


At first, the ARM64 Linux booting requirement recommended that the
kernel image be placed text_offset bytes from 2MB aligned base near
the start of usable system RAM because memory below that base address
was unusable at that time.

This requirement was relaxed by Linux commit a7f8de168ace ("arm64:
allow kernel Image to be loaded anywhere in physical memory").
Since then, the bit 3 of the flags field indicates the tolerance
of the kernel physical placement.  If this bit is set, the 2MB
aligned base may be anywhere in physical memory.  For details, see
Documentation/arm64/booting.txt of Linux.

The booti command should be also relaxed to not expect the kernel
image at the start of the system RAM.  Even when booting older
kernel versions, it still makes sense to have some space below the
kernel.  For example, some firmware may sit at the start of the
system RAM.

After all, the most flexible way for booting the kernel is to respect
the original images->ep instead of gd->bd->bi_dram[0].start.  If
image->ep (which is the address given to the booti command) already
meets the address requirement, just use it.  If not, relocate the
kernel to the next 2MB aligned address.

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

 cmd/booti.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/booti.c b/cmd/booti.c
index f65f0e7..9408c34 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -11,6 +11,8 @@
 #include <image.h>
 #include <lmb.h>
 #include <mapmem.h>
+#include <linux/kernel.h>
+#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -54,7 +56,9 @@ static int booti_setup(bootm_headers_t *images)
 	 * If we are not at the correct run-time location, set the new
 	 * correct location and then move the image there.
 	 */
-	dst = gd->bd->bi_dram[0].start + le64_to_cpu(ih->text_offset);
+	dst = images->ep - ih->text_offset;
+	dst = ALIGN(dst, SZ_2M);
+	dst += ih->text_offset;
 
 	unmap_sysmem(ih);
 
-- 
1.9.1



More information about the U-Boot mailing list