From: Vishal Verma <vishal.l.verma@intel.com>
To: x86@kernel.org, Dave Hansen <dave.hansen@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Kiryl Shutsemau <kas@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev,
kvm@vger.kernel.org, Vishal Verma <vishal.l.verma@intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v2] x86/tdx: Remove the early #VE handler
Date: Mon, 02 Nov 2026 15:49:35 -0700 [thread overview]
Message-ID: <20261102-b4-tdx_remove_early_ve_handler-v2-1-71361d14f359@intel.com> (raw)
tdx_early_handle_ve() emulates port I/O for #VEs taken before
idt_setup_early_traps() installs the real #VE gate. Per commit
32e72854fa5f ("x86/tdx: Port I/O: Add early boot support"), it exists to
support earlyprintk's serial driver.
"earlyprintk=" and "earlycon=" are both early_param() handlers, so no
console can be registered before parse_early_param(), which runs from
setup_arch(), after idt_setup_early_traps() has replaced the early IDT.
Nothing in the window between idt_setup_early_handler() and
idt_setup_early_traps() does port I/O, so this emulation doesn't ever
get called.
Remove the handler. Any #VE in the early window now falls through to
early_fixup_exception().
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
---
Changes in v2:
- Add review tags (Rick, Kiryl, Nikolay)
- Move LLM attribution below the ---
- Rebase to v7.4-rc1
- Link to v1: https://patch.msgid.link/20260910-b4-tdx_remove_early_ve_handler-v1-1-bf47a4d360c5@intel.com
---
Found with the help of an LLM observing that the real IDT is installed
before parse_early_param(). LLMs were also used to verify this. On a TDX
guest booted with earlyprintk, a counter added to tdx_early_handle_ve()
for testing remained 0 after boot.
---
arch/x86/include/asm/tdx.h | 4 ----
arch/x86/coco/tdx/tdx.c | 22 ----------------------
arch/x86/kernel/head64.c | 3 ---
3 files changed, 29 deletions(-)
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 1fcfaed515fec..3f7a96b85beb0 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -76,8 +76,6 @@ bool tdx_handle_virt_exception(struct pt_regs *regs, struct ve_info *ve);
void tdx_halt(void);
-bool tdx_early_handle_ve(struct pt_regs *regs);
-
int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport);
int tdx_mcall_extend_rtmr(u8 index, u8 *data);
@@ -94,8 +92,6 @@ void __init tdx_dump_td_ctls(u64 td_ctls);
static inline void tdx_early_init(void) { };
static inline void tdx_halt(void) { };
-static inline bool tdx_early_handle_ve(struct pt_regs *regs) { return false; }
-
#endif /* CONFIG_INTEL_TDX_GUEST */
#if defined(CONFIG_KVM_GUEST) && defined(CONFIG_INTEL_TDX_GUEST)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 8bacbef62891f..288142062991e 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -737,28 +737,6 @@ static int handle_io(struct pt_regs *regs, struct ve_info *ve)
return ve_instr_len(ve);
}
-/*
- * Early #VE exception handler. Only handles a subset of port I/O.
- * Intended only for earlyprintk. If failed, return false.
- */
-__init bool tdx_early_handle_ve(struct pt_regs *regs)
-{
- struct ve_info ve;
- int insn_len;
-
- tdx_get_ve_info(&ve);
-
- if (ve.exit_reason != EXIT_REASON_IO_INSTRUCTION)
- return false;
-
- insn_len = handle_io(regs, &ve);
- if (insn_len < 0)
- return false;
-
- regs->ip += insn_len;
- return true;
-}
-
void tdx_get_ve_info(struct ve_info *ve)
{
struct tdx_module_args args = {};
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index fd28b53dbac51..7b8b13f454545 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -166,9 +166,6 @@ void __init do_early_exception(struct pt_regs *regs, int trapnr)
trapnr == X86_TRAP_VC && handle_vc_boot_ghcb(regs))
return;
- if (trapnr == X86_TRAP_VE && tdx_early_handle_ve(regs))
- return;
-
early_fixup_exception(regs, trapnr);
}
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260828-b4-tdx_remove_early_ve_handler-7c1463cf0f63
Best regards,
--
Vishal Verma <vishal.l.verma@intel.com>
reply other threads:[~2026-11-02 22:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102-b4-tdx_remove_early_ve_handler-v2-1-71361d14f359@intel.com \
--to=vishal.l.verma@intel.com \
--cc=ak@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=nik.borisov@suse.com \
--cc=rick.p.edgecombe@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®