[PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log
From: Jasmeet (Jazz) Bhatia
Date: Tue Sep 01 2026 - 07:34:32 EST
Commit 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event
log to avoid corruption") changed the TPM event log allocation from
EFI_LOADER_DATA to EFI_ACPI_RECLAIM_MEMORY so that the memory would
remain reserved across kexec.
On x86, EFI_ACPI_RECLAIM_MEMORY is represented as ACPI data in the
E820 map. If the EFI allocator places the event log at a different
physical address on a subsequent boot, this changes the firmware E820
map.
x86 hibernation records architecture-specific information derived
from that map and rejects the image when it differs on resume:
Hibernate inconsistent memory map detected!
PM: hibernation: Image mismatch: architecture specific data
This occurs on a Framework Laptop 16 (AMD Ryzen AI 300 Series), where
the EFI allocation backing the TPM event log was observed at different
addresses across otherwise ordinary boots.
Allocate the event log from EFI_LOADER_DATA again so that the
Linux-created allocation does not appear as an E820 ACPI region.
Preserve the kexec protection provided by commit 77d48d39e991
("efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption")
by adding the event log range to the Linux EFI persistent memreserve
table.
On Linux 7.2, the stock kernel failed hibernation resume because of the
E820 mismatch, while both an EFI_LOADER_DATA-only diagnostic build and
this series resumed successfully.
With this series, the TPM event log range remained reserved across
both kexec_file_load() and kexec_load(). The contents exported through
binary_bios_measurements were byte-for-byte identical before and after
both kexec tests.
Fixes: 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption")
Link: https://lore.kernel.org/all/DL3MNWW4VEBR.K3K6A92WMHUY@xxxxxxxxx/
Signed-off-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@xxxxxxxxx>
---
drivers/firmware/efi/libstub/tpm.c | 2 +-
drivers/firmware/efi/tpm.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index a5c6c4f163fc..8e04aaf428d0 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) {
diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index cdd431027065..9771cc91d71e 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -15,6 +15,9 @@
int efi_tpm_final_log_size;
EXPORT_SYMBOL(efi_tpm_final_log_size);
+#ifdef CONFIG_KEXEC_CORE
+static unsigned int efi_tpm_eventlog_size __initdata;
+#endif
static int __init tpm2_calc_event_log_size(void *data, int count, void *size_info)
{
@@ -68,6 +71,10 @@ int __init efi_tpm_eventlog_init(void)
goto out;
}
+#ifdef CONFIG_KEXEC_CORE
+ efi_tpm_eventlog_size = tbl_size;
+#endif
+
if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR) {
pr_info("TPM Final Events table not present\n");
goto out;
@@ -114,3 +121,23 @@ int __init efi_tpm_eventlog_init(void)
return ret;
}
+#ifdef CONFIG_KEXEC_CORE
+static int __init efi_tpm_eventlog_reserve_persistent(void)
+{
+ int ret;
+
+ if (efi.tpm_log == EFI_INVALID_TABLE_ADDR ||
+ !efi_tpm_eventlog_size)
+ return 0;
+
+ ret = efi_mem_reserve_persistent(efi.tpm_log,
+ efi_tpm_eventlog_size);
+ if (ret)
+ pr_warn("Failed to persistently reserve TPM Event Log: %d\n",
+ ret);
+
+ return 0;
+}
+late_initcall(efi_tpm_eventlog_reserve_persistent);
+#endif
+
--
2.55.0