From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VgQAv-00010A-3i for mharc-grub-devel@gnu.org; Tue, 12 Nov 2013 21:27:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgQAm-0000vI-2F for grub-devel@gnu.org; Tue, 12 Nov 2013 21:27:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgQAe-0005v2-83 for grub-devel@gnu.org; Tue, 12 Nov 2013 21:27:15 -0500 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:45558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgQAe-0005ts-2F for grub-devel@gnu.org; Tue, 12 Nov 2013 21:27:08 -0500 Received: from mfilter9-d.gandi.net (mfilter9-d.gandi.net [217.70.178.138]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id A0EB541C067 for ; Wed, 13 Nov 2013 03:27:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter9-d.gandi.net Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter9-d.gandi.net (mfilter9-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 4dOXPBGfRqns for ; Wed, 13 Nov 2013 03:27:06 +0100 (CET) X-Originating-IP: 50.43.14.201 Received: from leaf (static-50-43-14-201.bvtn.or.frontiernet.net [50.43.14.201]) (Authenticated sender: josh@joshtriplett.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 59F0C41C054 for ; Wed, 13 Nov 2013 03:27:05 +0100 (CET) Date: Tue, 12 Nov 2013 18:27:03 -0800 From: Josh Triplett To: grub-devel@gnu.org Subject: [PATCH 4/4] efi: On x86-64, align the stack to a 16-byte boundary as required by ABI Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::197 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 02:27:23 -0000 The x86-64 ABI specification requires a 16-byte-aligned stack. In some cases, GCC emits code that assumes this alignment, which crashes if not aligned. The EFI firmware is also entitled to assume that stack alignment without checking, and some firmware does make that assumption. --- ChangeLog entry: 2013-11-13 Josh Triplett * grub-core/kern/x86_64/efi/startup.S (_start): Align the stack to a 16-byte boundary, as required by the x86-64 ABI, before calling grub_main. In some cases, GCC emits code that assumes this alignment, which crashes if not aligned. The EFI firmware is also entitled to assume that stack alignment without checking. grub-core/kern/x86_64/efi/startup.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/x86_64/efi/startup.S b/grub-core/kern/x86_64/efi/startup.S index f86f019..94bd6ae 100644 --- a/grub-core/kern/x86_64/efi/startup.S +++ b/grub-core/kern/x86_64/efi/startup.S @@ -29,7 +29,11 @@ start: _start: movq %rcx, EXT_C(grub_efi_image_handle)(%rip) movq %rdx, EXT_C(grub_efi_system_table)(%rip) - + mov %rsp, %rax + subq $8, %rsp + and $~0xf, %rsp + mov %rax, (%rsp) call EXT_C(grub_main) + mov (%rsp), %rsp ret -- 1.8.4.3