linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Brown <mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
To: Matt Fleming
	<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
	Linn Crosetto <linn-VXdhtT5mjnY@public.gmane.org>
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3] efi: Request desired alignment via the PE/COFF headers
Date: Thu, 18 Jun 2015 23:27:55 +0100	[thread overview]
Message-ID: <558345EB.8010408@fensystems.co.uk> (raw)
In-Reply-To: <20150618220241.GA2776-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>

On 18/06/15 23:02, Matt Fleming wrote:
> On Tue, 16 Jun, at 11:37:25AM, Linn Crosetto wrote:
>> I have been reverting this patch as a workaround. The fields need to be changed,
>> but I am not that familiar with the code. Maybe there is a way to use a
>> heuristic to calculate the best values based on init_sz?
>
> Linn, could you please provide some details of the system that you're
> booting this kernel on? EDK2 does not include any checks for this
> alignment requirement, which probably explains why no one else ever
> caught this issue.
>
> I can't think of any way to fix this without simply doing a revert of
> commit aeffc4928ea2 ("x86/efi: Request desired alignment via the PE/COFF
> headers"). Especially since that patch was an optimisation and not a bug
> fix.

I'm pretty sure that patch _is_ a bug fix, not just an optimisation.  It 
looks as though the commit log message was changed from what I 
originally wrote:

    The kernel will align itself to the nearest boundary specified by the
    kernel_alignment field in the bzImage header.  If the kernel is loaded
    to an address which is not sufficiently aligned, it will therefore use
    memory beyond that indicated solely by the init_size field.

    The PE/COFF headers now include a .bss section to describe the
    requirements of the init_size field, but do not currently expose the
    alignment requirement.  Consequently, a kernel loaded via the PE entry
    point may still end up overwriting unexpected areas of memory.

to

    The EFI boot stub goes to great pains to relocate the kernel image to
    an appropriately aligned address, as indicated by the ->kernel_alignment
    field in the bzImage header.  However, for the PE stub entry case, we
    can request that the EFI PE/COFF loader do the work for us.

If the patch is reverted, then I think it will cause undefined behaviour 
on some platforms (which happen to load the kernel to non-preferred 
alignment, and where the memory immediately after the loaded kernel 
happens to be in use for something).

Michael

  parent reply	other threads:[~2015-06-18 22:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10 15:59 [PATCH v3] efi: Request desired alignment via the PE/COFF headers Michael Brown
     [not found] ` <1405007963-520-1-git-send-email-mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-10 20:36   ` Matt Fleming
     [not found]     ` <20140710203633.GC5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-11  0:18       ` Michael Brown
     [not found]         ` <53BF2D63.60808-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-11  7:41           ` Matt Fleming
     [not found]             ` <20140711074117.GE5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-11 15:16               ` Michael Brown
     [not found]                 ` <53BFFFCE.5040002-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-14 13:10                   ` Matt Fleming
     [not found]                     ` <20140714131042.GJ5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-14 13:28                       ` Michael Brown
2015-06-15 21:43 ` Linn Crosetto
     [not found]   ` <loom.20150615T232724-11-eS7Uydv5nfjZ+VzJOa5vwg@public.gmane.org>
2015-06-16 16:19     ` Michael Brown
     [not found]       ` <55804C91.4030000-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2015-06-16 17:37         ` Linn Crosetto
     [not found]           ` <20150616173725.GE13153-QpTgeCMhooRo/CpIj0byZw@public.gmane.org>
2015-06-18 22:02             ` Matt Fleming
     [not found]               ` <20150618220241.GA2776-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-06-18 22:27                 ` Michael Brown [this message]
     [not found]                   ` <558345EB.8010408-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2015-06-19 12:21                     ` Matt Fleming
     [not found]                       ` <20150619122147.GC2776-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-06-19 12:25                         ` Michael Brown
     [not found]                           ` <55840A3B.3000400-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2015-07-15 14:11                             ` Matt Fleming
     [not found]                               ` <20150715141119.GA6955-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-07-15 16:56                                 ` Linn Crosetto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=558345EB.8010408@fensystems.co.uk \
    --to=mbrown-oviybiukjbuk421+scfkdq@public.gmane.org \
    --cc=linn-VXdhtT5mjnY@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).