All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Ard Biesheuvel <ardb@kernel.org>, linux-efi <linux-efi@vger.kernel.org>
Subject: Re: [PATCH 0/3] Relocate GOT before calling EFI stub
Date: Tue, 7 Jan 2020 15:28:31 +0100	[thread overview]
Message-ID: <CAKv+Gu8v-5DXWh5ZaY0omrVNh46TEourpcf2Hv3TrsbCUtLFng@mail.gmail.com> (raw)
In-Reply-To: <20200107142732.GB652888@rani.riverdale.lan>

On Tue, 7 Jan 2020 at 15:27, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Tue, Jan 07, 2020 at 03:24:18PM +0100, Ard Biesheuvel wrote:
> > On Tue, 7 Jan 2020 at 15:21, Arvind Sankar <nivedita@alum.mit.edu> wrote:
> > >
> > > On Tue, Jan 07, 2020 at 03:13:46PM +0100, Ard Biesheuvel wrote:
> > > > On Tue, 7 Jan 2020 at 15:01, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > > > >
> > > > > On Tue, 7 Jan 2020 at 14:55, Arvind Sankar <nivedita@alum.mit.edu> wrote:
> > > > > >
> > > > > > This series performs GOT relocation before calling into C code for the
> > > > > > EFI stub. While the stub does not currently require GOT relocation, it's
> > > > > > quite easy to introduce code that will use the GOT on old toolchains,
> > > > > > but not recent ones, which can lead to unexpected issues.
> > > > > >
> > > > > > This is based on
> > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git/log/?h=next
> > > > > >
> > > > > > with commit 4169bb99cd70 ("efi/libstub/x86: use mandatory 16-byte stack
> > > > > > alignment in mixed mode") reverted, as it caused a crash in mixed mode.
> > > > > >
> > > > >
> > > > > Hi Arvind,
> > > > >
> > > > > I appreciate the effort, but I really don't think this is a good idea.
> > > > >
> > > > > A GOT is completely pointless in bare metal code, and fortunately,
> > > > > modern toolchains make it easier to suppress GOT entries from being
> > > > > emitted. So instead of adding back asm code that I just removed, I
> > > > > think it would be better to investigate whether we can get rid of the
> > > > > GOT entirely.
> > > > >
> > > >
> > > > With the following added to arch/x86/boot/compressed/vmlinux.lds.S,
> > > > the 64-bit kernel already links without error.
> > > >
> > > > ASSERT (_got == _egot, "GOT entries detected");
> > > >
> > > > The 32-bit kernel produces a GOT with 3 entries: I'm trying to narrow
> > > > down where they come from.
> > > >
> > > >
> > >
> > > With modern toolchain, 32-bit compressed kernel doesn't actually use the
> > > GOT, however unlike 64-bit, the linker still emits a GOT with the three
> > > reserved entries.
> > >
> > > The rest of the early boot code (after EFI stub) does generate
> > > R_386_GOT32(X) relocations, so we need to use a GOT anyway to cater for
> > > older linkers. Having a build-time check that the EFI stub code does not
> > > have any such relocations might be possible, but it seems easier to just
> > > do the GOT processing for it as well.
> >
> > Not necessarily. My tests with binutils 2.24 building 32-bit suggest
> > that using 'hidden' visibility is often sufficient to get rid of them.
>
> Ah. Could we just add -fvisibility=hidden to the boot/compressed cflags?
> If that works with old toolchain, we could just get rid of the whole
> adjust_got thing.

Unfortunately, the command line option implements a weaker form of
visibility than the pragma, so it probably comes down to setting the
pragma in a .h file that gets -include'd via the command line so it is
guaranteed to be seen first.

  reply	other threads:[~2020-01-07 14:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 13:54 [PATCH 0/3] Relocate GOT before calling EFI stub Arvind Sankar
2020-01-07 13:54 ` [PATCH 1/3] x86/boot/compressed/64: Make adjust_got easier to use repeatedly Arvind Sankar
2020-01-07 13:54 ` [PATCH 2/3] x86/boot/compressed/32: Allow adjust_got to be called repeatedly Arvind Sankar
2020-01-07 13:55 ` [PATCH 3/3] x86/boot: Perform GOT relocation before calling EFI stub Arvind Sankar
2020-01-07 14:01 ` [PATCH 0/3] Relocate GOT " Ard Biesheuvel
2020-01-07 14:13   ` Ard Biesheuvel
2020-01-07 14:21     ` Arvind Sankar
2020-01-07 14:24       ` Ard Biesheuvel
2020-01-07 14:27         ` Arvind Sankar
2020-01-07 14:28           ` Ard Biesheuvel [this message]
2020-01-07 17:58             ` Arvind Sankar
2020-01-07 17:59               ` Ard Biesheuvel
2020-01-07 18:08                 ` Arvind Sankar
2020-01-07 18:10                   ` Ard Biesheuvel
2020-01-07 18:32                     ` Arvind Sankar
2020-01-07 19:03                       ` Ard Biesheuvel
2020-01-07 19:14                         ` Arvind Sankar
2020-01-07 19:23                           ` Ard Biesheuvel
2020-01-07 19:51                             ` Ard Biesheuvel
2020-01-07 20:00                               ` Arvind Sankar

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+Gu8v-5DXWh5ZaY0omrVNh46TEourpcf2Hv3TrsbCUtLFng@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=nivedita@alum.mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.