linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: linux-efi <linux-efi@vger.kernel.org>,
	Laszlo Ersek <lersek@redhat.com>,
	Leif Lindholm <leif@nuviainc.com>,
	Peter Jones <pjones@redhat.com>,
	Matthew Garrett <mjg59@google.com>,
	Alexander Graf <agraf@csgraf.de>,
	Daniel Kiper <daniel.kiper@oracle.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v2 4/5] efi/x86: Implement mixed mode boot without the handover protocol
Date: Fri, 21 Feb 2020 19:54:02 +0100	[thread overview]
Message-ID: <CAKv+Gu-Q6SjVYoAqmAE-JZguFd5PsG6hkZWLj_nnA91+C2ZA6g@mail.gmail.com> (raw)
In-Reply-To: <20200221175949.GA2825100@rani.riverdale.lan>

On Fri, 21 Feb 2020 at 18:59, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Fri, Feb 21, 2020 at 06:12:40PM +0100, Ard Biesheuvel wrote:
> > On Fri, 21 Feb 2020 at 17:39, Arvind Sankar <nivedita@alum.mit.edu> wrote:
> > >
> > > On Mon, Feb 17, 2020 at 03:48:21PM +0100, Ard Biesheuvel wrote:
> > > > Add support for booting 64-bit x86 kernels from 32-bit firmware running
> > > > on 64-bit capable CPUs without requiring the bootloader to implement
> > > > the EFI handover protocol or allocate the setup block, etc etc, all of
> > > > which can be done by the stub itself, using code that already exists.
> > > >
> > > > Instead, create an ordinary EFI application entrypoint but implemented
> > > > in 32-bit code [so that it can be invoked by 32-bit firmware], and stash
> > > > the address of this 32-bit entrypoint in the .compat section where the
> > > > bootloader can find it.
> > > >
> > > > Note that we use the setup block embedded in the binary to go through
> > > > startup_32(), but it gets reallocated and copied in efi_pe_entry(),
> > > > using the same code that runs when the x86 kernel is booted in EFI
> > > > mode from native firmware. This requires the loaded image protocol to
> > > > be installed on the kernel image's EFI handle, and point to the kernel
> > > > image itself and not to its loader. This, in turn, requires the
> > > > bootloader to use the LoadImage() boot service to load the 64-bit
> > > > image from 32-bit firmware, which is in fact supported by firmware
> > > > based on EDK2. (Only StartImage() will fail, and instead, the newly
> > > > added entrypoint needs to be invoked)
> > > >
> > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > >
> > > I think there's one issue with this. startup_32 is 14KiB from the start
> > > of the image because of .setup. This means the code in startup_32 that
> > > rounds the load address up to kernel_alignment will likely calculate it
> > > as 2MiB from the image address (if the image address was 2MiB-aligned),
> > > and the page tables constructed by the 32-bit code will be beyond the
> > > space allocated for the image.
> > >
> >
> > Right. Image address could be any multiple of 4 KB so we'll have to
> > deal with that.
> >
> > > I think the simplest fix would be to increase SizeOfImage by
> > > kernel_alignment to allow enough slop space for the alignment.
> >
> > So we basically need at least 2 MB - 14 KB slack at the top, right?
> > That's easily done.
> >
> > > We should
> > > also increase it by text_start, since we need init_size beginning from
> > > startup_32, not from the image address.
> >
> > So something like the below?
>
> Yup.
>
> You might as well do the text_start bit unconditionally I think? If by
> some blind stroke of luck startup_32 ends up at pref_address and so we
> don't call efi_relocate_kernel, we'll need the room.
>

Yeah, so this could already be an issue today ...

  reply	other threads:[~2020-02-21 18:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 14:48 [PATCH v2 0/5] efi/x86: add support for generic EFI mixed mode boot Ard Biesheuvel
2020-02-17 14:48 ` [PATCH v2 1/5] efi/x86: Drop redundant .bss section Ard Biesheuvel
2020-02-21 16:40   ` Arvind Sankar
2020-02-21 16:45     ` Ard Biesheuvel
2020-02-17 14:48 ` [PATCH v2 2/5] efi/libstub/x86: Make loaded_image protocol handling mixed mode safe Ard Biesheuvel
2020-02-17 14:48 ` [PATCH v2 3/5] efi/libstub/x86: Use Exit() boot service to exit the stub on errors Ard Biesheuvel
2020-02-17 14:48 ` [PATCH v2 4/5] efi/x86: Implement mixed mode boot without the handover protocol Ard Biesheuvel
2020-02-21 16:39   ` Arvind Sankar
2020-02-21 17:12     ` Ard Biesheuvel
2020-02-21 17:59       ` Arvind Sankar
2020-02-21 18:54         ` Ard Biesheuvel [this message]
2020-02-17 14:48 ` [PATCH v2 5/5] efi/x86: Add true mixed mode entry point into .compat section 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=CAKv+Gu-Q6SjVYoAqmAE-JZguFd5PsG6hkZWLj_nnA91+C2ZA6g@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=agraf@csgraf.de \
    --cc=daniel.kiper@oracle.com \
    --cc=hdegoede@redhat.com \
    --cc=leif@nuviainc.com \
    --cc=lersek@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mjg59@google.com \
    --cc=nivedita@alum.mit.edu \
    --cc=pjones@redhat.com \
    /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).