[RFC PATCH 13/15] x86/tdx: Add __tdcall_saved() helper
From: Zhenzhong Duan
Date: Thu Sep 24 2026 - 00:14:53 EST
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.
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 */
--
2.52.0