From nobody Fri Sep 25 09:19:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0460A47126F; Fri, 25 Sep 2026 07:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322722; cv=none; b=sk3XF341bfvkwpU11TIhQ+wXf754VAZ11SvY2tW4psqEvjFSBTTovGHIBu/Zkeh4vgjSE9xLPbCBVycSJfhIiOt5fGtUwlxL2ziRzSgMI1AYkGZ18eZThkHu567x7JeSgJxB/NkLJmzhec4eIfEWNRDnoR0OTQejP0XsITHtgOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322722; c=relaxed/simple; bh=kPoD8lW44V/3nDhlhS9xwNQIIUT/HfnBMhIn+AWS5GM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VJxQd2cXdeXCfFHUqA62OlE05/Q+7Xa0cDgq4cqTXSWdIFtorxS/MpIA16q76o4DocR1M9rXiyZ2RuhsNDgjM2g5mH+L/stH6Yom640xEzeZ/dKYEeBdFUd7FPnqhYOosb0g3HOBKQXOeddHmhsCsfvN62yWqJ1rXXjzEMSOeUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nbeBSiCD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nbeBSiCD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA201F00893; Fri, 25 Sep 2026 07:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790322720; bh=YUwUc3UZFCV/1P38S16BL8NaNwjtsKwGSQSNoePmnDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nbeBSiCDx0cTzIJu00Y9sAjeh/+TfJy7jpND+2F1lnqrHNflzayPdLsbnUI0m2cdO XiLhwnlxl39EdKHBXCx3K72rFOlvQPgbzzExdxOEcgshx067Dn29Q7Z2nrrySPjVnw Vc9nfUjXiZHYmaLMYVRaDMGzBwXw+1+sqWyWXuSq9DgnAY2NzS3Oph7eRSfXaxe2VQ JhGiu8lZZMnESJ9GGMGMpAeMu/zNOYcecw6quZ4sE4SKDfmbVdI+mU/ZurUQJF9vxU 63sd1+Ni48RQ8WpwSmcquhMR/TJD+pZW48vO6IBBIPjEXZVYgMU/2Wterk/7jdpmia Ngn5wE64TjHoA== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , "Kiryl Shutsemau (Meta)" , Borislav Petkov , "Edgecombe, Rick P" Subject: [PATCH v2 1/3] x86/tdx: Share tdx_panic() with the EFI stub Date: Fri, 25 Sep 2026 09:51:39 +0200 Message-ID: <20260925075137.44298-6-ardb@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260925075137.44298-5-ardb@kernel.org> References: <20260925075137.44298-5-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4835; i=ardb@kernel.org; h=from:subject; bh=kPoD8lW44V/3nDhlhS9xwNQIIUT/HfnBMhIn+AWS5GM=; b=owGbwMvMwCn83sBh/rljoYmMp9WSGLK2aXAZZD2P7l6TF6cw03tfbqx7c8qXeecnKGqVi15ks M5nT6zvmMrCIMzJICumyLJTOaf7tYvoO32FyhyYOaxMIEMYuDgFYCIs3xgbGhZssJVXZ/0Uo5Vy f8s7pqvFCqI2ETWalzgTuc1bI9a+/hHC9z6+8YXBiY2fz51ONolmbJjQypv485Ck+fnMvZMaTp8 yO3v2+McbRxI4Jj74Zn2zvkXg1u2+l7lvzlZcdNxo+KW7WBYA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the implementation of tdx_panic() into the source file that is shared with the decompressor and the EFI stub. Use memcpy() and strnlen() instead of strtomem_pad(), as the latter does not exist in the early boot code. Avoid fortify instrumentation in the decompressor/EFI stub by #define'ing __NO_FORTIFY before including tdx-shared.c Note that __tdx_hypercall() may call __tdx_hypercall_failed() if the hypercall returns with an error (while it should never return to begin with). __tdx_hypercall_failed() calls the decompressor's error() routine, which prints a message and then loops forever. When called from the EFI stub, this error() call may attempt to use port I/O to the default serial port rather than the TDX hypercalls which the decompressor uses normally to print diagnostics to the console, but this is fine: given that this situation only occurs after a catastrophic error, and a subsequent spurious return from tdx_panic(), whether error() uses port I/O or not is rather moot at that point, as long as it never returns. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/tdx-shared.c | 2 ++ arch/x86/coco/tdx/tdx-shared.c | 31 +++++++++++++++++ arch/x86/coco/tdx/tdx.c | 35 -------------------- arch/x86/include/asm/shared/tdx.h | 1 + 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/arch/x86/boot/compressed/tdx-shared.c b/arch/x86/boot/compress= ed/tdx-shared.c index 5ac43762fe13..dc38047647cc 100644 --- a/arch/x86/boot/compressed/tdx-shared.c +++ b/arch/x86/boot/compressed/tdx-shared.c @@ -1,2 +1,4 @@ +#define __NO_FORTIFY + #include "error.h" #include "../../coco/tdx/tdx-shared.c" diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index 1655aa56a0a5..29661d8dfe8e 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -89,3 +89,34 @@ noinstr u64 __tdx_hypercall(struct tdx_module_args *args) /* TDVMCALL leaf return code is in R10 */ return args->r10; } + +void __noreturn tdx_panic(const char *msg) +{ + struct tdx_module_args args =3D { + .r10 =3D TDX_HYPERCALL_STANDARD, + .r11 =3D TDVMCALL_REPORT_FATAL_ERROR, + .r12 =3D 0, /* Error code: 0 is Panic */ + }; + /* Define register order according to the GHCI */ + struct { u64 r14, r15, rbx, rdi, rsi, r8, r9, rdx; } message =3D {}; + + /* VMM assumes '\0' in byte 65, if the message took all 64 bytes */ + memcpy(&message, msg, strnlen(msg, sizeof(message))); + + args.r8 =3D message.r8; + args.r9 =3D message.r9; + args.r14 =3D message.r14; + args.r15 =3D message.r15; + args.rdi =3D message.rdi; + args.rsi =3D message.rsi; + args.rbx =3D message.rbx; + args.rdx =3D message.rdx; + + /* + * This hypercall should never return and it is not safe + * to keep the guest running. Call it forever if it + * happens to return. + */ + while (1) + __tdx_hypercall(&args); +} diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index f904a636d449..a9a16d0fb5c2 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -198,41 +198,6 @@ u64 tdx_hcall_get_quote(u8 *buf, size_t size) } EXPORT_SYMBOL_GPL(tdx_hcall_get_quote); =20 -static void __noreturn tdx_panic(const char *msg) -{ - struct tdx_module_args args =3D { - .r10 =3D TDX_HYPERCALL_STANDARD, - .r11 =3D TDVMCALL_REPORT_FATAL_ERROR, - .r12 =3D 0, /* Error code: 0 is Panic */ - }; - union { - /* Define register order according to the GHCI */ - struct { u64 r14, r15, rbx, rdi, rsi, r8, r9, rdx; }; - - char bytes[64] __nonstring; - } message; - - /* VMM assumes '\0' in byte 65, if the message took all 64 bytes */ - strtomem_pad(message.bytes, msg, '\0'); - - args.r8 =3D message.r8; - args.r9 =3D message.r9; - args.r14 =3D message.r14; - args.r15 =3D message.r15; - args.rdi =3D message.rdi; - args.rsi =3D message.rsi; - args.rbx =3D message.rbx; - args.rdx =3D message.rdx; - - /* - * This hypercall should never return and it is not safe - * to keep the guest running. Call it forever if it - * happens to return. - */ - while (1) - __tdx_hypercall(&args); -} - /* * The kernel cannot handle #VEs when accessing normal kernel memory. Ensu= re * that no #VE will be delivered for accesses to TD-private memory. diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/share= d/tdx.h index f20e91d7ac35..e5785258e547 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -171,6 +171,7 @@ static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r= 13, u64 r14, u64 r15) return __tdx_hypercall(&args); } =20 +void __noreturn tdx_panic(const char *msg); =20 /* Called from __tdx_hypercall() for unrecoverable failure */ void __noreturn __tdx_hypercall_failed(void); --=20 2.53.0 From nobody Fri Sep 25 09:19:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E3BA472521; Fri, 25 Sep 2026 07:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322725; cv=none; b=YZXmGbTMbt/SDg5W5Qg/ZRRf7OVMB+OWCHVxcWSQvIfSx1JsgAEDk+1U1ii85vbJaTfBlfJU7x2MQTt/tTP2vKSPA7Fd8Cb4o1Zx8azja9jDLbZdL/3YHBXdCrJdbO9sq1T1ZuoFvHjCIVaH+bPw1azmtxHUjP5EhmXsJfrnxow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322725; c=relaxed/simple; bh=71mGxAzLcQPoNeORpGuq8IqoDwiJDyUGD/Ks++Ev8Po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WhlHPw3apOllF0xfkfGqtEessiT1s0bFmoMC76YjjKMaCySbzvDo0rb14lYDHJIcxzybq8VhFKwVzN2k9rMTUr7lnJO8A0yiStOluVdKsZKZ7YYlbFTvEC+Hkz+rWH/+3oYkNNGYbH+D5LJHeETcOmqtg96KdGWD9Roj8zfYbhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G2syX2Mo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G2syX2Mo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D6141F000FF; Fri, 25 Sep 2026 07:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790322724; bh=9YY5Gywu/GZ0CW+bb3YA7j7g0CCf7ew/7WGXkzNuqGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=G2syX2Mox5sq7+fM+k341dG3u8WXVLimWZysbqQ3cSwDwjttVWA5XvlhiwXD5GAoO g4QpBPpv9pvTgYEeiOVYP4elsCJJbVNYkd8lAG4fFvXbaEA743/+lVEPpOVYUFfuOD MFsx0TnM6DPo3b51hQK/Q9Gh9OVU+X2hLgrePmWPrePFWVXF88Emy9MEp77LZ9okHo z1znVEl11IqJGgY/r00im/M7fF8ElUeEuHO6YbAdZXeIuGDA2PO8z1Oiwo8l72k0JQ cSML3JQ0GmpkDDAcgSV4BkoHdqwgql8RYIPTG0m+7LOKe8fBLhbMcWdJPAusO3bKIt 9lFHdI9HMBBrg== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , "Kiryl Shutsemau (Meta)" , Borislav Petkov , "Edgecombe, Rick P" Subject: [PATCH v2 2/3] x86/boot: Move unaccepted memory handling out of the decompressor Date: Fri, 25 Sep 2026 09:51:40 +0200 Message-ID: <20260925075137.44298-7-ardb@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260925075137.44298-5-ardb@kernel.org> References: <20260925075137.44298-5-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6435; i=ardb@kernel.org; h=from:subject; bh=71mGxAzLcQPoNeORpGuq8IqoDwiJDyUGD/Ks++Ev8Po=; b=owGbwMvMwCn83sBh/rljoYmMp9WSGLK2aXCxlndqb14Yt83DYtIzA7870/TD5qvs+jD5bMoFo 51sBRe+d0xlYRDmZJAVU2TZqZzT/dpF9J2+QmUOzBxWJpAhDFycAjCRC9yMdYZ7zn1tF/c+fqd8 3ua/hzOTvT9PbZ6mdOTzvk31lVwcYQJ/OpbfXC++Q0GaI2daac4xBcaGm4rFOScn99ZlH3u7ZKu g4vT0jSm8vMair9KEW6PPzGeOcvyVd+bQT8VVE/LP6sSKve0FAA== X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" arch_accept_memory() is an arch-specific hook that is required by the EFI stub when processing memory that the firmware reports to the OS as EFI_UNACCEPTED_MEMORY. This hook is called after ExitBootServices() has been called, as before that point, the EFI memory map may get updated behind the back of the running EFI stub, making it difficult to get a stable view on it while iterating over the entries. Currently, the x86 version of this hook is implemented in its decompressor rather than in the EFI stub itself, in a manner that is problematic: when an error occurs, it calls the decompressor's error() routine, but without having gone through the decompressor initialization code. This means it will resort to direct port I/O rather than the hypercall based interface that TDX guests would use otherwise. Conceptually, code that is only called from the EFI stub, and never by the decompressor when doing legacy boot, belongs in the EFI stub and not in the decompressor. So move it into the x86-specific EFI stub code, replacing the error() on the TDX path with tdx_panic(), and dropping the error() when no CC support is detected - the kernel can decide what to do in this case after it has booted. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/mem.c | 42 -------------------- arch/x86/boot/compressed/sev.h | 2 - arch/x86/include/asm/sev.h | 2 + drivers/firmware/efi/libstub/x86-stub.c | 39 ++++++++++++++++++ 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/arch/x86/boot/compressed/mem.c b/arch/x86/boot/compressed/mem.c index 0e9f84ab4bdc..1721af3a8039 100644 --- a/arch/x86/boot/compressed/mem.c +++ b/arch/x86/boot/compressed/mem.c @@ -2,48 +2,6 @@ =20 #include "error.h" #include "misc.h" -#include "tdx.h" -#include "sev.h" -#include - -/* - * accept_memory() and process_unaccepted_memory() called from EFI stub wh= ich - * runs before decompressor and its early_tdx_detect(). - * - * Enumerate TDX directly from the early users. - */ -static bool early_is_tdx_guest(void) -{ - static bool once; - static bool is_tdx; - - if (!IS_ENABLED(CONFIG_INTEL_TDX_GUEST)) - return false; - - if (!once) { - u32 eax, sig[3]; - - cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, - &sig[0], &sig[2], &sig[1]); - is_tdx =3D !memcmp(TDX_IDENT, sig, sizeof(sig)); - once =3D true; - } - - return is_tdx; -} - -void arch_accept_memory(phys_addr_t start, phys_addr_t end) -{ - /* Platform-specific memory-acceptance call goes here */ - if (early_is_tdx_guest()) { - if (!tdx_accept_memory(start, end)) - panic("TDX: Failed to accept memory\n"); - } else if (early_is_sevsnp_guest()) { - snp_accept_memory(start, end); - } else { - error("Cannot accept memory: unknown platform\n"); - } -} =20 bool init_unaccepted_memory(void) { diff --git a/arch/x86/boot/compressed/sev.h b/arch/x86/boot/compressed/sev.h index 22637b416b46..62e50c2e71ed 100644 --- a/arch/x86/boot/compressed/sev.h +++ b/arch/x86/boot/compressed/sev.h @@ -14,7 +14,6 @@ =20 void snp_accept_memory(phys_addr_t start, phys_addr_t end); u64 sev_get_status(void); -bool early_is_sevsnp_guest(void); =20 static inline u64 sev_es_rd_ghcb_msr(void) { @@ -37,7 +36,6 @@ static inline void sev_es_wr_ghcb_msr(u64 val) =20 static inline void snp_accept_memory(phys_addr_t start, phys_addr_t end) {= } static inline u64 sev_get_status(void) { return 0; } -static inline bool early_is_sevsnp_guest(void) { return false; } =20 #endif =20 diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h index 9e7a077c445d..4b5db43cc0b1 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -517,6 +517,7 @@ void snp_accept_memory(phys_addr_t start, phys_addr_t e= nd); u64 snp_get_unsupported_features(u64 status); u64 sev_get_status(void); void sev_show_status(void); +bool early_is_sevsnp_guest(void); int prepare_pte_enc(struct pte_enc_desc *d); void set_pte_enc_mask(pte_t *kpte, unsigned long pfn, pgprot_t new_prot); void snp_kexec_finish(void); @@ -626,6 +627,7 @@ static inline void snp_accept_memory(phys_addr_t start,= phys_addr_t end) { } static inline u64 snp_get_unsupported_features(u64 status) { return 0; } static inline u64 sev_get_status(void) { return 0; } static inline void sev_show_status(void) { } +static inline bool early_is_sevsnp_guest(void) { return false; } static inline int prepare_pte_enc(struct pte_enc_desc *d) { return 0; } static inline void set_pte_enc_mask(pte_t *kpte, unsigned long pfn, pgprot= _t new_prot) { } static inline void snp_kexec_finish(void) { } diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi= /libstub/x86-stub.c index cef32e2c82d8..80556a7e7552 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -10,6 +10,7 @@ #include #include =20 +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include =20 #include "efistub.h" #include "x86-stub.h" @@ -1068,3 +1070,40 @@ void efi64_stub_entry(efi_handle_t handle, efi_syste= m_table_t *sys_table_arg, struct boot_params *boot_params); #endif #endif + +#ifdef CONFIG_UNACCEPTED_MEMORY +/* + * process_unaccepted_memory() is called after ExitBootServices(), and so = these + * memory acceptance routines cannot rely on EFI protocols for detecting t= he + * presence of TDX or SEV-SNP, or emit any kind of output if any error + * conditions are detected. + */ +static bool early_is_tdx_guest(void) +{ + static bool once; + static bool is_tdx; + + if (!IS_ENABLED(CONFIG_INTEL_TDX_GUEST)) + return false; + + if (!once) { + u32 eax =3D TDX_CPUID_LEAF_ID, sig[3] =3D {}; + + native_cpuid(&eax, &sig[0], &sig[2], &sig[1]); + is_tdx =3D !memcmp(TDX_IDENT, sig, sizeof(sig)); + once =3D true; + } + + return is_tdx; +} + +void arch_accept_memory(phys_addr_t start, phys_addr_t end) +{ + if (early_is_tdx_guest()) { + if (!tdx_accept_memory(start, end)) + tdx_panic("Failed to accept memory"); + } else if (early_is_sevsnp_guest()) { + snp_accept_memory(start, end); + } +} +#endif --=20 2.53.0 From nobody Fri Sep 25 09:19:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76759472F6C; Fri, 25 Sep 2026 07:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322728; cv=none; b=PQbeX4FK1Z5evzJcSJpXnB0a2j5e5A2gm7lNhOn9cgRYKtuPQRmgpbQSeYJ15uQdslex5pd+ee3N9nMZ3cmRK8/7am4gHCsFFQxYfDy6Uioyho+xsZk6NzaEHQJQSCwFowHBphbID+OqUkX1dCupsy7orEkTqSx05x2BuFi8iYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790322728; c=relaxed/simple; bh=crAnev32KuLVSJVQjGvR5L9UQnWQcWYK9AIZ7Pe38lw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sK0X27NjTm3sJKshxDSwPV88cTaPKohsSZcPqPRcg5FcoIp3rEGbfCLTFWh2JT0IqU844iY2Rg5TfLUgHxkUl0xY95z710OJnDXI2KEDSOlJqihtsXbRYf5IJhvLorEg/NVMnyq2ZdPXg0Psy3VAVuQ0WyJwbSysaJvwqNMkr2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N6SHolFL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N6SHolFL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E3A21F00893; Fri, 25 Sep 2026 07:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790322727; bh=nAjjmueqCXIzlMRnAfqoy03r2hmAnD29o4maM9aKTQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N6SHolFLa6lDebw2ouaPOAOdlejWz6gwgUhmD/Jgm0NlWcTI3hnfdGHS3iUHgqVA5 ibx29oHhnQRxwTBSAfGXg4wDjHlXMued0VACvY5KHkxkbX5PRIT0cNjJwwrYiZQauW EFRY0nY2kJKahqLIjAfkyKj3BboAjvJnNbQGETq/PJSqHlxOGgrBZxDfjCV6+I31x2 G9P9WX+C6R8pMk/wpuCGM9ADATuwWzudS/B/j3RVHPx8EN73va/ZNzo3526cw4Ve1H GbK15wqGPZ2YtdrNgqeFqo1cD6rGAC62VQzWZh/Jly02dZuL0nUY655J3+5X4FuyNs 7ymINlBRO8YQQ== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , "Kiryl Shutsemau (Meta)" , Borislav Petkov , "Edgecombe, Rick P" Subject: [PATCH v2 3/3] x86/boot: Drop unused implementation of panic() Date: Fri, 25 Sep 2026 09:51:41 +0200 Message-ID: <20260925075137.44298-8-ardb@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260925075137.44298-5-ardb@kernel.org> References: <20260925075137.44298-5-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1687; i=ardb@kernel.org; h=from:subject; bh=crAnev32KuLVSJVQjGvR5L9UQnWQcWYK9AIZ7Pe38lw=; b=owGbwMvMwCn83sBh/rljoYmMp9WSGLK2aXDZhea8PxooGarCsD3HZJOv29J9n9nO7pzwfDHjZ dt/HcGfOqayMAhzMsiKKbLsVM7pfu0i+k5foTIHZg4rE8gQBi5OAZhIuBJjQ5vR0S3TuxnqVmR+ TC4t0PP5IJDVsUL3VmhM0o44d1aW2ElrtR+uE/QSthCo/6yxclIFY8Nkry0nlzIfnVdkFGS9+lt 3JkvkAYEZystUpjw6caeDqVmfqzw19f+W468MXD+3ahkFrQAA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The decompressor has its own implementation of panic(), which is based on the vsnprintf() routine provided by the EFI stub. The decompressor's panic() has no remaining users, and is implemented in terms of the EFI stub's snprintf() implementation, which is going away (and relying on the EFI stub from code that does not execute in the context of the EFI boot services is a bad idea in general). So drop it. Acked-by: Kiryl Shutsemau (Meta) Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/error.c | 19 ------------------- arch/x86/boot/compressed/error.h | 1 - 2 files changed, 20 deletions(-) diff --git a/arch/x86/boot/compressed/error.c b/arch/x86/boot/compressed/er= ror.c index 19a8251de506..ce5ed7d8265e 100644 --- a/arch/x86/boot/compressed/error.c +++ b/arch/x86/boot/compressed/error.c @@ -22,22 +22,3 @@ void error(char *m) while (1) asm("hlt"); } - -/* EFI libstub provides vsnprintf() */ -#ifdef CONFIG_EFI_STUB -void panic(const char *fmt, ...) -{ - static char buf[1024]; - va_list args; - int len; - - va_start(args, fmt); - len =3D vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - - if (len && buf[len - 1] =3D=3D '\n') - buf[len - 1] =3D '\0'; - - error(buf); -} -#endif diff --git a/arch/x86/boot/compressed/error.h b/arch/x86/boot/compressed/er= ror.h index 31f9e080d61a..87062dea9a20 100644 --- a/arch/x86/boot/compressed/error.h +++ b/arch/x86/boot/compressed/error.h @@ -6,6 +6,5 @@ =20 void warn(const char *m); void error(char *m) __noreturn; -void panic(const char *fmt, ...) __noreturn __cold; =20 #endif /* BOOT_COMPRESSED_ERROR_H */ --=20 2.53.0