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=1796382015; b=ocnfwccfmehvhtFNdmVkJ6QCDwvTZCBwj+uO0aMfsdZAbuXZf/5TyW8o0al8weKDAQFG L1fezOjRSU7k4Ez1QPwnu8dl2nGL+nL2Tb910StQa/NJr0K6V7GMunDgm1zfTskhHdR3z TZ/srXUwryz+kcBYIvQei5FsS2ff4Ka9StjGXBuJ59ywnZkweJXDVZoxbKC4gaqInInzi iMoekA6t3CJQ7EuyyIDfwtkgBIfFs2a3qKUmsH6ObhwUWOGuHngaPaFJ7tKXKNoQPBzZ/ 7ZmEk6lNkYNBX9ZYeHYtbzH7BirnLbHT/k++AmhpQsaurVbuDWLnyvAcyJWUAUWgyKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382015; 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=TIYKf+ypU2IifLWXchiWwGDWT/HDx/oiMMU7oPx7YBc=; b=DQzV0/9A7fc/S/xhTFE/0HMoGmgnDCWky3t6PnqbOm8CWby26gM9qQCO76ss9nAw4vA0 W8PxKK8ENDPRUUbqsYkJCiTQzJTkyamHAFE3+xXmnkrQ2jrSIr8WXVVnGAYwYRwTewDMf RIKNzUxMsunwKQjXHAxNT3dO/oT1WRlrunFC1s4hCUWv75QJgpVYFXngfsKvu/fXeq7K6 uQ3ec7Ewh2lXJd/fAQSffQLBvKLvD94H8yQ0a67Egv8kvxf6H5iIIPl7/8twpcbhdgcB/ EtGh5vRutApgxbtBbF9oLpa8/QtiH9jTGftFcCF0UVeBgV77xPVLOY6KVAH5Z5X/btA== 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=cIKqNE0y; 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 9F8B4606A32D; Fri, 4 Dec 2026 11:00:15 +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=cIKqNE0y Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4AA31F000C2; Fri, 4 Dec 2026 11:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382015; bh=TIYKf+ypU2IifLWXchiWwGDWT/HDx/oiMMU7oPx7YBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cIKqNE0yJIw+o+hq7LwSFj0TPEO9WwdXxpg+4bEJovnV01U2gx9EwJT/7+YH3312W YBM9O/SbCkMlEBFCXUydhbiMZL1Mw+r+DDvKRcFk3cr+HAKxYK9m1W9VlikblM3krh Hl/6N90x/Ha+s0KJRTUSzYBdqaWRFJo2k6nmMi6g= 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 6.18 269/703] efi/tpm: Allocate the event log from EFI loader data again Date: Fri, 4 Dec 2026 19:02:48 +0900 Message-ID: <20261204100634.937264019@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 2c48a72b2a099..f217a441c5ab7 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -443,6 +443,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 @@ -456,6 +463,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