Page MenuHomeFreeBSD

loader.efi: efi_exit should return more data
Needs ReviewPublic

Authored by tsoome on Sep 11 2025, 7:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 12:18 AM
Unknown Object (File)
Mon, Oct 13, 12:18 AM
Unknown Object (File)
Mon, Oct 13, 12:18 AM
Unknown Object (File)
Sun, Oct 12, 12:45 PM
Unknown Object (File)
Sat, Oct 11, 10:35 PM
Unknown Object (File)
Sat, Oct 11, 12:21 PM
Unknown Object (File)
Sun, Sep 28, 10:00 AM
Unknown Object (File)
Wed, Sep 24, 7:29 AM
Subscribers

Details

Reviewers
manu
imp
Summary

UEFI specification has an mechanism to pass data via
EFI_BOOT_SERVICES.Exit(). We can use this to pass
panic() message, so the use has an chance to get this
information in case the console is not usable or
available.

To do this, we allocate static string buffer (arbitrary
picked 2 lines - 160 chars) - it is possible the loader heap
is corrupted and malloc is not usable, and we pass it to BS->Exit().

Note: we still need to print this buffer on console too
for non-UEFI platforms.

The static buffer size does limit the length of the panic
message (assert may generate long messages), but we do not want to
waste too much of precious resource.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66980
Build 63863: arc lint + arc unit

Event Timeline

imp requested changes to this revision.Sep 11 2025, 5:15 PM

I'd really rather not have efi_main depend on the frame buffer.

stand/efi/loader/efi_main.c
49

we're panicing. Can we really allocate this? We should preallocate this maybe?

59

Is there some way we can have this be some sort of 'atexit' functionality rather than doing it inline here forcing efi_main.c to know about framebuffer stuff. It's supposed to be just a thin wrapper between stand world and efi world.

This revision now requires changes to proceed.Sep 11 2025, 5:15 PM

preallocate buffer space for exit message.
factor out framebuffer cleanup.
we do not really return from efi_main.