* [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820
@ 2026-09-01 11:34 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 1/2] efi/libstub: Install memreserve table on x86 Jasmeet (Jazz) Bhatia
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jasmeet (Jazz) Bhatia @ 2026-09-01 11:34 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Ilias Apalodimas, rafael, Pavel Machek, linux-efi, linux-pm, x86,
linux-kernel, Jasmeet (Jazz) Bhatia
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").
This patch series instead installs the Linux EFI memreserve table on the
x86 stub path and then uses efi_mem_reserve_persistent() to preserve the
TPM event log across kexec while keeping the allocation as
EFI_LOADER_DATA.
The series was also backported to Linux 7.2 for validation on the
affected system.
Results:
- stock 7.2:
TPM event log allocation changes the E820 map across boots;
hibernation resume fails
- EFI_LOADER_DATA-only diagnostic build:
E820 map remains stable;
hibernation resume succeeds
- this series:
TPM range is persistently reserved;
hibernation resume succeeds with the normal device drivers;
kexec_file_load() succeeds with the TPM range preserved;
kexec_load() succeeds with the TPM range preserved
For kexec_file_load(), the event log had the same size and SHA256 digest
before and after kexec. For kexec_load(), the before and after event log
files compared byte-for-byte identical.
The original report and investigation are here:
https://lore.kernel.org/all/DL3MNWW4VEBR.K3K6A92WMHUY@gmail.com/
Patch 1 makes the existing EFI memreserve table installer available to
the x86 EFI stub path.
Patch 2 switches the TPM event log allocation back to EFI_LOADER_DATA
and persistently reserves it after the normal TPM event log reservation
has succeeded.
Jasmeet (Jazz) Bhatia (2):
efi/libstub: Install memreserve table on x86
efi/tpm: Persistently reserve the TPM event log
.../firmware/efi/libstub/efi-stub-helper.c | 23 ++++++++++++++++
drivers/firmware/efi/libstub/efi-stub.c | 23 ----------------
drivers/firmware/efi/libstub/efistub.h | 1 +
drivers/firmware/efi/libstub/tpm.c | 2 +-
drivers/firmware/efi/libstub/x86-stub.c | 2 ++
drivers/firmware/efi/tpm.c | 27 +++++++++++++++++++
6 files changed, 54 insertions(+), 24 deletions(-)
base-commit: 786262be6048deab760f68c8acc2c85607165894
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/2] efi/libstub: Install memreserve table on x86
2026-09-01 11:34 [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Jasmeet (Jazz) Bhatia
@ 2026-09-01 11:34 ` Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log Jasmeet (Jazz) Bhatia
2026-09-03 14:18 ` [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Ard Biesheuvel
2 siblings, 0 replies; 4+ messages in thread
From: Jasmeet (Jazz) Bhatia @ 2026-09-01 11:34 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Ilias Apalodimas, rafael, Pavel Machek, linux-efi, linux-pm, x86,
linux-kernel, Jasmeet (Jazz) Bhatia
The generic EFI stub installs the Linux EFI memreserve configuration
table from efi_stub_common(), but x86 uses a separate EFI stub path.
Consequently, efi_mem_reserve_persistent() cannot be used on x86 when
no memreserve root has been installed.
Move install_memreserve_table() to the common stub helper code, expose
it through efistub.h, and invoke it from the x86 stub before exiting
boot services.
This allows x86 kernels to add persistent EFI memory reservations that
are carried across kexec.
Signed-off-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@gmail.com>
---
.../firmware/efi/libstub/efi-stub-helper.c | 23 +++++++++++++++++++
drivers/firmware/efi/libstub/efi-stub.c | 23 -------------------
drivers/firmware/efi/libstub/efistub.h | 1 +
drivers/firmware/efi/libstub/x86-stub.c | 2 ++
4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index f27f2e1f0019..9ea0ed0ed7d1 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -27,6 +27,29 @@ static bool efi_disable_pci_dma = IS_ENABLED(CONFIG_EFI_DISABLE_PCI_DMA);
int efi_mem_encrypt;
+void install_memreserve_table(void)
+{
+ struct linux_efi_memreserve *rsv;
+ efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
+ efi_status_t status;
+
+ status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
+ (void **)&rsv);
+ if (status != EFI_SUCCESS) {
+ efi_err("Failed to allocate memreserve entry!\n");
+ return;
+ }
+
+ rsv->next = 0;
+ rsv->size = 0;
+ atomic_set(&rsv->count, 0);
+
+ status = efi_bs_call(install_configuration_table,
+ &memreserve_table_guid, rsv);
+ if (status != EFI_SUCCESS)
+ efi_err("Failed to install memreserve config table!\n");
+}
+
bool __pure __efi_soft_reserve_enabled(void)
{
return !efi_nosoftreserve;
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 42d6073bcd06..e378dd7db682 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -77,29 +77,6 @@ static struct sysfb_display_info *setup_primary_display(void)
return NULL;
}
-static void install_memreserve_table(void)
-{
- struct linux_efi_memreserve *rsv;
- efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
- efi_status_t status;
-
- status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
- (void **)&rsv);
- if (status != EFI_SUCCESS) {
- efi_err("Failed to allocate memreserve entry!\n");
- return;
- }
-
- rsv->next = 0;
- rsv->size = 0;
- atomic_set(&rsv->count, 0);
-
- status = efi_bs_call(install_configuration_table,
- &memreserve_table_guid, rsv);
- if (status != EFI_SUCCESS)
- efi_err("Failed to install memreserve config table!\n");
-}
-
static u32 get_supported_rt_services(void)
{
const efi_rt_properties_table_t *rt_prop_table;
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index fd91fc15ec81..8656d6a545e5 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1168,6 +1168,7 @@ efi_enable_reset_attack_mitigation(void) { }
#endif
void efi_retrieve_eventlog(void);
+void install_memreserve_table(void);
struct sysfb_display_info *alloc_primary_display(void);
struct sysfb_display_info *__alloc_primary_display(void);
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index cef32e2c82d8..4a24126ccfd9 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -1015,6 +1015,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
efi_retrieve_eventlog();
+ install_memreserve_table();
+
setup_graphics(boot_params);
setup_efi_pci(boot_params);
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log
2026-09-01 11:34 [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 1/2] efi/libstub: Install memreserve table on x86 Jasmeet (Jazz) Bhatia
@ 2026-09-01 11:34 ` Jasmeet (Jazz) Bhatia
2026-09-03 14:18 ` [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Ard Biesheuvel
2 siblings, 0 replies; 4+ messages in thread
From: Jasmeet (Jazz) Bhatia @ 2026-09-01 11:34 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Ilias Apalodimas, rafael, Pavel Machek, linux-efi, linux-pm, x86,
linux-kernel, Jasmeet (Jazz) Bhatia
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@gmail.com/
Signed-off-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820
2026-09-01 11:34 [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 1/2] efi/libstub: Install memreserve table on x86 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log Jasmeet (Jazz) Bhatia
@ 2026-09-03 14:18 ` Ard Biesheuvel
2 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2026-09-03 14:18 UTC (permalink / raw)
To: Jasmeet (Jazz) Bhatia
Cc: Ilias Apalodimas, Rafael J . Wysocki, Pavel Machek, linux-efi,
linux-pm, x86, linux-kernel
Hi Jazz,
On Tue, 1 Sep 2026, at 13:34, Jasmeet (Jazz) Bhatia wrote:
> 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").
>
As I replied in the other thread, I am not convinced preserving the TPM
event log across a kexec makes sense to begin with. This is the firmware's
view of the state of the TPM PCRs when it handed over the system to the
first OS.
If the first OS boots, loads a kexec kernel and then boots it without
measuring any of that into the TPM, the TPM event log will match the
TPM state, but this is meaningless because of the missing measurements,
and the attestation chain is broken.
If the first OS does perform TPM measurements, it would need to record
them into a log and pass that on to the kexec'ed in some implementation
specific way - it cannot use the existing TPM event log for that.
TL;DR perhaps we should just discard the TPM event log reference from
the EFI config tables after consuming it. Or add a special case to the
kexec code to disregard it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-03 14:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 11:34 [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 1/2] efi/libstub: Install memreserve table on x86 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` [PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log Jasmeet (Jazz) Bhatia
2026-09-03 14:18 ` [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox