Re: [PATCH 2/2] x86/early_printk: Avoid #VE emulation for TDX guest serial output
From: Dave Hansen
Date: Fri Sep 11 2026 - 16:39:09 EST
On 9/10/26 15:34, Vishal Verma wrote:
> +/* Substitute the hypercall accessors, but only in an actual TDX guest */
> +static __init void early_serial_tdx_init(void)
> +{
> + if (!cpu_feature_enabled(X86_FEATURE_TDX_GUEST))
> + return;
> +
> + static_call_update(serial_in, tdx_serial_in);
> + static_call_update(serial_out, tdx_serial_out);
> +}
> +#else
> +static inline void early_serial_tdx_init(void) { }
> +#endif /* CONFIG_INTEL_TDX_GUEST */
> +
> static int early_serial_putc(unsigned char ch)
> {
> unsigned timeout = 0xffff;
> @@ -160,6 +204,9 @@ static __init void early_serial_init(char *s)
> unsigned long baud = DEFAULT_BAUD;
> char *e;
>
> + /* Must be before early_serial_hw_init(), which does port I/O */
> + early_serial_tdx_init();
I really don't like the idea of putting any code in here. How about just
adding a case to setup_early_printk(). Perhaps:
#ifdef CONFIG_TDX_GUEST
if (!strncmp(buf, "tdx", 3)) {
early_serial_tdx_init();
early_serial_init(buf + 3);
early_console_register(&early_serial_console, keep);
}
#endif
Then folks can just use earlyprintk=tdx.