From nobody Fri Sep 25 09:19:44 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 5F36929D288; Mon, 14 Sep 2026 18:38:02 +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=1789411086; cv=none; b=LaYyMlbh38r5CKqB0KdAD70K6gEJs3As9Eo8Vc+zu9LMRqXRF/4bFgH8j0L/tqYBvtPayw4Zx1/1gVyLmwt/dZH/qAFMy8BCJtebZNKE2sHo1CgxbPyfw5VyBKtHBosgxAysu7cwfEo/pkYVaz0lg/c5wFP0rkYCfdH+jl9K5bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789411086; c=relaxed/simple; bh=7fvC6tmPvvZsBWIGboxc6DT6cqHkjbJK0VVLs3h7yDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dmCGrSdOitHsJeRG6jUaBzLySNV87RjTDIMefpvpIPX56U1z1geUc7AbFBb6rKRg4KNVz1uA3LHnSZuKnhR9/CHB+Xp7Ts0eguR1eBaNQdIs6x9Cj4C2m+iVS8GydyE4YNej8PR9oxKKuP3B6WpSlE4jPyl883i6lcxZmAslWhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RK5wGDAS; 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="RK5wGDAS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5881E1F00899; Mon, 14 Sep 2026 18:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789411079; bh=FmTL5XnLGOB37Jqo77v/tK8G9e1D//jUg3LVsiExQKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RK5wGDASsW564l8HO3NFw1zgso2Etn9WyhYEGIAznQ7TE7Uc94prp/oh0m5wd1tzX d8i0GcAi99rBEKb+MqKkduZcnznTTI7KWKvgCyFKvMdhu26jEcGm5lyiKcAin2sHMU LM7PUMr5UWrWLcWpBU7P/HRSko/yNGvEpyLuluLMfsj0cZEvOyJXYQ9PrbM9FBSk5W P8mrSRcBv3BMm2GE9KZnDFrYAxqZeQU4qG8pJVamwTMHUJCHd/9fj3F/4SGoOXhdCk unFcJ3055lDJeUkHVqyW51nBevHAF00h7kDAD/yeMFfOeVHJp7A9Rq2i4CbcvsmF7r jp5E1zn0Ta4ww== 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 Subject: [PATCH 1/3] x86/tdx: Share tdx_panic() with the EFI stub Date: Mon, 14 Sep 2026 20:37:47 +0200 Message-ID: <20260914183745.37538-6-ardb@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260914183745.37538-5-ardb@kernel.org> References: <20260914183745.37538-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=4390; i=ardb@kernel.org; h=from:subject; bh=7fvC6tmPvvZsBWIGboxc6DT6cqHkjbJK0VVLs3h7yDs=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIWuF3c+pxyXfpN3JUFCTUfrXdWVLpX9MJavS0znGyl9Ff 59z4ODsKGVhEONikBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABMxUGH4p9jW0TL5bMlEO021 2l4zjjd76/4tdlw4schMQPWaXqSjDsP/GoMv5vfaTix3iv71/mHr76WPN14R9+VjeTLF5k+VoXo VMwA= 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. 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/coco/tdx/tdx-shared.c | 35 ++++++++++++++++++++ arch/x86/coco/tdx/tdx.c | 35 -------------------- arch/x86/include/asm/shared/tdx.h | 1 + 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index 1655aa56a0a5..5fc36c8b35db 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -89,3 +89,38 @@ 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 */ + }; + union { + /* Define register order according to the GHCI */ + struct { u64 r14, r15, rbx, rdi, rsi, r8, r9, rdx; }; + + char bytes[64] __nonstring; + } message =3D {}; + + /* VMM assumes '\0' in byte 65, if the message took all 64 bytes */ + memcpy(message.bytes, 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.47.3 From nobody Fri Sep 25 09:19:44 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 6521E39A06D; Mon, 14 Sep 2026 18:38:05 +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=1789411090; cv=none; b=ruw7DOWQhXGjLYVZ3/2QljdHNHEJqOtqyemo22nsEMqGITSKhcx+4WmVe+ocTEB147nc7ZQKUgu/UuboY0/mOhRDUu5jQJpjPos9EZ48KHTLi0Nc4FKYaptga/K7jnqGYzxElvgIaGstAUntL+mxjMkeoPbIjoFBwcZEqlLq+Lc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789411090; c=relaxed/simple; bh=buo+TV4B9A9ue04d3G5s3ntT0h/OLrZvRPQ+pXGsoVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HUzdnurV65MFbOXLBKxKauP4+Fc+e/TBlOQtFos+yvvw2cHxdQTYjRFKlvhBavPZooP4BwlmGftzfIXH8HOG4KFUmNVOzO47q9oujbFW9TuIXwVfqs4jms4aVu/xAYNwurJfARNohH2L8tjoDMscoj1jxzQbOLpx2k+E2mwY8Ec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GGHNSAzR; 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="GGHNSAzR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0713A1F00893; Mon, 14 Sep 2026 18:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789411081; bh=Z4o56JwkEFW73boPUFtrcKj3thXmqi1LZKtly3vu1cE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GGHNSAzR/YhH3QxWKSpLNHwFdrKTCQM++s4yVnSlTjpF5i0eKHg87SWTJS+60Jz6O tmd2pV1U9ekBH9l7e1TB26XBFYY95/AeNM6M+abVf2wXus84n+3nw/BnoVaaZFjdBx Z+EEynR3KHL8940RmbcPqrPx1iIsaeLWq++uK8z9E703MistGlNSU9AFtPZGysg/EO NB7SKar172Fc+bdrEHyaVuwD5rOoYj09bbgJl+NWYJZfKGgnJj1jPbQoiULfZyrYbe IPPb4MwDvV9sfDVUuSFtPwvAAd+ZqpTzW5YpMDHphkO184NNB0+5XcktIC/58Efx2q 8R0tB+TXRJqhQ== 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 Subject: [PATCH 2/3] x86/boot: Move unaccepted memory handling out of the decompressor Date: Mon, 14 Sep 2026 20:37:48 +0200 Message-ID: <20260914183745.37538-7-ardb@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260914183745.37538-5-ardb@kernel.org> References: <20260914183745.37538-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=5848; i=ardb@kernel.org; h=from:subject; bh=buo+TV4B9A9ue04d3G5s3ntT0h/OLrZvRPQ+pXGsoVI=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIWuF3c/iOyf69Vw8uI/N/aa/MfteQeRJ95K8nnX/EyO1N x08a/yqo5SFQYyLQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEzE+i0jw/JJfrGeLsFepx71 M36V3WxxgW12rvHh6UIF+84wm1kv3c7wP+HCpktyPm+FS1uk/lZGLE7e5Cup9bbP46uts8qH1Zv 9WAA= 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 | 40 +++++++++++++++++++ 4 files changed, 42 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..843bf463d14d 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -464,6 +464,8 @@ static __always_inline void sev_es_nmi_complete(void) extern int __init sev_es_efi_map_ghcbs_cas(pgd_t *pgd); extern void sev_enable(struct boot_params *bp); =20 +bool early_is_sevsnp_guest(void); + /* * RMPADJUST modifies the RMP permissions of a page of a lesser- * privileged (numerically higher) VMPL. diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi= /libstub/x86-stub.c index cef32e2c82d8..5009623e4a37 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,41 @@ 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, 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) +{ + 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.47.3 From nobody Fri Sep 25 09:19:44 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 DF74C33F8A2; Mon, 14 Sep 2026 18:38: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=1789411089; cv=none; b=SvdmDMw1fbqx5QOktU36UWQ2lYitlnR1Yw2fxwZlNMIOxmvAKK/4pMuOvVrdEuDiXY/fWYoGDGzTqmS5QF1j1+xjvT4PN3elH2iM3iRWcbIsPj5FNq+25AKxaJBtmxbF3CmGNAoGfjwJuYe/X6rQy0KkNCxUJbXJ1N3gg39/3PU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789411089; c=relaxed/simple; bh=izFpT7OKTB6r+ynqk4XSI+BCN4X4wbUJThWU2dts0e0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=euCSmN9q/d81U3IsZNpERRaYVhg0xEteks001Ew8K92+/6/8cJCcHjOsmoYoPIHyHLczOQM2uswOXT28JvCxd+a64IxG6oq8hP4jwE+u62QEcF/kNdJjbC25CyC5w8GDkc4q7ZG242AV28cA6Ef1v9vL2VpWAsh7rwXctvglLBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LIQWcpns; 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="LIQWcpns" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA5761F000FF; Mon, 14 Sep 2026 18:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789411083; bh=lNSqTRjMqES0isAYw+Wl1SDBpLhQQrsFrzQ9FNYBg58=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LIQWcpnsFpMkp156ePnWQFJOTMRdzrNkCkW3X31h5RM6FPKiECEytomqll4ZOziJ1 HJvSoQ+Ih7qjlVoD58JX36qRlsokNAtSYrSib+vcWaUkWYalhZ9MQf+o2Pr8CGb38/ sH+6g6oWc75KtbE0xSbnxK4qfBqd5QvyuZm4b3VpeZlduNCv2vUosnqCjKoX8Z0fhp AfVYFwAJKDIUbKNTXHDK4IfLhPa/Xu+x4wUIXdpzagi/nd88ua7Qf3cg9OqbQ7+xou J6hipRzlM6RKkvJbNg5cB7KdWStUeKfLH5ck3BgdFyMGHNmt48fzA1SO5xjEb/rimG eXr4wXH9zNJsA== 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 Subject: [PATCH 3/3] x86/boot: Drop unused implementation of panic() Date: Mon, 14 Sep 2026 20:37:49 +0200 Message-ID: <20260914183745.37538-8-ardb@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260914183745.37538-5-ardb@kernel.org> References: <20260914183745.37538-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=izFpT7OKTB6r+ynqk4XSI+BCN4X4wbUJThWU2dts0e0=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIWuF3U+e/P8KzNGWWnvyA4WmrGQ0/B3s/CZGeumi7Z9+n dSJmL6yo5SFQYyLQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAExk+yRGhjvZ7EbeK+wnuCoo /VvWX/kvYMHOgq/2R2f5nqpdz774qQgjw+Tr3V9LxLfvtTMVmFOnuqKL767CqmVv5mecNnsw56r 5MXYA 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.47.3