Linux EFI development
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
	"Jasmeet (Jazz) Bhatia" <jasmeet.bhatia.us@gmail.com>
Subject: [PATCH 2/2] efi/tpm: Allocate the event log from EFI loader data again
Date: Mon, 23 Nov 2026 10:42:31 +0100	[thread overview]
Message-ID: <20261123094228.466164-6-ardb+git@google.com> (raw)
In-Reply-To: <20261123094228.466164-4-ardb+git@google.com>

From: Ard Biesheuvel <ardb@kernel.org>

The EFI stub currently allocates the TPM event log as
EFI_ACPI_RECLAIM_MEMORY. On x86, this becomes an ACPI data entry
in the E820 map.

On a Framework Laptop 16 (AMD Ryzen AI 300 Series), the EFI allocator
can place this allocation at different physical addresses across boots.
Since x86 hibernation validates architecture-specific data from
the firmware E820 map, this causes an otherwise valid hibernation image
to be rejected on resume with the following error:

  Hibernate inconsistent memory map detected!
  PM: hibernation: Image mismatch: architecture specific data

Allocating the event log as EFI_LOADER_DATA avoids changing the E820
map, but doing that alone would regress the kexec corruption issue fixed
by commit 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event
log to avoid corruption"): the E820 map that kexec passes on to the next
kernel describes EFI loader data as ordinary RAM, and so the event log
may get clobbered before the next kernel gets around to reserving it.

So use the x86 implementation of efi_config_table_is_usable() to
disregard the TPM event log table after kexec, just like the INITRD
table, and go back to allocating it as EFI_LOADER_DATA. This is simpler
than preserving the event log across kexec, e.g., by installing the
memreserve table on x86 and using efi_mem_reserve_persistent(), and the
utility of the event log after kexec is questionable to begin with.

This also protects kexec'd kernels from a clobbered event log if the
previous kernel predates the change above, and allocated the table from
EFI loader data as well. The kexec issue was specific to x86, so other
architectures can use EFI loader data as before.

Fixes: 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/x86/platform/efi/efi.c        | 6 ++++++
 drivers/firmware/efi/libstub/tpm.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index c2817c7415ce..db1b179db0a5 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -442,6 +442,11 @@ static int __init efi_systab_init(unsigned long phys)
  *   data, which is released to the page allocator once the kernel is up and
  *   running, and so the table is stale by the time kexec boots the next kernel.
  *
+ * - The TPM event log table is installed by the EFI stub too, and allocated
+ *   from EFI loader data as well. It is reserved by the kernel, but the E820
+ *   memory map that kexec passes on describes it as ordinary RAM, and so it
+ *   may get clobbered before the next kernel gets around to reserving it.
+ *
  * - The Memory Attributes table may reside in EFI boot services data, which is
  *   released to the page allocator as well. Even if it is still intact, the
  *   sanity check in efi_memattr_init() may fail spuriously, given that only
@@ -455,6 +460,7 @@ bool __init x86_efi_config_table_is_usable(const efi_guid_t *guid,
 		return true;
 
 	return efi_guidcmp(*guid, LINUX_EFI_INITRD_MEDIA_GUID) &&
+	       efi_guidcmp(*guid, LINUX_EFI_TPM_EVENT_LOG_GUID) &&
 	       efi_guidcmp(*guid, EFI_MEMORY_ATTRIBUTES_TABLE_GUID);
 }
 
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index 73f001114732..b8183bfdbaa3 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -96,7 +96,7 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
 	}
 
 	/* Allocate space for the logs and copy them. */
-	status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
+	status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
 			     sizeof(*log_tbl) + log_size, (void **)&log_tbl);
 
 	if (status != EFI_SUCCESS) {
-- 
2.56.1.750.gf70dc682cf-goog


  parent reply	other threads:[~2026-11-23  9:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:42 [PATCH 0/2] x86/efi: Disregard stale EFI config tables after kexec Ard Biesheuvel
2026-11-23  9:42 ` [PATCH 1/2] x86/efi: Disregard the INITRD and MEMATTR " Ard Biesheuvel
2026-11-23  9:42 ` Ard Biesheuvel [this message]
2026-11-23 13:05 ` [PATCH 0/2] x86/efi: Disregard stale EFI " jasmeet.bhatia.us

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=20261123094228.466164-6-ardb+git@google.com \
    --to=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=jasmeet.bhatia.us@gmail.com \
    --cc=linux-efi@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