From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: catalin.marinas@arm.com, will@kernel.org,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
Matthew Garrett <mjg59@srcf.ucam.org>,
Peter Jones <pjones@redhat.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Atish Patra <atishp@atishpatra.org>,
Arnd Bergmann <arnd@arndb.de>,
Huacai Chen <chenhuacai@loongson.cn>,
Lennart Poettering <lennart@poettering.net>,
linux-efi@vger.kernel.org
Subject: Re: [PATCH v2 0/6] efi: implement generic compressed boot support
Date: Tue, 9 Aug 2022 11:03:03 +0200 [thread overview]
Message-ID: <ca0a22d9-d80c-836d-9b04-fa9d3e2c79c0@canonical.com> (raw)
In-Reply-To: <CAMj1kXHLw419xpULVP5wZUW0fnAz0ovJ+RmkFFdDGtUmNM2wSQ@mail.gmail.com>
On 8/9/22 10:46, Ard Biesheuvel wrote:
> On Tue, 9 Aug 2022 at 10:38, Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
>>
>> On 8/9/22 10:09, Ard Biesheuvel wrote:
>>> Relatively modern architectures such as arm64 or RISC-V don't implement
>>> a self-decompressing kernel, and leave it up to the bootloader to
>>> decompress the compressed image before executing it. For bare metal
>>> boot, this policy makes sense, as a self-decompressing image essentially
>>> duplicates a lot of fiddly preparation work to create a 1:1 mapping and
>>> set up the C runtime, and to discover or infer where DRAM lives from
>>> device trees or other firmware tables.
>>>
>>> For EFI boot, the situation is a bit different: the EFI entrypoint is
>>> called with a 1:1 cached mapping covering all of DRAM already active,
>>> and with a stack, a heap, a memory map and boot services to load and
>>> start images. This means it is rather trivial to implement a
>>> self-decompressing wrapper for EFI boot in a generic manner, and reuse
>>> it across architectures that implement EFI boot.
>>>
>>> The only slight downside is that when UEFI secure boot is enabled, the
>>> generic LoadImage/StartImage only allow signed images to be loaded and
>>> started, and we prefer to avoid the need to sign both the inner and
>>> outer PE/COFF images. This series adopts the EFI shim approach, i.e., to
>>> override an internal UEFI/PI protocol that is used by the image loader,
>>> to allow the inner image to be booted after decompression. This has been
>>
>> We should avoid requiring anything that is not in the UEFI
>> specification. If you have any additional requirements, please, create a
>> change request for the UEFI specification.
>>
>
> As I have explained numerous times before, the EFI spec was intended
> to be extensible (hence the 'E'). The ACPI, SMBIOS and TCG specs all
> augment the EFI specification by defining protocols, GUIDs and other
> things that are only relevant in a EFI context, but none of those are
> covered by the EFI spec itself.
>
>> Overriding the services of the system table is dangerous and should be
>> avoided.
>>
>
> Agreed. But this is not what is happening here.
>
>> There is no need for two UEFI binaries one inside the other and we
>> should avoid such overengineering.
>>
>
> I disagree. Using an EFI app to encapsulate another one is the only
> generic way to go about this, as far as I can tell.
Please, elaborate why the inner compressed binary needs to be UEFI to
boot into Linux while currently we don't need a an uncompressed inner
UEFI binary.
>
>> Today we append an uncompressed kernel to the EFI stub. The stub
>> relocates it, sets up the memory map and calls it entry point.
>>
>
> Not exactly. On arm64 as well as RISC-V, the EFI stub and the kernel
> proper are essentially the same executable image.
Currently on ARM and RISC-V you have a file with two entry points:
* EFI stub
* legacy entry point
The EFI stub calls the legacy entry point. In the EFI case some part of
the EFI stub lives on at runtime. The same pointers passed to the legacy
entry point could also be passed to a decompressed legacy kernel.
The EFI stub and the kernel should be completely separate binaries. Then
you just need the cp command to join them.
>
>> Just add decompressor code to the EFI stub and instead of appending an
>> uncompressed kernel append a compressed one. Then sign a binary
>> consisting of the EFI stub and the compressed kernel.
>>
>
> Yes, this would be a cleaner approach, although it would require more
> re-engineering of the EFI stub, in particular, it would require
> cloning more code, and adding additional build and link steps.
If this is the cleanest approach, we should go for it.
Best regards
Heinrich
>
>> This way you don't need any change to UEFI firmware at all and you don't
>> need to override UEFI services.
>>
>> Another reasonable approach would be to zip the signed UEFI binary (EFI
>> stub with uncompressed kernel) and let the UEFI firmware unzip it and
>> check the signature of the decompressed UEFI binary. This would not
>> require any patch in Linux at all and would be simple to implement in
>> U-Boot.
>>
>
> This is how it works today. One problem with this is that the image
> needs to be decompressed in order to sign it, or verify its signature.
> In general, having compression at the outside like this is fiddly
> because it is no longer a PE/COFF image, and the EFI spec only reasons
> about PE/COFF images as executable images. So we'd need to change the
> UEFI spec or the PE/COFF spec.
next prev parent reply other threads:[~2022-08-09 9:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 8:09 [PATCH v2 0/6] efi: implement generic compressed boot support Ard Biesheuvel
2022-08-09 8:09 ` [PATCH v2 1/6] efi: stub: add some missing boot service prototypes Ard Biesheuvel
2022-08-09 8:42 ` Heinrich Schuchardt
2022-08-09 8:09 ` [PATCH v2 2/6] efi: stub: split off printk() routines Ard Biesheuvel
2022-08-09 8:09 ` [PATCH v2 3/6] efi: stub: move efi_system_table global var into separate object Ard Biesheuvel
2022-08-09 8:09 ` [PATCH v2 4/6] efi: stub: implement generic EFI zboot Ard Biesheuvel
2022-08-09 8:09 ` [PATCH v2 5/6] arm64: efi: enable generic EFI compressed boot Ard Biesheuvel
2022-08-09 8:09 ` [PATCH v2 6/6] riscv: " Ard Biesheuvel
2022-09-12 14:26 ` Palmer Dabbelt
2022-08-09 8:38 ` [PATCH v2 0/6] efi: implement generic compressed boot support Heinrich Schuchardt
2022-08-09 8:46 ` Ard Biesheuvel
2022-08-09 9:03 ` Heinrich Schuchardt [this message]
2022-08-09 9:10 ` Ard Biesheuvel
2022-08-09 8:47 ` Matthew Garrett
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=ca0a22d9-d80c-836d-9b04-fa9d3e2c79c0@canonical.com \
--to=heinrich.schuchardt@canonical.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=atishp@atishpatra.org \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@loongson.cn \
--cc=ilias.apalodimas@linaro.org \
--cc=lennart@poettering.net \
--cc=linux-efi@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=palmer@dabbelt.com \
--cc=pjones@redhat.com \
--cc=takahiro.akashi@linaro.org \
--cc=will@kernel.org \
/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