mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Andy Lutomirski" <luto@kernel.org>
To: "Ard Biesheuvel" <ardb@kernel.org>
Cc: linux-efi@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Evgeniy Baskov" <baskov@ispras.ru>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Alexey Khoroshilov" <khoroshilov@ispras.ru>,
	"Peter Jones" <pjones@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Dave Young" <dyoung@redhat.com>,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>
Subject: Re: [RFC PATCH 0/3] efi: Implement generic zboot support
Date: Wed, 03 May 2023 10:55:19 -0700	[thread overview]
Message-ID: <44b21bb3-a65d-4560-9fe5-c7ddc260ddc0@app.fastmail.com> (raw)
In-Reply-To: <CAMj1kXH5+scbFuaOP+VC7EHEZcn-tmp3nk=9uYGYGfJyb0S92Q@mail.gmail.com>

On Fri, Apr 21, 2023, at 6:41 AM, Ard Biesheuvel wrote:
> On Fri, 21 Apr 2023 at 15:30, Andy Lutomirski <luto@kernel.org> wrote:
>>
>>
>>
>> On Sun, Apr 16, 2023, at 5:07 AM, Ard Biesheuvel wrote:
>> > This series is a proof-of-concept that implements support for the EFI
>> > zboot decompressor for x86. It replaces the ordinary decompressor, and
>> > instead, performs the decompression, KASLR randomization and the 4/5
>> > level paging switch while running in the execution context of EFI.
>>
>> I like the concept.  A couple high-level questions, since I haven’t dug into the code:
>>
>> Could zboot and bzImage be built into the same kernel image?  That would get this into distros, and eventually someone could modify the legacy path to switch to long mode and invoke zboot (because zboot surely doesn’t need actual UEFI — just a sensible environment like what UEFI provides.)
>>
>
> That's an interesting question, and to some extent, that is actually
> what Evgeny's patch does: execute more of what the decompressor does
> from inside the EFI runtime context.
>
> The main win with zboot imho is that we get rid of all the funky
> heuristics that look for usable memory for trampolines and
> decompression buffers in funky ways, and instead, just use the EFI
> APIs for allocating pages and remapping them executable as needed
> (which is the important piece here) I'd have to think about whether
> there is any middle ground between this approach and Evgeny's - I'll
> have to get back to you on that.
>

Hmm.  I dug the tiniest bit into the history.  The x86/boot/compressed stuff has an allocator!  It's this:

        free_mem_ptr     = heap;        /* Heap */
        free_mem_end_ptr = heap + BOOT_HEAP_SIZE;

plus a trivial and horrible malloc() implementation in include/linux/decompress/mm.h.  There's one caller in x86/boot/compressed.

And, once upon a time, the idea of allocating enough memory to store the kernel from the decompressor would have been a problem.  I'm willing to claim that we should not even try to support x86 systems that have that little memory (at least not once they've gotten long mode or at least flat 32-bit protected mode working).  We should not try to allocate below 1MB (my laptop will cry), but there's no need for that.

So maybe the middle ground is to build a modern, simple malloc(), and back it by EFI when EFI is there and by just finding some free memory when EFI is not there?

This would be risky -- someone might have a horrible machine that has trouble with a simple allocator.

  reply	other threads:[~2023-05-03 17:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 12:07 Ard Biesheuvel
2023-04-16 12:07 ` [RFC PATCH 1/3] efi/libstub: x86: Split off pieces shared with zboot Ard Biesheuvel
2023-04-16 12:07 ` [RFC PATCH 2/3] efi/zboot: x86: Implement EFI zboot support Ard Biesheuvel
2023-04-16 12:07 ` [RFC PATCH 3/3] efi/zboot: x86: Clear NX restrictions on populated code regions Ard Biesheuvel
2023-04-18 14:10 ` [RFC PATCH 0/3] efi: Implement generic zboot support Evgeniy Baskov
2023-04-19  2:56 ` Dave Young
2023-04-19  5:54 ` Gerd Hoffmann
2023-04-19 14:44   ` Ard Biesheuvel
2023-04-20  6:07     ` Gerd Hoffmann
2023-04-20  7:54       ` Ard Biesheuvel
2023-04-20 12:29         ` Mario Limonciello
2023-04-21 13:29 ` Andy Lutomirski
2023-04-21 13:41   ` Ard Biesheuvel
2023-05-03 17:55     ` Andy Lutomirski [this message]
2023-05-03 18:13       ` 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=44b21bb3-a65d-4560-9fe5-c7ddc260ddc0@app.fastmail.com \
    --to=luto@kernel.org \
    --cc=ardb@kernel.org \
    --cc=baskov@ispras.ru \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dyoung@redhat.com \
    --cc=keescook@chromium.org \
    --cc=khoroshilov@ispras.ru \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kraxel@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjones@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®