svn commit: r323409 - in stable/11/sys/boot: arm/uboot uboot/common
Ian Lepore
ian at FreeBSD.org
Mon Sep 11 00:55:20 UTC 2017
Author: ian
Date: Mon Sep 11 00:55:18 2017
New Revision: 323409
URL: https://svnweb.freebsd.org/changeset/base/323409
Log:
MFC r316374, r316377:
Preserve the registers containing argc, argv, and return address values
passed in from u-boot across the call to self_reloc and any other early-init
code, and restore them before calling main().
Correct a comment... the stack used by ubldr is the same stack u-boot was
running on when it jumped to the ubldr entry point. None of the arches
that use this code set up a different stack in their start.S routines.
Modified:
stable/11/sys/boot/arm/uboot/start.S
stable/11/sys/boot/uboot/common/main.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/boot/arm/uboot/start.S
==============================================================================
--- stable/11/sys/boot/arm/uboot/start.S Mon Sep 11 00:51:47 2017 (r323408)
+++ stable/11/sys/boot/arm/uboot/start.S Mon Sep 11 00:55:18 2017 (r323409)
@@ -45,6 +45,13 @@ _start:
orr ip, ip, #(CPU_CONTROL_AFLT_ENABLE)
mcr p15, 0, ip, c1, c0, 0
#endif
+
+ /*
+ * Save r0 and r1 (argc and argv passed from u-boot), and lr (trashed
+ * by the call to self_reloc below) until we're ready to call main().
+ */
+ push {r0, r1, lr}
+
/*
* Do self-relocation when the weak external symbol _DYNAMIC is non-NULL.
* When linked as a dynamic relocatable file, the linker automatically
@@ -71,9 +78,11 @@ _start:
str r9, [ip, #4]
/*
+ * First restore argc, argv, and the u-boot return address, then
* Start loader. This is basically a tail-recursion call; if main()
* returns, it returns to u-boot (which reports the value returned r0).
*/
+ pop {r0, r1, lr}
b main
/*
Modified: stable/11/sys/boot/uboot/common/main.c
==============================================================================
--- stable/11/sys/boot/uboot/common/main.c Mon Sep 11 00:51:47 2017 (r323408)
+++ stable/11/sys/boot/uboot/common/main.c Mon Sep 11 00:55:18 2017 (r323409)
@@ -416,7 +416,9 @@ main(int argc, char **argv)
/*
* Initialise the heap as early as possible. Once this is done,
- * alloc() is usable. The stack is buried inside us, so this is safe.
+ * alloc() is usable. We are using the stack u-boot set up near the top
+ * of physical ram; hopefully there is sufficient space between the end
+ * of our bss and the bottom of the u-boot stack to avoid overlap.
*/
uboot_heap_start = round_page((uintptr_t)end);
uboot_heap_end = uboot_heap_start + 512 * 1024;
More information about the svn-src-stable
mailing list