From owner-svn-src-head@FreeBSD.ORG Fri Mar 13 09:38:18 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8708AE75; Fri, 13 Mar 2015 09:38:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F0EDAE0; Fri, 13 Mar 2015 09:38:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2D9cHRY077150; Fri, 13 Mar 2015 09:38:17 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2D9cGYU077146; Fri, 13 Mar 2015 09:38:16 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201503130938.t2D9cGYU077146@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 13 Mar 2015 09:38:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279949 - in head: lib/libstand sys/boot/amd64 sys/boot/efi/libefi sys/boot/ficl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2015 09:38:18 -0000 Author: jhb Date: Fri Mar 13 09:38:16 2015 New Revision: 279949 URL: https://svnweb.freebsd.org/changeset/base/279949 Log: 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. Modified: head/lib/libstand/Makefile head/sys/boot/amd64/Makefile.inc head/sys/boot/efi/libefi/Makefile head/sys/boot/ficl/Makefile Modified: head/lib/libstand/Makefile ============================================================================== --- head/lib/libstand/Makefile Fri Mar 13 09:03:25 2015 (r279948) +++ head/lib/libstand/Makefile Fri Mar 13 09:38:16 2015 (r279949) @@ -28,7 +28,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: head/sys/boot/amd64/Makefile.inc ============================================================================== --- head/sys/boot/amd64/Makefile.inc Fri Mar 13 09:03:25 2015 (r279948) +++ head/sys/boot/amd64/Makefile.inc Fri Mar 13 09:38:16 2015 (r279949) @@ -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: head/sys/boot/efi/libefi/Makefile ============================================================================== --- head/sys/boot/efi/libefi/Makefile Fri Mar 13 09:03:25 2015 (r279948) +++ head/sys/boot/efi/libefi/Makefile Fri Mar 13 09:38:16 2015 (r279949) @@ -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: head/sys/boot/ficl/Makefile ============================================================================== --- head/sys/boot/ficl/Makefile Fri Mar 13 09:03:25 2015 (r279948) +++ head/sys/boot/ficl/Makefile Fri Mar 13 09:38:16 2015 (r279949) @@ -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