:: commit 33fb627abd8c65a7a1a5513d044f4dbf5ecc9d41

Mintsuki <mintsuki@protonmail.com> — 2026-04-30 17:17

parents: 9d2a5d10ca

lib/tpm: Size the spec-ID event using the v1.2 layout when it is the only entry

diff --git a/common/lib/tpm.c b/common/lib/tpm.c
index ce6f8a02..947f47db 100644
--- a/common/lib/tpm.c
+++ b/common/lib/tpm.c
@@ -266,7 +266,10 @@ static bool tpm_capture_event_log(void) {
     uint32_t log_size = 0;
     if (log_last_entry != 0) {
         uint32_t last_entry_size = 0;
-        if (log_format > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) {
+        // The first entry of a TCG 2.0 log is itself a v1.2-format spec-ID
+        // event; only entries after it follow the crypto-agile layout.
+        if (log_format > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2
+         && log_last_entry != log_location) {
             last_entry_size = tpm_calc_event_size(
                 (void *)(uintptr_t)log_last_entry,
                 (void *)(uintptr_t)log_location);
tab: 248 wrap: offon