Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cZInj-0007od-6S for mharc-grub-devel@gnu.org; Thu, 02 Feb 2017 09:55:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZInh-0007mm-75 for grub-devel@gnu.org; Thu, 02 Feb 2017 09:55:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZInd-0005l3-Ai for grub-devel@gnu.org; Thu, 02 Feb 2017 09:55:53 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:20997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZInd-0005kF-16 for grub-devel@gnu.org; Thu, 02 Feb 2017 09:55:49 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v12Etjil007332 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2017 14:55:45 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v12EtjfA017556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Feb 2017 14:55:45 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v12EtgZV023027; Thu, 2 Feb 2017 14:55:43 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:55:42 -0800 Date: Thu, 2 Feb 2017 15:55:38 +0100 From: Daniel Kiper To: "Vladimir 'phcoder' Serbinenko" Cc: Andrei Borzenkov , Konrad Rzeszutek Wilk , The development of GNU GRUB Subject: Re: [PATCH] i386/relocator: Align stack in grub_relocator64_efi relocator Message-ID: <20170202145538.GR16671@olila.local.net-space.pl> References: <1486045677-3515-1-git-send-email-daniel.kiper@oracle.com> 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-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 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:55:54 -0000 On Thu, Feb 02, 2017 at 02:48:31PM +0000, Vladimir 'phcoder' Serbinenko wrote: > On Thu, 2 Feb 2017, 15:43 Andrei Borzenkov wrote: > > > On Thu, Feb 2, 2017 at 5:27 PM, Daniel Kiper > > wrote: > > > 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 > > > + > > > > It sounds like it should be fixed on caller side instead. I mean, > > caller allocated some memory, we cannot just arbitrary adjust it now. > > It sounds wrong. > > > Unlike normal relocator, EFI relocator didn't use .RSP field but instead > uses EFI stack, so there is no other place to fix this. The other option is call instead of jmp below but it seems to me a less reliable thing. Daniel