From: Kiryl Shutsemau <kas@kernel.org>
To: Vishal Verma <vishal.l.verma@intel.com>
Cc: x86@kernel.org, Dave Hansen <dave.hansen@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev,
kvm@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 2/2] x86/early_printk: Add earlyprintk=tdx to drive the UART with TDVMCALLs
Date: Fri, 25 Sep 2026 12:30:45 +0100 [thread overview]
Message-ID: <arZbBqArD9NqWPry@thinkstation> (raw)
In-Reply-To: <20260922-b4-tdx_earlyprintk_tdcalls-v3-2-6ebaa599df10@intel.com>
On Tue, Sep 22, 2026 at 02:20:07PM -0600, Vishal Verma wrote:
> @@ -111,6 +112,23 @@ ANNOTATE_NOENDBR_SYM(io_serial_out);
> DEFINE_STATIC_CALL(serial_in, io_serial_in);
> DEFINE_STATIC_CALL(serial_out, io_serial_out);
>
> +#ifdef CONFIG_INTEL_TDX_GUEST
> +/*
> + * A TDX guest cannot execute port I/O instructions, so ask the VMM to do it.
> + */
> +static __noendbr unsigned int tdx_serial_in(unsigned long addr, int offset)
> +{
> + return tdx_inb(addr + offset);
> +}
> +ANNOTATE_NOENDBR_SYM(tdx_serial_in);
> +
> +static __noendbr void tdx_serial_out(unsigned long addr, int offset, int value)
> +{
> + tdx_outb(value, addr + offset);
> +}
> +ANNOTATE_NOENDBR_SYM(tdx_serial_out);
> +#endif /* CONFIG_INTEL_TDX_GUEST */
> +
> static int early_serial_putc(unsigned char ch)
> {
> unsigned timeout = 0xffff;
> @@ -196,6 +214,22 @@ static __init void early_serial_init(char *s)
> early_serial_hw_init(divisor);
> }
>
> +#ifdef CONFIG_INTEL_TDX_GUEST
> +/*
> + * Use early_serial_base (COM1) and same default baud rate as
> + * "earlyprintk=serial"
> + */
> +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(115200 / 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 +448,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
All these #ifdefs in early_printk.c can go. X86_FEATURE_TDX_GUEST is a
disabled feature without CONFIG_INTEL_TDX_GUEST, so
cpu_feature_enabled() folds to zero and the compiler drops the
static_call_update() calls and the wrappers with them.
Add stubs for tdx_inb() and tdx_outb() to the #else branch in
<asm/tdx.h> and make the "tdx" case unconditional.
--
Kiryl Shutsemau / Kirill A. Shutemov
prev parent reply other threads:[~2026-09-25 11:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:20 [PATCH v3 0/2] x86/tdx: Use TDVMCALLs directly for earlyprintk Vishal Verma
2026-09-22 20:20 ` [PATCH v3 1/2] x86/tdx: Move port I/O definitions to a shared header Vishal Verma
2026-09-22 20:20 ` [PATCH v3 2/2] x86/early_printk: Add earlyprintk=tdx to drive the UART with TDVMCALLs Vishal Verma
2026-09-25 11:30 ` Kiryl Shutsemau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arZbBqArD9NqWPry@thinkstation \
--to=kas@kernel.org \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=skhan@linuxfoundation.org \
--cc=vishal.l.verma@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®