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 3/3] efi/libstub: factor shared static GUID variables
Date: Thu, 03 Sep 2026 23:25:17 +0200 [thread overview]
Message-ID: <20260903-libstub_guid_cleanup-v1-3-06fcb6216975@kernel.org> (raw)
In-Reply-To: <20260903-libstub_guid_cleanup-v1-0-06fcb6216975@kernel.org>
Some GUIDs are used several times in the same translation unit.
Factor the duplicated EFI_FILE_SYSTEM_GUID, EFI_RNG_PROTOCOL_GUID and
EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID objects at file scope within their
translation units. Leave the single-use GUID objects at function scope.
For an x86_64 build with gcc 15.3.0, bloat-o-meter reports:
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-48 (-48)
Function old new delta
rng_proto 32 16 -16
graphics_output_guid 32 16 -16
fs_proto 32 16 -16
Total: Before=28471, After=28423, chg -0.17%
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
drivers/firmware/efi/libstub/file.c | 4 ++--
drivers/firmware/efi/libstub/gop.c | 4 ++--
drivers/firmware/efi/libstub/random.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
index 0dff9e08d49e..b2601e284695 100644
--- a/drivers/firmware/efi/libstub/file.c
+++ b/drivers/firmware/efi/libstub/file.c
@@ -29,6 +29,8 @@
*/
#define EFI_READ_CHUNK_SIZE SZ_1M
+static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID;
+
struct finfo {
efi_file_info_t info;
efi_char16_t filename[MAX_FILENAME_SIZE];
@@ -74,7 +76,6 @@ static efi_status_t efi_open_file(efi_file_protocol_t *volume,
static efi_status_t efi_open_volume(efi_loaded_image_t *image,
efi_file_protocol_t **fh)
{
- static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID;
efi_simple_file_system_protocol_t *io;
efi_status_t status;
@@ -129,7 +130,6 @@ static efi_status_t efi_open_device_path(efi_file_protocol_t **volume,
struct finfo *fi)
{
static efi_guid_t text_to_dp_guid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
- static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID;
static efi_device_path_from_text_protocol_t *text_to_dp = NULL;
efi_device_path_protocol_t *initrd_dp;
efi_simple_file_system_protocol_t *io;
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
index acc2827ba4d7..fa324d4abcaa 100644
--- a/drivers/firmware/efi/libstub/gop.c
+++ b/drivers/firmware/efi/libstub/gop.c
@@ -24,6 +24,8 @@ enum efi_cmdline_option {
EFI_CMDLINE_LIST
};
+static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
+
static struct {
enum efi_cmdline_option option;
union {
@@ -425,7 +427,6 @@ static void setup_edid_info(struct edid_info *edid, u32 gop_size_of_edid, u8 *go
static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_handle_t handles[],
efi_graphics_output_protocol_t **found_gop)
{
- static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
static efi_guid_t console_out_device_guid = EFI_CONSOLE_OUT_DEVICE_GUID;
efi_graphics_output_protocol_t *first_gop;
efi_handle_t h, first_gop_handle;
@@ -481,7 +482,6 @@ static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_ha
efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid)
{
- static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
static efi_guid_t edid_active_guid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
static efi_guid_t edid_discovered_guid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;
efi_handle_t *handles __free(efi_pool) = NULL;
diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
index 3ca230fa7aa3..d63262d36e47 100644
--- a/drivers/firmware/efi/libstub/random.c
+++ b/drivers/firmware/efi/libstub/random.c
@@ -8,6 +8,8 @@
#include "efistub.h"
+static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
+
typedef union efi_rng_protocol efi_rng_protocol_t;
union efi_rng_protocol {
@@ -38,7 +40,6 @@ union efi_rng_protocol {
*/
efi_status_t efi_get_random_bytes(unsigned long size, u8 *out)
{
- static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
efi_status_t status;
efi_rng_protocol_t *rng = NULL;
@@ -64,7 +65,6 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out)
*/
efi_status_t efi_random_get_seed(void)
{
- static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
static efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
static efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
struct linux_efi_random_seed *prev_seed, *seed = NULL;
--
2.55.0
next prev parent 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 [PATCH 0/3] efi/libstub: reduce size by optimizing GUID storage Vincent Mailhol
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 ` Vincent Mailhol [this message]
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-3-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