From 1991ffa91222a122dc1391ba3e29238d71d73873 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 Nov 2024 23:22:39 +0100 Subject: [PATCH 1/3] efi: don't log if EFI RNG isn't ready Apparently this happens IRL on some systems, let's handle this gracefully and don't log. Fixes: #35033 --- src/boot/log.h | 1 + src/boot/random-seed.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/boot/log.h b/src/boot/log.h index 0699631b89..64664f77c3 100644 --- a/src/boot/log.h +++ b/src/boot/log.h @@ -27,6 +27,7 @@ _gnu_printf_(3, 4) EFI_STATUS log_internal(EFI_STATUS status, uint8_t text_color log_internal(status, text_color, "%s:%i@%s: " format, __FILE__, __LINE__, __func__, ##__VA_ARGS__) #define log_debug(...) log_full(EFI_SUCCESS, EFI_LIGHTGRAY, __VA_ARGS__) #define log_info(...) log_full(EFI_SUCCESS, EFI_WHITE, __VA_ARGS__) +#define log_warning_status(status, ...) log_full(status, EFI_YELLOW, __VA_ARGS__) #define log_error_status(status, ...) log_full(status, EFI_LIGHTRED, __VA_ARGS__) #define log_error(...) log_full(EFI_INVALID_PARAMETER, EFI_LIGHTRED, __VA_ARGS__) #define log_oom() log_full(EFI_OUT_OF_RESOURCES, EFI_LIGHTRED, "Out of memory.") diff --git a/src/boot/random-seed.c b/src/boot/random-seed.c index 2edb2afb58..920f55eefc 100644 --- a/src/boot/random-seed.c +++ b/src/boot/random-seed.c @@ -43,8 +43,11 @@ static EFI_STATUS acquire_rng(void *ret, size_t size) { return EFI_UNSUPPORTED; err = rng->GetRNG(rng, NULL, size, ret); + /* On some systems the RNG might not be ready during early boot, handle gracefully and don't log. */ + if (err == EFI_NOT_READY) + return err; if (err != EFI_SUCCESS) - return log_error_status(err, "Failed to acquire RNG data: %m"); + return log_warning_status(err, "Failed to acquire RNG data, proceeding without: %m"); return EFI_SUCCESS; } From 557d9fd5d1e3af684cd8bdcc41dc644f2858291c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 Nov 2024 23:15:17 +0100 Subject: [PATCH 2/3] pe: remove unnecessary log message about DT/HWID Fixes: #35100 --- src/boot/pe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/boot/pe.c b/src/boot/pe.c index 9af6ca0dd4..e4cb942426 100644 --- a/src/boot/pe.c +++ b/src/boot/pe.c @@ -328,8 +328,7 @@ static void pe_locate_sections( log_error_status(err, "HWID matching failed, no DT blob will be selected: %m"); hwids = NULL; } - } else - log_info("HWIDs section is missing, no DT blob will be selected"); + } } return pe_locate_sections_internal( From f2b4f1988184e0bcdb83900d1949cbfb98d61c90 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 Nov 2024 23:17:41 +0100 Subject: [PATCH 3/3] pe: use PE_SECTION_VECTOR_IS_SET() macro where appropriate --- src/boot/pe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/boot/pe.c b/src/boot/pe.c index e4cb942426..69b42faff5 100644 --- a/src/boot/pe.c +++ b/src/boot/pe.c @@ -320,7 +320,7 @@ static void pe_locate_sections( /* device */ NULL, &hwids_section); - if (hwids_section.memory_offset != 0) { + if (PE_SECTION_VECTOR_IS_SET(&hwids_section)) { hwids = (const uint8_t *) SIZE_TO_PTR(validate_base) + hwids_section.memory_offset; EFI_STATUS err = chid_match(hwids, hwids_section.memory_size, &device); @@ -358,7 +358,7 @@ static uint32_t get_compatibility_entry_address(const DosFileHeader *dos, const PTR_TO_SIZE(dos), &vector); - if (vector.memory_size == 0) /* not found */ + if (!PE_SECTION_VECTOR_IS_SET(&vector)) /* not found */ return 0; typedef struct {