linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] arm64/efi: efistub: jump to 'stext' directly, not through the header
Date: Fri, 10 Oct 2014 13:19:18 +0100	[thread overview]
Message-ID: <20141010121918.GA5294@leverpostej> (raw)
In-Reply-To: <CAKv+Gu_mx3uWqnRESAjqz6MdUJqBSjgeMCdnpzKiRQ+1FxUjCQ@mail.gmail.com>

On Fri, Oct 10, 2014 at 12:52:32PM +0100, Ard Biesheuvel wrote:
> On 10 October 2014 12:49, Mark Rutland <mark.rutland@arm.com> wrote:
> > On Thu, Oct 09, 2014 at 08:03:52PM +0100, Ard Biesheuvel wrote:
> >> On 9 October 2014 19:23, Mark Rutland <mark.rutland@arm.com> wrote:
> >> > Hi Ard,
> >> >
> >> > On Wed, Oct 08, 2014 at 03:11:27PM +0100, Ard Biesheuvel wrote:
> >> >> After the EFI stub has done its business, it jumps into the kernel by
> >> >> branching to offset #0 of the loaded Image, which is where it expects
> >> >> to find the header containing a 'branch to stext' instruction.
> >> >>
> >> >> However, the UEFI spec 2.1.1 states the following regarding PE/COFF
> >> >> image loading:
> >> >> "A UEFI image is loaded into memory through the LoadImage() Boot
> >> >> Service. This service loads an image with a PE32+ format into memory.
> >> >> This PE32+ loader is required to load all sections of the PE32+ image
> >> >> into memory."
> >> >>
> >> >> In other words, it is /not/ required to load parts of the image that are
> >> >> not covered by a PE/COFF section, so it may not have loaded the header
> >> >> at the expected offset, as it is not covered by any PE/COFF section.
> >> >
> >> > What does this mean for handle_kernel_image? Given we might not have
> >> > _text through to _stext mapped, do we not need to take that into
> >> > account?
> >> >
> >>
> >> Actually, handle_kernel_image() does not interpret the header, it just
> >> copies it along with the rest of the image if it needs to be
> >> relocated, so I don't see an issue there.
> >
> > Sorry, I wasn't clear enough with my concern. My concern was whether we
> > had any guarantee _something_ was mapped for the address range covering
> > efi_head to stext.
> >
> > So long as _something_ is mapped there, we're ok -- handle_kernel_image
> > will just copy some garbage along with the usable portion of the kernel.
> >
> 
> Indeed.
> 
> > But if the EFI loader is allowed to load stext at the precise start of
> > RAM (or anywhere not in the idmap), in attempting the copy we'd try to
> > access unmapped addresses.
> >
> > So if that's a possibility, we need to shrink the copy to cover stext
> > to _edata rather than _text to edata.
> >
> > Does that make sense?
> >
> 
> That cannot happen. The PE/COFF .text section's positive relative
> virtual offset ensures that the memory image has room for the header,
> it's just not guaranteed that anything gets copied there.

Ok. If we're guaranteed to have some space there, we're fine.

I'm probably being a bit thick here, but where is the "positive relative
virtual offset" in the header? Which field defines that?

Thanks,
Mark.

  reply	other threads:[~2014-10-10 12:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 14:11 [PATCH v3] arm64/efi: efistub: jump to 'stext' directly, not through the header Ard Biesheuvel
2014-10-09 17:23 ` Mark Rutland
2014-10-09 19:03   ` Ard Biesheuvel
2014-10-09 22:19     ` Mark Salter
2014-10-09 23:20       ` Roy Franz
2014-10-10  6:30         ` Ard Biesheuvel
2014-10-10 14:14           ` Mark Salter
2014-10-10 14:28             ` Ard Biesheuvel
2014-10-10 13:53         ` Peter Jones
2014-10-10 10:49     ` Mark Rutland
2014-10-10 11:52       ` Ard Biesheuvel
2014-10-10 12:19         ` Mark Rutland [this message]
2014-10-10 12:31           ` Ard Biesheuvel
2014-10-10 13:03             ` Mark Rutland
2014-10-10 13:27               ` Ard Biesheuvel
2014-10-10 14:02                 ` Mark Rutland
2014-10-10 15:38                 ` Roy Franz
2014-10-10 15:52                   ` Ard Biesheuvel

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=20141010121918.GA5294@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).