2020-04-14 15:17:32

by Jörg Otte

[permalink] [raw]
Subject: Kernel V5.7-rc1 doesn't boot (EFI?)

Booting my notebook with kernel V57-rc1 I get following
display:

exit_boot() failed!
efi_main() failed!
StartImage failed: Buffer Too Small

Booting Kernel V5.6 works well.

From dmesg (kernel V5.6):
efi: EFI v2.31 by Phoenix Technologies Ltd.
efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
efi: seeding entropy pool
efi: [Firmware Bug]: Invalid EFI memory map entries:
efi: mem47: [Reserved | | | | | | | | | | | |
| ] range=[0x0000000000000000-0x0000000000000000] (invalid)
efi: mem48: [Reserved | | | | | | | | | | | |
| ] range=[0x0000000000000000-0x0000000000000000] (invalid)
efi: mem49: [Reserved | | | | | | | | | | | |
| ] range=[0x0000000000000000-0x0000000000000000] (invalid)
efi: mem50: [Reserved | | | | | | | | | | | |
| ] range=[0x0000000000000000-0x0000000000000000] (invalid)
efi: mem51: [Reserved | | | | | | | | | | | |
| ] range=[0x0000000000000000-0x0000000000000000] (invalid)
efi: Removing 5 invalid memory map entries.


Thanks, Jörg


