Date: Mon, 18 Dec 2017 17:17:07 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r326934 - in stable/11/sys/boot: arm/uboot uboot/lib Message-ID: <201712181717.vBIHH75G007747@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Mon Dec 18 17:17:07 2017 New Revision: 326934 URL: https://svnweb.freebsd.org/changeset/base/326934 Log: MFC (conceptually) r326752, r326754: This is a direct commit to 11-stable, because the code has moved and the directories have been restructured in 12-current, but it just hand- applies the same patches to the corresponding files in their old locations. r326752: Save and restore r9 register in arm ubldr. In old gcc 4.2, r9 was a callee- saved register, but in arm EABI it may be either callee-saved or dedicated to some special purpose (such as a TLS pointer). It appears clang does not treat it as a callee-saved register (instead using it as another work register, similar to r12). Another important side effect of these changes is that saving an extra register in the push/pop statements keeps the stack aligned to an 8-byte boundary during the self_reloc() call, as it always should have been. As stated in the PR... Essentially the important caller-saved registers are pushed (r0, r1, r9, lr) before the relocation call, and popped after. Then r8/r9 are saved as usual for the syscall trampoline, and lr is stored in r8 (now free) as a callee-saved value before calling into `main`. The call to `main` can no longer be a tail call because we must restore r9 especially after main returns (although since we have used r8 to hold lr we must also restore this). r326754: When building for arm arches, set PKTALIGN to the max cache line size supported by the arch, to meet u-boot's requirement that I/O be done in cache-aligned chunks. PR: 223977 224008 Modified: stable/11/sys/boot/arm/uboot/start.S stable/11/sys/boot/uboot/lib/libuboot.h Modified: stable/11/sys/boot/arm/uboot/start.S ============================================================================== --- stable/11/sys/boot/arm/uboot/start.S Mon Dec 18 14:29:48 2017 (r326933) +++ stable/11/sys/boot/arm/uboot/start.S Mon Dec 18 17:17:07 2017 (r326934) @@ -46,11 +46,8 @@ _start: 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} + /* Save the arguments and return register before calling self_reloc */ + push {r0, r1, r9, lr} /* * Do self-relocation when the weak external symbol _DYNAMIC is non-NULL. @@ -68,22 +65,31 @@ _start: addne r1, r1, r0 /* r1 = dynamic section physaddr. */ blne _C_LABEL(self_reloc) /* Do reloc if _DYNAMIC is non-NULL. */ + /* Restore saved arguments */ + pop {r0, r1, r9, lr} + /* Hint where to look for the API signature */ ldr ip, =uboot_address str sp, [ip] - /* Save U-Boot's r8 and r9 */ + /* Save U-Boot's r8 and r9 for syscall trampoline */ ldr ip, =saved_regs - str r8, [ip, #0] - str r9, [ip, #4] + str r8, [ip, #0] /* old gd pointer (use to hold lr) */ + str r9, [ip, #4] /* new gd pointer */ /* - * 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). + * Start loader. Save return address first (r8 is available from + * trampoline save). */ - pop {r0, r1, lr} - b main + mov r8, lr + bl main + mov lr, r8 + + /* Restore U-Boot environment */ + ldr ip, =saved_regs + ldr r8, [ip, #0] + ldr r9, [ip, #4] + mov pc, lr /* * Data for self-relocation, in the text segment for pc-rel access. Modified: stable/11/sys/boot/uboot/lib/libuboot.h ============================================================================== --- stable/11/sys/boot/uboot/lib/libuboot.h Mon Dec 18 14:29:48 2017 (r326933) +++ stable/11/sys/boot/uboot/lib/libuboot.h Mon Dec 18 17:17:07 2017 (r326934) @@ -45,9 +45,16 @@ struct uboot_devdesc #define d_disk d_kind.disk /* - * Default network packet alignment in memory + * Default network packet alignment in memory. On arm arches packets must be + * aligned to cacheline boundaries. */ +#if defined(__aarch64__) +#define PKTALIGN 128 +#elif defined(__arm__) +#define PKTALIGN 64 +#else #define PKTALIGN 32 +#endif int uboot_getdev(void **vdev, const char *devspec, const char **path); char *uboot_fmtdev(void *vdev);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712181717.vBIHH75G007747>