Re: [PATCH v3 2/2] x86/early_printk: Add earlyprintk=tdx to drive the UART with TDVMCALLs
From: Verma, Vishal L
Date: Fri Oct 02 2026 - 15:34:50 EST
On Fri, 2026-10-02 at 15:59 +0100, Kiryl Shutsemau wrote:
>
>
> ANNOTATE_NOENDBR_SYM() is a top-level asm() that references the symbol.
> Once the compiler drops the wrapper, the annotation points at an
> undefined symbol and objtool flags it.
>
> __used makes it go away by keeping the dead wrappers in every non-TDX
> kernel, which is the opposite of what dropping the #ifdefs was for.
>
> Drop the wrappers instead.
>
> Let tdx.c provide the accessors with the serial_in/serial_out signature,
> __noendbr and annotated there, and declare them outside the #ifdef. No
> stubs are needed: the only reference is under cpu_feature_enabled(),
> which folds to zero without CONFIG_INTEL_TDX_GUEST.
>
> Builds with TDX on and off.
Hi Kiryl,
Thanks - that makes sense and the patch looks good. I think the
prototype declarations in asm/tdx.h (see below) also need __noendbr
annotations?
<snip>
> diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
> index 325dd7c5929f..0bbabcf0791e 100644
> --- a/arch/x86/include/asm/tdx.h
> +++ b/arch/x86/include/asm/tdx.h
> @@ -83,9 +83,6 @@ int tdx_mcall_extend_rtmr(u8 index, u8 *data);
>
> u64 tdx_hcall_get_quote(u8 *buf, size_t size);
>
> -u8 tdx_inb(u16 port);
> -void tdx_outb(u8 value, u16 port);
> -
> void __init tdx_dump_attributes(u64 td_attr);
> void __init tdx_dump_td_ctls(u64 td_ctls);
>
> @@ -98,6 +95,10 @@ static inline bool tdx_early_handle_ve(struct pt_regs *regs) { return false; }
>
> #endif /* CONFIG_INTEL_TDX_GUEST */
>
> +/* Only referenced when X86_FEATURE_TDX_GUEST is enabled, no stubs needed */
> +unsigned int tdx_serial_in(unsigned long addr, int offset);
> +void tdx_serial_out(unsigned long addr, int offset, int value);
> +
>
.. Should these also be:
+__noendbr unsigned int tdx_serial_in(unsigned long addr, int offset);
+__noendbr void tdx_serial_out(unsigned long addr, int offset, int value);