From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796237625; b=xpzLZMcR7sHRXZsUAgqaw2bPDePXS5UrpzD5zGXS7R5joncjUfiHlvA9mQ/gcVphxtML 9vSor3JIR4N/mf71lA1tPIMHR1G1Ah6ur0lQdv2IQtA8hsUSBpYocLnxt1rystDaAVY46 QhcT1HGRqiczTkJsHAm8zzNdeNRGviQpYY12oxrg8/elmCclEB+9DwxsM9hmlteneiwcV 8aJZyGwsjq3/Mwl6ElWDfHhqKSb+nzbdRSvXGDCxZeNKTT7/jaZXFwdN4n3M7q5EGiXVV c+gfWLEYJeFsvplN/WUh/90smr8cSqKSC6qkEtIAdqEJH9n5HloKSai5B7+5gxXg0/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237625; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature: X-Developer-Key; bh=w35jCRlhRLLvHg58p8rFyCGw2hlF86JawSdZUY4ueM4=; b=Os8/ao4yGvwicGHCQrCQfGAxAHm4GeepPWk4poIQKqPS+TnMcHQqLrxQFs9QBHFkUp7d HlVYqUR+w6cDgbryE0/9dYVnoSbxb2SS+VnXHQsEEE+OWTyhLYandTrz+nT/wm2fAHNoe PjBnddzMiQWmnP2nI0SYii1EpsJSbBKx1LWm6OC6nSb/arpNF402Ipj5kZSh5kkaE86oN o2gPwdBdCypenkJyD2JouU272lzrDkdwQWbhanHHMStwakTZrhavx6NHeSCgrRVDg9erU 4gvV8JHxFJ2LWggGcUzvV2bBh8b6w7ZPu4kJQCfQ0lD6Ibv/77UA2maeKqki6JJs9kA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=etMLyHs3; arc=none smtp.remote-ip=192.198.163.14 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA9F7606A33F; Wed, 2 Dec 2026 18:53:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CA9F7606A33F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=etMLyHs3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796237623; x=1827773623; h=from:date:subject:mime-version:content-transfer-encoding: message-id:to:cc; bh=w35jCRlhRLLvHg58p8rFyCGw2hlF86JawSdZUY4ueM4=; b=etMLyHs3Swk23lcmFAMlYUzHzfhkoJ8ELBxAbKvUodBAMv8hcho62OGs Zbkdud4KZkYET8q6bPvMwajbUFzssGIIvFIrVEGnySMPxaGi9mbMYMyA5 mQXIBcRAxesfXwhHEa8CkmshiQqXjNQHPtq+3CgnqKgoH/ZVthq9ttHqo CGFNsMJuimLjC03uS79HM19q/A13r+RgSK9bnQn0MVotBXQQHzl9Cvycv EBYo4be4foOmeDxeE//RUnXH3hvyhpuNhBC11uTq6p3KtDfsuUPcHSp0Q Dk6XCpQTHEJmD6xgM7lm9MEmbaAKXyr+3K4e+JKYwQbVfa8lgtPGM/06T w==; X-CSE-ConnectionGUID: c4KDNYwPT+CehhPSSYfecg== X-CSE-MsgGUID: YiMm1ofHR9+BYmilQkGwPg== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5139524" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5139524" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:53:43 -0800 X-CSE-ConnectionGUID: jibrixlSQheoWEddUeOLOw== X-CSE-MsgGUID: mCxWmjMcTM6y6eFhRxRQyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13701849" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.125.108.47]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:53:42 -0800 From: Vishal Verma Date: Wed, 02 Dec 2026 11:53:34 -0700 Subject: [PATCH v3] x86/tdx: Remove the early #VE handler X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-b4-tdx_remove_early_ve_handler-v3-1-54c340e251a7@intel.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/4WOzQrCMBAGX0VyNpJN0lQ9+R4ipU02GumPJDW0l L67aQvizdsOfMzsRAJ6h4GcdxPxGF1wXZtA7HdEP8r2jtSZxIQzrtiRH2klaW+GwmPTRSyw9PV YpCNtTY2e5hqkEtoyqwRJkpdH64Y1cL1tHN7VE3W/WJfFw4W+8+P6QYRlt8VOwP7FIlCglZV5K Y1QTGcX1/ZYH3TXkCUW+VcHwPhfHU+6HIQCA9KK7PSrm+f5A7/JxZUtAQAA X-Change-ID: 20260828-b4-tdx_remove_early_ve_handler-7c1463cf0f63 To: x86@kernel.org, Dave Hansen , Rick Edgecombe , Kiryl Shutsemau Cc: linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, Vishal Verma , Nikolay Borisov , Andi Kleen X-Mailer: b4 0.17-dev-e5168 X-Developer-Signature: v=1; a=openpgp-sha256; l=4319; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=f1m7Ahr3xFX1hMojKvFGIjKqwjnQXycNhNhmlG/1f+Y=; b=owGbwMvMwCXGf25diOft7jLG02pJDNkCmfpXln6ceOzE7OqJrEv1Pqa+vOF8dMKp4uuzukMv2 fZlrreX6ShlYRDjYpAVU2T5u+cj4zG57fk8gQmOMHNYmUCGMHBxCsBENhky/I+Z3vD3/J31Gunx kxby/Zr54vqhkOwfCk9by3Mu++wTCbdnZPi5rlJLXCCv5uaTu3+1Ulus5jBWHJVki9jiMie4V6p KhAkA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF 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 Reviewed-by: Rick Edgecombe Reviewed-by: Kiryl Shutsemau (Meta) Reviewed-by: Nikolay Borisov Cc: Andi Kleen Cc: Rick Edgecombe --- Changes in v3: - Mostly a resend - rebase to v7.4-rc5, and verify it applies to tip/master - Link to v2: https://patch.msgid.link/20261102-b4-tdx_remove_early_ve_handler-v2-1-71361d14f359@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 --- Dave, I assume this will go through you - it has review tags and should be ready for you unless of course you have any comments. --- 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: fe6ff8d5d675c01793b9f051d16055dd4aa75244 change-id: 20260828-b4-tdx_remove_early_ve_handler-7c1463cf0f63 Best regards, -- Vishal Verma