2020-04-14 15:17:42

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Tue, 14 Apr 2020 at 12:40, Jörg Otte <[email protected]> wrote:
>
> Booting my notebook with kernel V57-rc1 I get following
> display:
>
> exit_boot() failed!
> efi_main() failed!
> StartImage failed: Buffer Too Small
>
> Booting Kernel V5.6 works well.
>
> From dmesg (kernel V5.6):
> efi: EFI v2.31 by Phoenix Technologies Ltd.
> efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> efi: seeding entropy pool
> efi: [Firmware Bug]: Invalid EFI memory map entries:
> efi: mem47: [Reserved | | | | | | | | | | | |
> | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> efi: mem48: [Reserved | | | | | | | | | | | |
> | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> efi: mem49: [Reserved | | | | | | | | | | | |
> | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> efi: mem50: [Reserved | | | | | | | | | | | |
> | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> efi: mem51: [Reserved | | | | | | | | | | | |
> | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> efi: Removing 5 invalid memory map entries.
>

Thanks for the report.

Can you try booting with efi=no_disable_early_pci_dma passed via the
kernel command line? [*]

If that does not help, can you try to reproduce with this branch?

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent

If it still does not work, please share your exact kernel config, and
the version of your distro, GRUB, shim, systemd-boot, etc

[*] GRUB on x86 turns out not to zero initialize BSS when it invokes
the EFI stub as a PE/COFF executable, resulting in the 'disable early
PCI DMA' feature to get enabled spuriously, which breaks the boot on
buggy firmware. systemd-boot is even worse, as it ignores the PE/COFF
metadata entirely in some cases, and just assumes it can invoke the
PE/COFF entrypoint after copying the kernel image into memory.

2020-04-14 16:56:13

by Jörg Otte

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

Am Di., 14. Apr. 2020 um 12:50 Uhr schrieb Ard Biesheuvel <[email protected]>:
>
> On Tue, 14 Apr 2020 at 12:40, Jörg Otte <[email protected]> wrote:
> >
> > Booting my notebook with kernel V57-rc1 I get following
> > display:
> >
> > exit_boot() failed!
> > efi_main() failed!
> > StartImage failed: Buffer Too Small
> >
> > Booting Kernel V5.6 works well.
> >
> > From dmesg (kernel V5.6):
> > efi: EFI v2.31 by Phoenix Technologies Ltd.
> > efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> > efi: seeding entropy pool
> > efi: [Firmware Bug]: Invalid EFI memory map entries:
> > efi: mem47: [Reserved | | | | | | | | | | | |
> > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > efi: mem48: [Reserved | | | | | | | | | | | |
> > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > efi: mem49: [Reserved | | | | | | | | | | | |
> > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > efi: mem50: [Reserved | | | | | | | | | | | |
> > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > efi: mem51: [Reserved | | | | | | | | | | | |
> > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > efi: Removing 5 invalid memory map entries.
> >
>
> Thanks for the report.
>
> Can you try booting with efi=no_disable_early_pci_dma passed via the
> kernel command line? [*]
>
Yes, that works!

> If that does not help, can you try to reproduce with this branch?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent

Should I give that branch a try anyway?

Thanks, Jörg

2020-04-14 16:56:23

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Tue, 14 Apr 2020 at 18:32, Jörg Otte <[email protected]> wrote:
>
> Am Di., 14. Apr. 2020 um 12:50 Uhr schrieb Ard Biesheuvel <[email protected]>:
> >
> > On Tue, 14 Apr 2020 at 12:40, Jörg Otte <[email protected]> wrote:
> > >
> > > Booting my notebook with kernel V57-rc1 I get following
> > > display:
> > >
> > > exit_boot() failed!
> > > efi_main() failed!
> > > StartImage failed: Buffer Too Small
> > >
> > > Booting Kernel V5.6 works well.
> > >
> > > From dmesg (kernel V5.6):
> > > efi: EFI v2.31 by Phoenix Technologies Ltd.
> > > efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> > > efi: seeding entropy pool
> > > efi: [Firmware Bug]: Invalid EFI memory map entries:
> > > efi: mem47: [Reserved | | | | | | | | | | | |
> > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > efi: mem48: [Reserved | | | | | | | | | | | |
> > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > efi: mem49: [Reserved | | | | | | | | | | | |
> > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > efi: mem50: [Reserved | | | | | | | | | | | |
> > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > efi: mem51: [Reserved | | | | | | | | | | | |
> > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > efi: Removing 5 invalid memory map entries.
> > >
> >
> > Thanks for the report.
> >
> > Can you try booting with efi=no_disable_early_pci_dma passed via the
> > kernel command line? [*]
> >
> Yes, that works!
>
> > If that does not help, can you try to reproduce with this branch?
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent
>
> Should I give that branch a try anyway?
>

Your test proves that BSS is not being cleared correctly, so I have
the answer I was looking for. However, I would appreciate it if you
could test that branch, just to double check.

Thanks,
Ard.

2020-04-15 13:05:37

by Linus Torvalds

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Tue, Apr 14, 2020 at 3:50 AM Ard Biesheuvel <[email protected]> wrote:
>
> [*] GRUB on x86 turns out not to zero initialize BSS when it invokes
> the EFI stub as a PE/COFF executable

The fix seems to be to put all globals in the .data section, even if
they don't have initializers.

That seems very fragile. Very easy to forget to not declare some
static variable with __efistub_global.

Could we not make the EFI stub code zero out the BSS itself? Perhaps
setting a warning flag (for a later printout) if it wasn't already
zero, so that people could point fingers are buggy loaders..

Linus

2020-04-15 13:08:08

by Linus Torvalds

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Tue, Apr 14, 2020 at 11:32 AM Ard Biesheuvel <[email protected]> wrote:
>
> That is the quick fix, but Arvind is working on getting rid of
> __efistub_global entirely, and use the right linker foo to put .bss in
> .data.

Oh, that sounds even better. Yeah, a linker script fix to just make
.bss be in the executable is the right thing to do if we have
unreliable loaders.

Thanks,
Linus

2020-04-15 21:49:55

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Tue, 14 Apr 2020 at 20:27, Linus Torvalds
<[email protected]> wrote:
>
> On Tue, Apr 14, 2020 at 3:50 AM Ard Biesheuvel <[email protected]> wrote:
> >
> > [*] GRUB on x86 turns out not to zero initialize BSS when it invokes
> > the EFI stub as a PE/COFF executable
>
> The fix seems to be to put all globals in the .data section, even if
> they don't have initializers.
>
> That seems very fragile. Very easy to forget to not declare some
> static variable with __efistub_global.
>
> Could we not make the EFI stub code zero out the BSS itself? Perhaps
> setting a warning flag (for a later printout) if it wasn't already
> zero, so that people could point fingers are buggy loaders..
>

That is the quick fix, but Arvind is working on getting rid of
__efistub_global entirely, and use the right linker foo to put .bss in
.data. This gives a tiny bit of bloat, but we are talking about a
handful of bools here.

2020-04-15 22:37:20

by Jörg Otte

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

Am Di., 14. Apr. 2020 um 18:35 Uhr schrieb Ard Biesheuvel <[email protected]>:
>
> On Tue, 14 Apr 2020 at 18:32, Jörg Otte <[email protected]> wrote:
> >
> > Am Di., 14. Apr. 2020 um 12:50 Uhr schrieb Ard Biesheuvel <[email protected]>:
> > >
> > > On Tue, 14 Apr 2020 at 12:40, Jörg Otte <[email protected]> wrote:
> > > >
> > > > Booting my notebook with kernel V57-rc1 I get following
> > > > display:
> > > >
> > > > exit_boot() failed!
> > > > efi_main() failed!
> > > > StartImage failed: Buffer Too Small
> > > >
> > > > Booting Kernel V5.6 works well.
> > > >
> > > > From dmesg (kernel V5.6):
> > > > efi: EFI v2.31 by Phoenix Technologies Ltd.
> > > > efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> > > > efi: seeding entropy pool
> > > > efi: [Firmware Bug]: Invalid EFI memory map entries:
> > > > efi: mem47: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem48: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem49: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem50: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem51: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: Removing 5 invalid memory map entries.
> > > >
> > >
> > > Thanks for the report.
> > >
> > > Can you try booting with efi=no_disable_early_pci_dma passed via the
> > > kernel command line? [*]
> > >
> > Yes, that works!
> >
> > > If that does not help, can you try to reproduce with this branch?
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent
> >
> > Should I give that branch a try anyway?
> >
>
> Your test proves that BSS is not being cleared correctly, so I have
> the answer I was looking for. However, I would appreciate it if you
> could test that branch, just to double check.
>
> Thanks,
> Ard.

The branch works for me too!

Thanks, Jörg

2020-04-15 22:53:21

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)

On Wed, 15 Apr 2020 at 10:35, Jörg Otte <[email protected]> wrote:
>
> Am Di., 14. Apr. 2020 um 18:35 Uhr schrieb Ard Biesheuvel <[email protected]>:
> >
> > On Tue, 14 Apr 2020 at 18:32, Jörg Otte <[email protected]> wrote:
> > >
> > > Am Di., 14. Apr. 2020 um 12:50 Uhr schrieb Ard Biesheuvel <[email protected]>:
> > > >
> > > > On Tue, 14 Apr 2020 at 12:40, Jörg Otte <[email protected]> wrote:
> > > > >
> > > > > Booting my notebook with kernel V57-rc1 I get following
> > > > > display:
> > > > >
> > > > > exit_boot() failed!
> > > > > efi_main() failed!
> > > > > StartImage failed: Buffer Too Small
> > > > >
> > > > > Booting Kernel V5.6 works well.
> > > > >
> > > > > From dmesg (kernel V5.6):
> > > > > efi: EFI v2.31 by Phoenix Technologies Ltd.
> > > > > efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> > > > > efi: seeding entropy pool
> > > > > efi: [Firmware Bug]: Invalid EFI memory map entries:
> > > > > efi: mem47: [Reserved | | | | | | | | | | | |
> > > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > > efi: mem48: [Reserved | | | | | | | | | | | |
> > > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > > efi: mem49: [Reserved | | | | | | | | | | | |
> > > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > > efi: mem50: [Reserved | | | | | | | | | | | |
> > > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > > efi: mem51: [Reserved | | | | | | | | | | | |
> > > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > > efi: Removing 5 invalid memory map entries.
> > > > >
> > > >
> > > > Thanks for the report.
> > > >
> > > > Can you try booting with efi=no_disable_early_pci_dma passed via the
> > > > kernel command line? [*]
> > > >
> > > Yes, that works!
> > >
> > > > If that does not help, can you try to reproduce with this branch?
> > > >
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent
> > >
> > > Should I give that branch a try anyway?
> > >
> >
> > Your test proves that BSS is not being cleared correctly, so I have
> > the answer I was looking for. However, I would appreciate it if you
> > could test that branch, just to double check.
> >
> > Thanks,
> > Ard.
>
> The branch works for me too!
>

Thanks for testing!

2020-04-15 23:42:50

by Ingo Molnar

[permalink] [raw]
Subject: Re: Kernel V5.7-rc1 doesn't boot (EFI?)


* Ard Biesheuvel <[email protected]> wrote:

> On Tue, 14 Apr 2020 at 18:32, J?rg Otte <[email protected]> wrote:
> >
> > Am Di., 14. Apr. 2020 um 12:50 Uhr schrieb Ard Biesheuvel <[email protected]>:
> > >
> > > On Tue, 14 Apr 2020 at 12:40, J?rg Otte <[email protected]> wrote:
> > > >
> > > > Booting my notebook with kernel V57-rc1 I get following
> > > > display:
> > > >
> > > > exit_boot() failed!
> > > > efi_main() failed!
> > > > StartImage failed: Buffer Too Small
> > > >
> > > > Booting Kernel V5.6 works well.
> > > >
> > > > From dmesg (kernel V5.6):
> > > > efi: EFI v2.31 by Phoenix Technologies Ltd.
> > > > efi: ACPI=0xdcffe000 ACPI 2.0=0xdcffe014 SMBIOS=0xdce80000 RNG=0xdc3cd198
> > > > efi: seeding entropy pool
> > > > efi: [Firmware Bug]: Invalid EFI memory map entries:
> > > > efi: mem47: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem48: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem49: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem50: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: mem51: [Reserved | | | | | | | | | | | |
> > > > | ] range=[0x0000000000000000-0x0000000000000000] (invalid)
> > > > efi: Removing 5 invalid memory map entries.
> > > >
> > >
> > > Thanks for the report.
> > >
> > > Can you try booting with efi=no_disable_early_pci_dma passed via the
> > > kernel command line? [*]
> > >
> > Yes, that works!
> >
> > > If that does not help, can you try to reproduce with this branch?
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=efi/urgent
> >
> > Should I give that branch a try anyway?
> >
>
> Your test proves that BSS is not being cleared correctly, so I have
> the answer I was looking for. However, I would appreciate it if you
> could test that branch, just to double check.

I'll send efi/urgent to Linus within the next couple of hours, to get the
fix to Linus:

105cb9544b16: ("efi/x86: Move efi stub globals from .bss to .data")

Thanks,

Ingo