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 1/5] efi/x86: Drop redundant .bss section
Date: Fri, 21 Feb 2020 17:45:40 +0100	[thread overview]
Message-ID: <CAKv+Gu89Y8RP9-cS3z+m6gpkp3Wy-n6FxocMwOSsrGobWUw3Jg@mail.gmail.com> (raw)
In-Reply-To: <20200221164010.GB2766905@rani.riverdale.lan>

On Fri, 21 Feb 2020 at 17:40, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Mon, Feb 17, 2020 at 03:48:18PM +0100, Ard Biesheuvel wrote:
> > In commit
> >
> >   c7fb93ec51d462ec ("x86/efi: Include a .bss section within the PE/COFF headers")
> >
> > we added a separate .bss section to the PE/COFF header of the compressed
> > kernel describing the static memory footprint of the decompressor, to
> > ensure that it has enough headroom to decompress itself.
> >
> > We can achieve the exact same result by increasing the virtual size of
> > the .text section, without changing the raw size, which, as per the
> > PE/COFF specification, requires the loader to zero initialize the delta.
> >
> > Doing so frees up a slot in the section table, which we will use later
> > to describe the mixed mode entrypoint.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > ---
> >  arch/x86/boot/header.S      | 21 +-----------
> >  arch/x86/boot/tools/build.c | 35 ++++++++------------
> >  2 files changed, 14 insertions(+), 42 deletions(-)
> >
> > diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
> > index 55e669d29e54..0c8c5a52f1f0 100644
> > --- a/arch/x86/boot/tools/build.c
> > +++ b/arch/x86/boot/tools/build.c
> > @@ -203,10 +203,12 @@ static void update_pecoff_setup_and_reloc(unsigned int size)
> >       put_unaligned_le32(10, &buf[reloc_offset + 4]);
> >  }
> >
> > -static void update_pecoff_text(unsigned int text_start, unsigned int file_sz)
> > +static void update_pecoff_text(unsigned int text_start, unsigned int file_sz,
> > +                            unsigned int init_sz)
> >  {
> >       unsigned int pe_header;
> >       unsigned int text_sz = file_sz - text_start;
> > +     unsigned int bss_sz = init_sz - file_sz;
> >
> >       pe_header = get_unaligned_le32(&buf[0x3c]);
> >
> > @@ -216,28 +218,19 @@ static void update_pecoff_text(unsigned int text_start, unsigned int file_sz)
> >        */
> >       put_unaligned_le32(file_sz - 512, &buf[pe_header + 0x1c]);
> >
> > -     /*
> > -      * Address of entry point for PE/COFF executable
> > -      */
> > -     put_unaligned_le32(text_start + efi_pe_entry, &buf[pe_header + 0x28]);
> > -
> > -     update_pecoff_section_header(".text", text_start, text_sz);
> > -}
> > -
> > -static void update_pecoff_bss(unsigned int file_sz, unsigned int init_sz)
> > -{
> > -     unsigned int pe_header;
> > -     unsigned int bss_sz = init_sz - file_sz;
> > -
> > -     pe_header = get_unaligned_le32(&buf[0x3c]);
> > -
> >       /* Size of uninitialized data */
> >       put_unaligned_le32(bss_sz, &buf[pe_header + 0x24]);
>
> Should this still be populated given that there's no .bss section any
> more?

Good point. The PE/COFF spec is explicit, for a change, and
specifically mentions that this should be the combined sizeof all BSS
sections. It doesn't really specify how one could have multiple BSS
sections, but the wording does support your view that this should be
zero, and the value of bss_sz added to the SizeOfText field.

I couldn't find any code in EDK2 that actually references this field
(apart from the ELF to PE/COFF converter that always sets it to 0x0),
and so I don't think it really matters.

  reply	other threads:[~2020-02-21 16:45 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 [this message]
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
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+Gu89Y8RP9-cS3z+m6gpkp3Wy-n6FxocMwOSsrGobWUw3Jg@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).