[PATCH 0/2] x86/tdx: Use TDVMCALLs directly for earlyprintk
From: Vishal Verma
Date: Thu Sep 10 2026 - 18:37:22 EST
Background
==========
TDX guests have early_printk support, but it is through a roundabout way
using a #VE exception as a functional mechanism, which is fragile. The
exception handler has to use TDG.VP.VEINFO.GET to find out what faulted,
and then issue the TDVMCALL. This can be simplified into a TDVMCALL from
the guest that does the I/O directly.
Patch details
=============
Patch 1 is a prep patch that moves the port I/O direction constants to
arch/x86/include/asm/shared/tdx.h.
Patch 2: early_printk.c already reaches the UART through static calls,
so a TDX guest can simply substitute accessors that issue
TDG.VP.VMCALL<Instruction.IO> directly.
Testing
=======
Measured using a TD guest by counting handle_io() calls and snapshotting
the counter at the last earlyprintk write.
COM1 #VE count: 63160 (before patch) -> 21 (with patch)
Additionally, ran the usual suite of CI testing, which covers KVM self
tests, KVM unit tests, and Avocado KVM tests without any regressions.
This is based on v7.3-rc2.
Signed-off-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
---
Vishal Verma (2):
x86/tdx: Move port I/O definitions to a shared header
x86/early_printk: Avoid #VE emulation for TDX guest serial output
arch/x86/include/asm/shared/tdx.h | 4 ++++
arch/x86/boot/compressed/tdx.c | 4 ++--
arch/x86/coco/tdx/tdx.c | 8 ++-----
arch/x86/kernel/early_printk.c | 48 +++++++++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+), 8 deletions(-)
---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260903-b4-tdx_earlyprintk_tdcalls-40d1b21a8ba2
Best regards,
--
Vishal Verma <vishal.l.verma@xxxxxxxxx>