Background
==========
TDX guests have early_printk support, but it is through a roundabout way
using a #VE exception as a functional mechanism. The exception handler
has to use TDG.VP.VEINFO.GET to find out what faulted, and then issue
the TDVMCALL. Simplify this by using a TDVMCALL from the guest which can
directly perform the port I/O.
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: Add a new earlyprintk=tdx option (with sub-options to select
the serial port - same as earlyprintk=serial - tdx[,ttySN[,baud]]).
This calls new tdx_inb() / tdx_outb() helpers, which perform the port
I/O directly using TDVMCALLs.
The serial earlyprintk path is left as is - TD guests using this will
still take a #VE exception, and the exception handler will perform the
I/O.
Testing
=======
Added a counter for the number of COM1 port I/O #VEs handled:
no earlyprintk - ~63000
earlyprintk=ttyS0 - ~61000
earlyprintk=tdx - ~35000
The new tdx option nearly halves the number of #VEs handled.
Additionally, ran the usual suite of CI testing, which covers KVM self
tests, KVM unit tests, and Avocado KVM tests without any regressions.
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
Changes in v2:
- Rebase to v7.3-rc4
- Move the TDX hypercall helpers into coco/tdx/tdx.c (Kiryl)
- Add a new earlyprintk=tdx option that implements the direct TDVMCALL
path (Dave Hansen)
- Link to v1: https://patch.msgid.link/20260910-b4-tdx_earlyprintk_tdcalls-v1-0-4b2b1bf9001b@intel.com
---
Vishal Verma (2):
x86/tdx: Move port I/O definitions to a shared header
x86/early_printk: Add earlyprintk=tdx to drive the UART with TDVMCALLs
Documentation/admin-guide/kernel-parameters.txt | 9 +++++
arch/x86/include/asm/shared/tdx.h | 6 ++++
arch/x86/include/asm/tdx.h | 3 ++
arch/x86/boot/compressed/tdx.c | 4 +--
arch/x86/coco/tdx/tdx.c | 47 +++++++++++++++++++++----
arch/x86/kernel/early_printk.c | 37 +++++++++++++++++++
6 files changed, 98 insertions(+), 8 deletions(-)
---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260903-b4-tdx_earlyprintk_tdcalls-40d1b21a8ba2
Best regards,
--
Vishal Verma <vishal.l.verma@intel.com>