From: Vincent Mailhol <mailhol@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
Vincent Mailhol <mailhol@kernel.org>
Subject: [PATCH 0/3] efi/libstub: reduce size by optimizing GUID storage
Date: Thu, 03 Sep 2026 23:25:14 +0200 [thread overview]
Message-ID: <20260903-libstub_guid_cleanup-v1-0-06fcb6216975@kernel.org> (raw)
The EFI stub is size-sensitive. Several call sites currently pass GUID
macro addresses directly, or keep GUID objects as automatic local
variables. With gcc, this materializes the GUID at the call site,
resulting in several assembly instructions. Using static storage instead
emits 16 bytes of GUID data and only one instruction to pass its
address.
The first two patches convert direct GUID references and automatic GUID
variables to static storage. The last patch factors GUID objects that
are shared within the same translation unit.
For the full series, on an x86_64 build with gcc 15.3.0, bloat-o-meter
reports:
add/remove: 21/0 grow/shrink: 0/12 up/down: 400/-1200 (-800)
Function old new delta
tbl_guid - 32 +32
pci_proto - 32 +32
guid - 32 +32
cc_guid - 32 +32
tpm2_guid - 16 +16
text_to_dp_guid - 16 +16
tcg2_guid - 16 +16
smbios_guid - 16 +16
rng_table_guid - 16 +16
rng_proto - 16 +16
rng_algo_raw - 16 +16
proto - 16 +16
linux_eventlog_guid - 16 +16
lf2_proto_guid - 16 +16
info_guid - 16 +16
graphics_output_guid - 16 +16
fs_proto - 16 +16
edid_discovered_guid - 16 +16
edid_active_guid - 16 +16
console_out_device_guid - 16 +16
apple_set_os_guid - 16 +16
efi_get_memory_map 707 696 -11
efi_pci_disable_bridge_busmaster 1199 1184 -15
efi_get_random_bytes 216 188 -28
efi_remap_image 357 328 -29
efi_load_initrd 1113 1065 -48
efi_get_smbios_record 283 226 -57
efi_random_get_seed 1368 1297 -71
efi_measure_tagged_event 935 854 -81
efi_retrieve_eventlog 1686 1570 -116
handle_cmdline_files 2501 2341 -160
efi_stub_entry 4180 3953 -227
efi_setup_graphics 2210 1853 -357
Total: Before=29223, After=28423, chg -2.74%
See this as my penitence for adding the BLI feature: I am giving you
back the bytes that I consumed, and even more.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
Vincent Mailhol (3):
efi/libstub: move direct GUID references to static storage
efi/libstub: make local GUID variables static
efi/libstub: factor shared static GUID variables
drivers/firmware/efi/libstub/efi-stub-entry.c | 2 +-
drivers/firmware/efi/libstub/efi-stub-helper.c | 10 +++++-----
drivers/firmware/efi/libstub/efi-stub.c | 2 +-
drivers/firmware/efi/libstub/file.c | 8 ++++----
drivers/firmware/efi/libstub/gop.c | 17 ++++++++++-------
drivers/firmware/efi/libstub/kaslr.c | 2 +-
drivers/firmware/efi/libstub/mem.c | 2 +-
drivers/firmware/efi/libstub/pci.c | 2 +-
drivers/firmware/efi/libstub/random.c | 8 ++++----
drivers/firmware/efi/libstub/riscv.c | 2 +-
drivers/firmware/efi/libstub/smbios.c | 3 ++-
drivers/firmware/efi/libstub/tpm.c | 8 ++++----
drivers/firmware/efi/libstub/unaccepted_memory.c | 2 +-
drivers/firmware/efi/libstub/x86-stub.c | 13 +++++++------
drivers/firmware/efi/libstub/zboot.c | 3 ++-
15 files changed, 45 insertions(+), 39 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260903-libstub_guid_cleanup-7aad27f1c0c5
Best regards,
--
Vincent Mailhol <mailhol@kernel.org>
next reply other threads:[~2026-09-03 21:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 21:25 Vincent Mailhol [this message]
2026-09-03 21:25 ` [PATCH 1/3] efi/libstub: move direct GUID references to static storage Vincent Mailhol
2026-09-03 21:25 ` [PATCH 2/3] efi/libstub: make local GUID variables static Vincent Mailhol
2026-09-03 21:25 ` [PATCH 3/3] efi/libstub: factor shared static GUID variables Vincent Mailhol
2026-09-04 16:31 ` [PATCH 0/3] efi/libstub: reduce size by optimizing GUID storage 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=20260903-libstub_guid_cleanup-v1-0-06fcb6216975@kernel.org \
--to=mailhol@kernel.org \
--cc=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.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