From: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
To: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Catalin Marinas <Catalin.Marinas-5wv7dgnIgG8@public.gmane.org>
Subject: Re: [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-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Fri, Oct 10, 2014 at 12:52:32PM +0100, Ard Biesheuvel wrote:
> On 10 October 2014 12:49, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote:
> > On Thu, Oct 09, 2014 at 08:03:52PM +0100, Ard Biesheuvel wrote:
> >> On 9 October 2014 19:23, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> 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.
next prev parent 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
[not found] ` <1412777487-13636-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-10-09 17:23 ` Mark Rutland
2014-10-09 19:03 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-D812Rn32rm5wQJfSM+NzPXZWbxDcDkZ8mBzbi5RQJXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-09 22:19 ` Mark Salter
[not found] ` <1412893179.29182.71.camel-PDpCo7skNiwAicBL8TP8PQ@public.gmane.org>
2014-10-09 23:20 ` Roy Franz
[not found] ` <CAFECyb9Tz2Fo2ix0VYiM7WPeie7C=woiVwyQtR4aH_HPcLwkOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-10 6:30 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_6uww=W9M9hDfoSmY+zr2i75Y=JOxTLCya2rr=HiT6Bw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-10 14:14 ` Mark Salter
[not found] ` <1412950468.29182.82.camel-PDpCo7skNiwAicBL8TP8PQ@public.gmane.org>
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
[not found] ` <CAKv+Gu_mx3uWqnRESAjqz6MdUJqBSjgeMCdnpzKiRQ+1FxUjCQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-10 12:19 ` Mark Rutland [this message]
2014-10-10 12:31 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-Kk=hZ78T+_ePceTgb9m4KmvpLcYOwvxEWuUcT+ScK_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-10 13:03 ` Mark Rutland
2014-10-10 13:27 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-OJ+byitcYSsajgEhgPOwP2ooF4Ro1QgJzXw1Z_VX1Ow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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-5wv7dgnigg8@public.gmane.org \
--cc=Catalin.Marinas-5wv7dgnIgG8@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=roy.franz-QSEj5FYQhm4dnm+yROfE0A@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