aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/ficl
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2015-03-13 09:38:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2015-03-13 09:38:16 +0000
commitad06e987b147dc272e683a419ce5b4c39b2bd16b (patch)
tree93053abb082c635514f425a5b5501454f3e58bde /sys/boot/ficl
parent2530ed9e7009590ef585f627a8a14ad7cee796e8 (diff)
downloadsrc-ad06e987b147dc272e683a419ce5b4c39b2bd16b.tar.gz
src-ad06e987b147dc272e683a419ce5b4c39b2bd16b.zip
The System V ABI for amd64 allows functions to use space in a 128 byte
redzone below the stack pointer for scratch space and requires interrupt and signal frames to avoid overwriting it. However, EFI uses the Windows ABI which does not support this. As a result, interrupt handlers in EFI push their interrupt frames directly on top of the stack pointer. If the compiler used the red zone in a function in the EFI loader, then a device interrupt that occurred while that function was running could trash its local variables. In practice this happens fairly reliable when using gzipfs as an interrupt during decompression can trash the local variables in the inflate_table() function resulting in corrupted output or hangs. Fix this by disabling the redzone for amd64 EFI binaries. This requires building not only the loader but any libraries used by the loader without redzone support. Thanks to Jilles for pointing me at the redzone once I found the stack corruption. Differential Revision: https://reviews.freebsd.org/D2054 Reviewed by: imp MFC after: 2 weeks Sponsored by: Cisco Systems, Inc.
Notes
Notes: svn path=/head/; revision=279949
Diffstat (limited to 'sys/boot/ficl')
-rw-r--r--sys/boot/ficl/Makefile3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile
index 833cf99d8510..15baae3f4908 100644
--- a/sys/boot/ficl/Makefile
+++ b/sys/boot/ficl/Makefile
@@ -21,6 +21,9 @@ CFLAGS+= -ffreestanding
CFLAGS+= -march=i386
CFLAGS.gcc+= -mpreferred-stack-boundary=2
.endif
+.if ${MACHINE_CPUARCH} == "amd64"
+CFLAGS+= -mno-red-zone
+.endif
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
.endif