Date: Thu, 21 Feb 2019 02:46:32 +0000 (UTC) From: Kyle Evans <kevans@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: r344409 - in stable/11/stand/efi: boot1 loader/arch/arm64 Message-ID: <201902210246.x1L2kW7g086031@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Thu Feb 21 02:46:32 2019 New Revision: 344409 URL: https://svnweb.freebsd.org/changeset/base/344409 Log: MFC r338337: Fix lualoader on arm64 Lua has a few places where it allocates a large buffer on the stack. This is normally fine, except there are a few places where there can be multiple frames with this buffer. This can cause a stack overflow on some arm64 SoCs. Fix this by allocating our own stack in loader.efi large enough for these objects. The required size has been found by tracing how the stack pointer changes in a virtual machine and found to be no larger than 50kB. A larger stack is allocated to reduce the likelihood of overflow from future changes. Modified: stable/11/stand/efi/boot1/Makefile stable/11/stand/efi/loader/arch/arm64/start.S Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/efi/boot1/Makefile ============================================================================== --- stable/11/stand/efi/boot1/Makefile Thu Feb 21 02:43:48 2019 (r344408) +++ stable/11/stand/efi/boot1/Makefile Thu Feb 21 02:46:32 2019 (r344409) @@ -6,6 +6,7 @@ PROG= boot1.sym INTERNALPROG= WARNS?= 6 +CFLAGS+= -DEFI_BOOT1 # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead Modified: stable/11/stand/efi/loader/arch/arm64/start.S ============================================================================== --- stable/11/stand/efi/loader/arch/arm64/start.S Thu Feb 21 02:43:48 2019 (r344408) +++ stable/11/stand/efi/loader/arch/arm64/start.S Thu Feb 21 02:46:32 2019 (r344409) @@ -160,6 +160,23 @@ _start: ldp x0, x1, [sp], #16 +#ifndef EFI_BOOT1 + /* + * Load the stack to use. The default stack may be too small for + * the lua loader. + */ + adr x2, initstack_end + mov sp, x2 +#endif + bl efi_main 1: b 1b + +#ifndef EFI_BOOT1 +.bss + .align 4 +initstack: + .space (64 * 1024) +initstack_end: +#endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902210246.x1L2kW7g086031>