svn commit: r281321 - in stable/10: lib/libstand sys/boot/amd64 sys/boot/efi/libefi sys/boot/ficl
John Baldwin
jhb at FreeBSD.org
Thu Apr 9 19:36:08 UTC 2015
Author: jhb
Date: Thu Apr 9 19:36:06 2015
New Revision: 281321
URL: https://svnweb.freebsd.org/changeset/base/281321
Log:
MFC 279949:
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.
Modified:
stable/10/lib/libstand/Makefile
stable/10/sys/boot/amd64/Makefile.inc
stable/10/sys/boot/efi/libefi/Makefile
stable/10/sys/boot/ficl/Makefile
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/lib/libstand/Makefile
==============================================================================
--- stable/10/lib/libstand/Makefile Thu Apr 9 19:07:01 2015 (r281320)
+++ stable/10/lib/libstand/Makefile Thu Apr 9 19:36:06 2015 (r281321)
@@ -27,7 +27,7 @@ CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -m
CFLAGS.gcc+= -mpreferred-stack-boundary=2
.endif
.if ${MACHINE_CPUARCH} == "amd64"
-CFLAGS+= -fPIC
+CFLAGS+= -fPIC -mno-red-zone
.endif
.if ${MACHINE} == "pc98"
CFLAGS+= -Os
Modified: stable/10/sys/boot/amd64/Makefile.inc
==============================================================================
--- stable/10/sys/boot/amd64/Makefile.inc Thu Apr 9 19:07:01 2015 (r281320)
+++ stable/10/sys/boot/amd64/Makefile.inc Thu Apr 9 19:36:06 2015 (r281321)
@@ -5,7 +5,7 @@
BINDIR?= /boot
# See conf/kern.mk for the correct set of these
-CFLAGS+= -ffreestanding
+CFLAGS+= -ffreestanding -mno-red-zone
CFLAGS+= -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float
LDFLAGS+= -nostdlib
Modified: stable/10/sys/boot/efi/libefi/Makefile
==============================================================================
--- stable/10/sys/boot/efi/libefi/Makefile Thu Apr 9 19:07:01 2015 (r281320)
+++ stable/10/sys/boot/efi/libefi/Makefile Thu Apr 9 19:36:06 2015 (r281321)
@@ -9,7 +9,7 @@ SRCS= delay.c efi_console.c efinet.c efi
SRCS+= nullconsole.c comconsole.c
.if ${MACHINE_ARCH} == "amd64"
-CFLAGS+= -fPIC
+CFLAGS+= -fPIC -mno-red-zone
.endif
CFLAGS+= -I${.CURDIR}/../include
CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH}
Modified: stable/10/sys/boot/ficl/Makefile
==============================================================================
--- stable/10/sys/boot/ficl/Makefile Thu Apr 9 19:07:01 2015 (r281320)
+++ stable/10/sys/boot/ficl/Makefile Thu Apr 9 19:36:06 2015 (r281321)
@@ -19,6 +19,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
More information about the svn-src-stable-10
mailing list