Re: Steps forward for the LoongArch UEFI bringup patch? (was: Re: [PATCH V14 11/24] LoongArch: Add boot and setup routines)

From: Arnd Bergmann
Date: Fri Jun 03 2022 - 06:09:03 EST


On Fri, Jun 3, 2022 at 11:48 AM WANG Xuerui <kernel@xxxxxxxxxx> wrote:
> On 6/3/22 17:32, Xi Ruoyao wrote:
> > On Thu, 2022-06-02 at 22:09 +0800, WANG Xuerui wrote:
> >
> > old firmware -> bootloongarch.efi -> customized u-boot -> bootloongarch64.efi (grub) -> efi stub (kernel)
> > --------- compatibility layer -------- ^^^^^^^^ normal UEFI compatible stuff ^^^^^^^^^
> >
> > new firmware -> bootloongarch64.efi (grub) -> efi stub (kernel)
> >
> > The old firmware route would be similar to the booting procedure of
> > Asahi Linux. I think this can be implemented because it's already
> > implemented on M1 even while Apple is almost completely uncooperative.

It should be a little easier here, as the firmware can already boot a version
of grub from disk. I would hope that there could simply be two different
file names for the grub executable, with the existing firmware booting
an old image, and new firmware looking for a different file name first,
which would contain a regular EFI executable (grub, kernel or anything
else). If either of the two versions of grub gets loaded by the firmware,
that should then be able to boot a modern kernel through efistub.

> This is a bit off-topic (we're basically hurrying up to get the port
> into v5.19-rc1 and discussing ways to achieve that), but yeah
> definitely. I've had the same idea right after knowing the LoongArch
> firmware would also have "new-world" variant, then I contacted some
> firmware engineers working on LoongArch boards, I think they agreed on
> the approach overall.
>
> However, making the kernel itself capable of booting on both BPI and
> new-world UEFI firmware flavors may have its merits after all; one
> scenario I could come up with is that user reboots and upgrades their
> firmware, *before* updating their old-world kernel, and bang! system
> soft-bricked. All such cases involve old-world distros that already
> deviate a little bit from vanilla upstream code, so such BPI support
> needn't be mainlined for avoiding this scenario.

The problem here is that this is very hard to ever get rid of. If
having the compatibility layer in grub works, I think that is better
for the long run.

Arnd