@@ -85,12 +85,12 @@ SYM_FUNC_START(__tdx_module_call)
8585SYM_FUNC_END(__tdx_module_call)
8686
8787/*
88- * __tdx_hypercall() - Make hypercalls to a TDX VMM using TDVMCALL leaf
89- * of TDCALL instruction
88+ * TDX_HYPERCALL - Make hypercalls to a TDX VMM using TDVMCALL leaf of TDCALL
89+ * instruction
9090 *
9191 * Transforms values in function call argument struct tdx_hypercall_args @args
9292 * into the TDCALL register ABI. After TDCALL operation, VMM output is saved
93- * back in @args.
93+ * back in @args, if \ret is 1 .
9494 *
9595 *-------------------------------------------------------------------------
9696 * TD VMCALL ABI:
@@ -105,26 +105,18 @@ SYM_FUNC_END(__tdx_module_call)
105105 * specification. Non zero value indicates vendor
106106 * specific ABI.
107107 * R11 - VMCALL sub function number
108- * RBX, RBP , RDI, RSI - Used to pass VMCALL sub function specific arguments.
108+ * RBX, RDX , RDI, RSI - Used to pass VMCALL sub function specific arguments.
109109 * R8-R9, R12-R15 - Same as above.
110110 *
111111 * Output Registers:
112112 *
113113 * RAX - TDCALL instruction status (Not related to hypercall
114114 * output).
115- * R10 - Hypercall output error code .
116- * R11 -R15 - Hypercall sub function specific output values .
115+ * RBX, RDX, RDI, RSI - Hypercall sub function specific output values .
116+ * R8 -R15 - Same as above .
117117 *
118- *-------------------------------------------------------------------------
119- *
120- * __tdx_hypercall() function ABI:
121- *
122- * @args (RDI) - struct tdx_hypercall_args for input and output
123- * @flags (RSI) - TDX_HCALL_* flags
124- *
125- * On successful completion, return the hypercall error code.
126118 */
127- SYM_FUNC_START(__tdx_hypercall)
119+ .macro TDX_HYPERCALL ret: req
128120 FRAME_BEGIN
129121
130122 /* Save callee-saved GPRs as mandated by the x86_64 ABI */
@@ -134,9 +126,8 @@ SYM_FUNC_START(__tdx_hypercall)
134126 push %r12
135127 push %rbx
136128
137- /* Free RDI and RSI to be used as TDVMCALL arguments */
129+ /* Free RDI to be used as TDVMCALL arguments */
138130 movq %rdi , %rax
139- push %rsi
140131
141132 /* Copy hypercall registers from arg struct: */
142133 movq TDX_HYPERCALL_r8(%rax ), %r8
@@ -171,14 +162,11 @@ SYM_FUNC_START(__tdx_hypercall)
171162 * and are handled by callers.
172163 */
173164 testq %rax , %rax
174- jne .Lpanic
165+ jne .Lpanic\@
175166
176167 pop %rax
177168
178- /* Copy hypercall result registers to arg struct if needed */
179- testq $TDX_HCALL_HAS_OUTPUT, (%rsp )
180- jz .Lout
181-
169+ .if \ret
182170 movq %r8 , TDX_HYPERCALL_r8(%rax )
183171 movq %r9 , TDX_HYPERCALL_r9(%rax )
184172 movq %r10 , TDX_HYPERCALL_r10(%rax )
@@ -191,7 +179,8 @@ SYM_FUNC_START(__tdx_hypercall)
191179 movq %rsi , TDX_HYPERCALL_rsi(%rax )
192180 movq %rbx , TDX_HYPERCALL_rbx(%rax )
193181 movq %rdx , TDX_HYPERCALL_rdx(%rax )
194- .Lout:
182+ .endif
183+
195184 /* TDVMCALL leaf return code is in R10 */
196185 movq %r10 , %rax
197186
@@ -208,9 +197,6 @@ SYM_FUNC_START(__tdx_hypercall)
208197 xor %rdi , %rdi
209198 xor %rdx , %rdx
210199
211- /* Remove TDX_HCALL_* flags from the stack */
212- pop %rsi
213-
214200 /* Restore callee-saved GPRs as mandated by the x86_64 ABI */
215201 pop %rbx
216202 pop %r12
@@ -221,9 +207,33 @@ SYM_FUNC_START(__tdx_hypercall)
221207 FRAME_END
222208
223209 RET
224- .Lpanic:
210+ .Lpanic\@ :
225211 call __tdx_hypercall_failed
226212 /* __tdx_hypercall_failed never returns */
227213 REACHABLE
228- jmp .Lpanic
214+ jmp .Lpanic\@
215+ .endm
216+
217+ /*
218+ *
219+ * __tdx_hypercall() function ABI:
220+ *
221+ * @args (RDI) - struct tdx_hypercall_args for input
222+ *
223+ * On successful completion, return the hypercall error code.
224+ */
225+ SYM_FUNC_START(__tdx_hypercall)
226+ TDX_HYPERCALL ret =0
229227SYM_FUNC_END(__tdx_hypercall)
228+
229+ /*
230+ *
231+ * __tdx_hypercall_ret() function ABI:
232+ *
233+ * @args (RDI) - struct tdx_hypercall_args for input and output
234+ *
235+ * On successful completion, return the hypercall error code.
236+ */
237+ SYM_FUNC_START(__tdx_hypercall_ret)
238+ TDX_HYPERCALL ret =1
239+ SYM_FUNC_END(__tdx_hypercall_ret)
0 commit comments