Re: [PATCH v2 07/17] x86/virt/tdx: Initialize Quoting extension

From: Chao Gao

Date: Mon Jun 29 2026 - 04:37:26 EST


On Thu, Jun 18, 2026 at 04:13:45PM +0800, Xu Yilun wrote:
>From: Peter Fang <peter.fang@xxxxxxxxx>
>
>Initialize the Quoting extension during TDX bringup, after enabling TDX
>module Extension.

This jumps into what the patch does without explaining what the Quoting
extension is. A brief background would help reviewers who aren't familiar
with it.

>
>Because Quoting is an optional TDX feature, do not let initialization
>failures cause TDX bringup to fail. In that case, TDX can fall back to
>the existing userspace flow via a KVM return code.
>
>Only lay the groundwork for TDX Quoting support. Leave the opt-in
>portion of the initialization to a follow-up patch after fully
>implementing the feature.
>
>Signed-off-by: Peter Fang <peter.fang@xxxxxxxxx>
>Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
>---
> arch/x86/include/asm/tdx.h | 1 +
> arch/x86/virt/vmx/tdx/tdx.h | 1 +
> arch/x86/virt/vmx/tdx/tdx.c | 34 +++++++++++++++++++++++++++++++++-
> 3 files changed, 35 insertions(+), 1 deletion(-)
>
>diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
>index 5fbf89d5317c..741fd97cc199 100644
>--- a/arch/x86/include/asm/tdx.h
>+++ b/arch/x86/include/asm/tdx.h
>@@ -36,6 +36,7 @@
> #define TDX_FEATURES0_TD_PRESERVING BIT_ULL(1)
> #define TDX_FEATURES0_NO_RBP_MOD BIT_ULL(18)
> #define TDX_FEATURES0_EXT BIT_ULL(39)
>+#define TDX_FEATURES0_QUOTE BIT_ULL(50)
>
> #ifndef __ASSEMBLER__
>
>diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
>index 2deb0a5c902e..1afa0b10dfc9 100644
>--- a/arch/x86/virt/vmx/tdx/tdx.h
>+++ b/arch/x86/virt/vmx/tdx/tdx.h
>@@ -66,6 +66,7 @@
> #define TDH_EXT_INIT 60
> #define TDH_EXT_MEM_ADD 61
> #define TDH_SYS_DISABLE 69
>+#define TDH_QUOTE_INIT 100
>
> /* TDX page types */
> #define PT_NDA 0x0
>diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
>index 4d2940f4538a..06c42b86b05e 100644
>--- a/arch/x86/virt/vmx/tdx/tdx.c
>+++ b/arch/x86/virt/vmx/tdx/tdx.c
>@@ -1167,6 +1167,32 @@ static __init int init_tdmrs(struct tdmr_info_list *tdmr_list)
> return 0;
> }
>
>+/* Initialize quoting extension */

This comment isn't quite helpful.

>+static __init int tdx_quote_init(void)
>+{
>+ struct tdx_module_args args = {};
>+ u64 r;
>+
>+ do {
>+ r = seamcall(TDH_QUOTE_INIT, &args);
>+ } while (r == TDX_INTERRUPTED_RESUMABLE);
>+
>+ if (r != TDX_SUCCESS)
>+ return -EFAULT;
>+
>+ return 0;
>+}
>+
>+static __init void init_tdx_quoting_extension(void)
>+{
>+ int ret;
>+
>+ if (tdx_addon_feature0 & TDX_FEATURES0_QUOTE) {
>+ ret = tdx_quote_init();
>+ WARN_ON_ONCE(ret);
>+ }

nit: Reduce indentation of the main body.

if (!(tdx_addon_feature0 & TDX_FEATURES0_QUOTE))
return;

ret = tdx_quote_init();
WARN_ON_ONCE(ret);


Also, why two functions? Can we inline tdx_quote_init() here, or push the
feature check into it.

>+}
>+
> /* Initialize TDX module extensions for extension SEAMCALLs */
> static int tdx_ext_init(void)
> {
>@@ -1305,7 +1331,13 @@ static __init int init_tdx_module_extensions(void)
> if (ret)
> return ret;
>
>- return tdx_ext_init();
>+ ret = tdx_ext_init();
>+ if (ret)
>+ return ret;
>+
>+ init_tdx_quoting_extension();
>+
>+ return 0;
> }
>
> /*
>--
>2.25.1
>