Re: [RFC PATCH 13/15] x86/tdx: Add __tdcall_saved() helper
From: Xiaoyao Li
Date: Mon Oct 26 2026 - 03:36:13 EST
On 9/24/2026 12:10 PM, Zhenzhong Duan wrote:
> The TDX Connect ABI defines TDCALL leaves that use registers up to r15
> in struct tdx_module_args as input, without returning output arguments.
>
> Add __tdcall_saved() for these leaves.
It's used by TDG.DMAR.ACCEPT in the next patch. And we need it because
TDG.DMAR.ACCEPT explicitly states that R8-R15 is reserved and must be 0.
It seems the first one having such requirement. Is it really necessary to keep
R8-R15 to be 0 for TDG.DMAR.ACCEPT? Can we ask the internal arch to see if
possible to fix the doc?
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxx>
> ---
> arch/x86/coco/tdx/tdcall.S | 17 +++++++++++++++++
> arch/x86/include/asm/shared/tdx.h | 1 +
> 2 files changed, 18 insertions(+)
>
> diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S
> index 52d9786da308..1dca01909dee 100644
> --- a/arch/x86/coco/tdx/tdcall.S
> +++ b/arch/x86/coco/tdx/tdcall.S
> @@ -44,6 +44,23 @@ SYM_FUNC_START(__tdcall_ret)
> TDX_MODULE_CALL host=0 ret=1
> SYM_FUNC_END(__tdcall_ret)
>
> +/*
> + * __tdcall_saved() - Used by TDX guests to request services from the TDX
> + * module (does not include VMM services) using TDCALL instruction.
> + *
> + * __tdcall_saved() function ABI:
> + *
> + * @fn (RDI) - TDCALL Leaf ID, moved to RAX
> + * @args (RSI) - struct tdx_module_args for input
> + *
> + * All registers in @args are used as input registers.
> + *
> + * Return status of TDCALL via RAX.
> + */
> +SYM_FUNC_START(__tdcall_saved)
> + TDX_MODULE_CALL host=0 saved=1
> +SYM_FUNC_END(__tdcall_saved)
> +
> /*
> * __tdcall_saved_ret() - Used by TDX guests to request services from the
> * TDX module (including VMM services) using TDCALL instruction, with
> diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h
> index 72520f09ef3f..90f2842f4253 100644
> --- a/arch/x86/include/asm/shared/tdx.h
> +++ b/arch/x86/include/asm/shared/tdx.h
> @@ -153,6 +153,7 @@ struct tdx_module_args {
> /* Used to communicate with the TDX module */
> u64 __tdcall(u64 fn, struct tdx_module_args *args);
> u64 __tdcall_ret(u64 fn, struct tdx_module_args *args);
> +u64 __tdcall_saved(u64 fn, struct tdx_module_args *args);
> u64 __tdcall_saved_ret(u64 fn, struct tdx_module_args *args);
>
> /* Used to request services from the VMM */