Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cZIN6-0002WT-Ro for mharc-grub-devel@gnu.org; Thu, 02 Feb 2017 09:28:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIN4-0002Ul-JL for grub-devel@gnu.org; Thu, 02 Feb 2017 09:28:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIN1-0002Tw-Eg for grub-devel@gnu.org; Thu, 02 Feb 2017 09:28:22 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:31639) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIN1-0002TH-5H for grub-devel@gnu.org; Thu, 02 Feb 2017 09:28:19 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v12ESDmS003900 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2017 14:28:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v12ESC4L004463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2017 14:28:13 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v12ESBtL029245; Thu, 2 Feb 2017 14:28:11 GMT Received: from olila.local.net-space.pl (/10.175.161.206) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Feb 2017 06:28:11 -0800 From: Daniel Kiper To: grub-devel@gnu.org Cc: arvidjaar@gmail.com, konrad.wilk@oracle.com, phcoder@gmail.com Subject: [PATCH] i386/relocator: Align stack in grub_relocator64_efi relocator Date: Thu, 2 Feb 2017 15:27:57 +0100 Message-Id: <1486045677-3515-1-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2017 14:28:23 -0000 Unified Extensible Firmware Interface Specification, Version 2.6, section 2.3.4, x64 Platforms, boot services, says among others: The stack must be 16-byte aligned. So, do it. Otherwise OS may boot only by chance as it happens right now. Signed-off-by: Daniel Kiper --- grub-core/lib/i386/relocator64.S | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S index 75725cf..148f38a 100644 --- a/grub-core/lib/i386/relocator64.S +++ b/grub-core/lib/i386/relocator64.S @@ -73,14 +73,22 @@ VARIABLE(grub_relocator64_rsp) movq %rax, %rsp +#ifdef GRUB_MACHINE_EFI + jmp LOCAL(skip_efi_stack_align) + /* - * Here is grub_relocator64_efi_start() entry point. - * Following code is shared between grub_relocator64_efi_start() + * Here is grub_relocator64_efi_start() entry point. Most of the + * code below is shared between grub_relocator64_efi_start() * and grub_relocator64_start(). * - * Think twice before changing anything below!!! + * Think twice before changing anything there!!! */ VARIABLE(grub_relocator64_efi_start) + /* Align the stack as UEFI spec requires. */ + andq $~15, %rsp + +LOCAL(skip_efi_stack_align): +#endif /* mov imm64, %rax */ .byte 0x48 .byte 0xb8 @@ -128,8 +136,10 @@ LOCAL(jump_addr): VARIABLE(grub_relocator64_rip) .quad 0 +#ifdef GRUB_MACHINE_EFI /* Here grub_relocator64_efi_start() ends. Ufff... */ VARIABLE(grub_relocator64_efi_end) +#endif #ifndef __x86_64__ .p2align 4 -- 1.7.10.4