From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380344; b=sK/0eztTovRDJPIISu+ZWUpNJt9bT1jGHlHbsVdzJOvo4I+oQk23pFT57SKFLBDfGw/T jMpzvmcEfUhVuIYdzzaFNhKNo0ef3IK+jy2fKHFyViSghzNO5RzVkplUFCS8SfwSRT0iv DXm1c22NlWkMeabojWhGqZ3RFt7yri1UaiycDqgQ9onzCQKnvIDjyMOG7R0qtRjCrgJQt TRPeTaE4Orn6xR4bIwSubLdYWCVE6U0nOsFIGtmxjoR5C3kG1XSzV3MCMgMT9Qnf/G/pv 4qGbrj2yP7ilY+gjJlVzpVaAVjvVR3vU7683uXAjfpvId/Hwr1CF0fbJaS/86ZPeI8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380344; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=0JV9LfVV4ILuuYkiFflPF4r8kT2yLplwyGOZ0jUttjs=; b=u0Q/ZL6mYsBRAKEU5HhlPqF5Q3OCS1eohIpvpkgb5W1mk7H6dIieHlhzYyKVMoOeseu6 8tcsA7VMLkhp1neNP1iqmo8MXCXiQUGsicFRKJAGAxtw78QF/Tvfrx3YtM54WNhLjoyVx 2McEmOWTmEXCl/0kbh7j1xpLSHnYxlVvdW5xUzy47nP7/FLZp7sQbhNLw6Se0gFTpy2FE jfyTIi3N/hKZz5b6X6Y1VWTwJRnAHHgjD5rMES36Fku+3OR7zoaQXwSKGU7lbQ92EcvsC qltXX3vVM1S2LipU4YWH+DGjGQbSQtMcTCUiA/I5UFICHP0y/H9nMZXEUvwhfH21Ceg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LbqWBRiX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A23DD606A32C; Fri, 4 Dec 2026 10:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LbqWBRiX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B6371F0092C; Fri, 4 Dec 2026 10:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380344; bh=0JV9LfVV4ILuuYkiFflPF4r8kT2yLplwyGOZ0jUttjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LbqWBRiXvMPaAmsJvAj+jLf7d/YvdvjnunwzstkeWhjKb1MRDTH/tMUuoGzKcQOUC kbrc9zHUiKTD032O4GmiMlcDVu6+OhkAcD5gO88iT4kbYbwfJA5Bo/ABG0+vm+3IF0 08I2b6Q1COWQ/Db1SSRGq+G+YQahvfsKGaKBPtUw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Jasmeet (Jazz) Bhatia" , Ard Biesheuvel , Sasha Levin Subject: [PATCH 7.3 234/742] efi/tpm: Allocate the event log from EFI loader data again Date: Fri, 4 Dec 2026 19:01:38 +0900 Message-ID: <20261204100641.286603526@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel [ Upstream commit cc919b0db7d322c65067801869bc6354669726dc ] 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. Tested-by: Jasmeet (Jazz) Bhatia Fixes: 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption") Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- arch/x86/platform/efi/efi.c | 8 ++++++++ drivers/firmware/efi/libstub/tpm.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index d74d44bf2605b..a649f282aacd5 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -442,6 +442,13 @@ 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. It is allocated + * from EFI loader data rather than ACPI reclaim memory, as the latter would + * create an E820 entry that may move around between boots, which breaks + * resume from hibernation. It is reserved by the kernel, but the E820 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 +462,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 73f0011147323..b8183bfdbaa3d 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.53.0