Re: [PATCH v2 2/2] x86/early_printk: Add earlyprintk=tdx to drive the UART with TDVMCALLs

From: Verma, Vishal L

Date: Tue Sep 22 2026 - 14:19:03 EST


On Mon, 2026-09-21 at 20:11 +0000, Verma, Vishal L wrote:
> On Mon, 2026-09-21 at 12:58 -0700, Dave Hansen wrote:
> > On 9/21/26 12:52, Vishal Verma wrote:
> > > + earlyprintk=tdx[,ttySn[,baudrate]]
> >
> > Isn't keeping support for ttySn and baudrate kinda silly? It costs a few
> > lines of code at least.
>
> I kept it because ultimately we call early_serial_init() to set the
> 'serial port' up - mainly select which address we want to use. The baud
> rate parsing tags along because that's just how the helper is set up.
>
> I think ttySN parsing can still be useful? The guest could be set up
> with multiple serial devices and someone could choose to redirect
> earlyprintk output to say ttyS1, and that would work.

Hi Dave,

As a thought exercise, I changed this to just use ttyS0 which is the
defined default, and that changes the setup hunks to look like below
(not thoroughly tested or anything yet). Would you prefer this instead?

---

@@ -196,6 +215,24 @@ static __init void early_serial_init(char *s)
early_serial_hw_init(divisor);
}

+#ifdef CONFIG_INTEL_TDX_GUEST
+/*
+ * "earlyprintk=tdx" takes no options. A TDX guest has no firmware tables to
+ * discover a UART from and the VMM presents COM1, so there is nothing for a
+ * port or a baud rate argument to usefully select. Leave early_serial_base at
+ * its default and use the same rate "earlyprintk=serial" would pick.
+ */
+static __init void early_serial_tdx_init(void)
+{
+ if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
+ static_call_update(serial_in, tdx_serial_in);
+ static_call_update(serial_out, tdx_serial_out);
+ }
+
+ early_serial_hw_init(BASE_BAUD / DEFAULT_BAUD);
+}
+#endif /* CONFIG_INTEL_TDX_GUEST */
+
static __noendbr void mem32_serial_out(unsigned long addr, int offset, int value)
{
u32 __iomem *vaddr = (u32 __iomem *)addr;
@@ -414,6 +451,13 @@ static int __init setup_early_printk(char *buf)
early_serial_init(buf + 4);
early_console_register(&early_serial_console, keep);
}
+#ifdef CONFIG_INTEL_TDX_GUEST
+ if (!strncmp(buf, "tdx", 3)) {
+ early_serial_tdx_init();
+ early_console_register(&early_serial_console, keep);
+ break;
+ }
+#endif
#ifdef CONFIG_PCI
if (!strncmp(buf, "pciserial", 9)) {
buf += 9; /* Keep from match the above "pciserial" */