|
1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | 2 | #include <asm/asm-offsets.h> |
3 | 3 | #include <asm/asm.h> |
4 | | -#include <asm/frame.h> |
5 | 4 |
|
6 | 5 | #include <linux/linkage.h> |
7 | 6 | #include <linux/errno.h> |
@@ -46,135 +45,19 @@ SYM_FUNC_START(__tdcall_ret) |
46 | 45 | SYM_FUNC_END(__tdcall_ret) |
47 | 46 |
|
48 | 47 | /* |
49 | | - * TDX_HYPERCALL - Make hypercalls to a TDX VMM using TDVMCALL leaf of TDCALL |
50 | | - * instruction |
51 | | - * |
52 | | - * Transforms values in function call argument struct tdx_module_args @args |
53 | | - * into the TDCALL register ABI. After TDCALL operation, VMM output is saved |
54 | | - * back in @args, if \ret is 1. |
55 | | - * |
56 | | - * Depends on the caller to pass TDG.VP.VMCALL as the TDCALL leaf, and set |
57 | | - * @args::rcx to TDVMCALL_EXPOSE_REGS_MASK. |
58 | | - * |
59 | | - *------------------------------------------------------------------------- |
60 | | - * TD VMCALL ABI: |
61 | | - *------------------------------------------------------------------------- |
62 | | - * |
63 | | - * Input Registers: |
64 | | - * |
65 | | - * RAX - TDCALL instruction leaf number (0 - TDG.VP.VMCALL) |
66 | | - * RCX - BITMAP which controls which part of TD Guest GPR |
67 | | - * is passed as-is to the VMM and back. |
68 | | - * R10 - Set 0 to indicate TDCALL follows standard TDX ABI |
69 | | - * specification. Non zero value indicates vendor |
70 | | - * specific ABI. |
71 | | - * R11 - VMCALL sub function number |
72 | | - * RBX, RDX, RDI, RSI - Used to pass VMCALL sub function specific arguments. |
73 | | - * R8-R9, R12-R15 - Same as above. |
74 | | - * |
75 | | - * Output Registers: |
76 | | - * |
77 | | - * RAX - TDCALL instruction status (Not related to hypercall |
78 | | - * output). |
79 | | - * RBX, RDX, RDI, RSI - Hypercall sub function specific output values. |
80 | | - * R8-R15 - Same as above. |
81 | | - * |
82 | | - */ |
83 | | -.macro TDX_HYPERCALL |
84 | | - FRAME_BEGIN |
85 | | - |
86 | | - /* Save callee-saved GPRs as mandated by the x86_64 ABI */ |
87 | | - push %r15 |
88 | | - push %r14 |
89 | | - push %r13 |
90 | | - push %r12 |
91 | | - push %rbx |
92 | | - |
93 | | - /* Move Leaf ID to RAX */ |
94 | | - movq %rdi, %rax |
95 | | - |
96 | | - /* Move bitmap of shared registers to RCX */ |
97 | | - movq TDX_MODULE_rcx(%rsi), %rcx |
98 | | - |
99 | | - /* Copy hypercall registers from arg struct: */ |
100 | | - movq TDX_MODULE_r8(%rsi), %r8 |
101 | | - movq TDX_MODULE_r9(%rsi), %r9 |
102 | | - movq TDX_MODULE_r10(%rsi), %r10 |
103 | | - movq TDX_MODULE_r11(%rsi), %r11 |
104 | | - movq TDX_MODULE_r12(%rsi), %r12 |
105 | | - movq TDX_MODULE_r13(%rsi), %r13 |
106 | | - movq TDX_MODULE_r14(%rsi), %r14 |
107 | | - movq TDX_MODULE_r15(%rsi), %r15 |
108 | | - movq TDX_MODULE_rdi(%rsi), %rdi |
109 | | - movq TDX_MODULE_rbx(%rsi), %rbx |
110 | | - movq TDX_MODULE_rdx(%rsi), %rdx |
111 | | - |
112 | | - pushq %rsi |
113 | | - movq TDX_MODULE_rsi(%rsi), %rsi |
114 | | - |
115 | | - tdcall |
116 | | - |
117 | | - /* |
118 | | - * Restore the pointer of the structure to save output registers. |
119 | | - * |
120 | | - * RCX is used as bitmap of shared registers and doesn't hold any |
121 | | - * value provided by the VMM, thus it can be used as spare to |
122 | | - * restore the structure pointer. |
123 | | - */ |
124 | | - popq %rcx |
125 | | - movq %rsi, TDX_MODULE_rsi(%rcx) |
126 | | - movq %rcx, %rsi |
127 | | - |
128 | | - movq %r8, TDX_MODULE_r8(%rsi) |
129 | | - movq %r9, TDX_MODULE_r9(%rsi) |
130 | | - movq %r10, TDX_MODULE_r10(%rsi) |
131 | | - movq %r11, TDX_MODULE_r11(%rsi) |
132 | | - movq %r12, TDX_MODULE_r12(%rsi) |
133 | | - movq %r13, TDX_MODULE_r13(%rsi) |
134 | | - movq %r14, TDX_MODULE_r14(%rsi) |
135 | | - movq %r15, TDX_MODULE_r15(%rsi) |
136 | | - movq %rdi, TDX_MODULE_rdi(%rsi) |
137 | | - movq %rbx, TDX_MODULE_rbx(%rsi) |
138 | | - movq %rdx, TDX_MODULE_rdx(%rsi) |
139 | | - |
140 | | - /* |
141 | | - * Zero out registers exposed to the VMM to avoid speculative execution |
142 | | - * with VMM-controlled values. This needs to include all registers |
143 | | - * present in TDVMCALL_EXPOSE_REGS_MASK, except RBX, and R12-R15 which |
144 | | - * will be restored. |
145 | | - */ |
146 | | - xor %r8d, %r8d |
147 | | - xor %r9d, %r9d |
148 | | - xor %r10d, %r10d |
149 | | - xor %r11d, %r11d |
150 | | - xor %rdi, %rdi |
151 | | - xor %rsi, %rsi |
152 | | - xor %rdx, %rdx |
153 | | - |
154 | | - /* Restore callee-saved GPRs as mandated by the x86_64 ABI */ |
155 | | - pop %rbx |
156 | | - pop %r12 |
157 | | - pop %r13 |
158 | | - pop %r14 |
159 | | - pop %r15 |
160 | | - |
161 | | - FRAME_END |
162 | | - |
163 | | - RET |
164 | | -.endm |
165 | | - |
166 | | -/* |
| 48 | + * __tdcall_saved_ret() - Used by TDX guests to request services from the |
| 49 | + * TDX module (including VMM services) using TDCALL instruction, with |
| 50 | + * saving output registers to the 'struct tdx_module_args' used as input. |
167 | 51 | * |
168 | | - * __tdcall_hypercall() function ABI: |
| 52 | + * __tdcall_saved_ret() function ABI: |
169 | 53 | * |
170 | 54 | * @fn (RDI) - TDCALL leaf ID, moved to RAX |
171 | 55 | * @args (RSI) - struct tdx_module_args for input/output |
172 | 56 | * |
173 | | - * @fn and @args::rcx from the caller must be TDG_VP_VMCALL and |
174 | | - * TDVMCALL_EXPOSE_REGS_MASK respectively. |
| 57 | + * All registers in @args are used as input/output registers. |
175 | 58 | * |
176 | 59 | * On successful completion, return the hypercall error code. |
177 | 60 | */ |
178 | | -SYM_FUNC_START(__tdcall_hypercall) |
179 | | - TDX_HYPERCALL |
180 | | -SYM_FUNC_END(__tdcall_hypercall) |
| 61 | +SYM_FUNC_START(__tdcall_saved_ret) |
| 62 | + TDX_MODULE_CALL host=0 ret=1 saved=1 |
| 63 | +SYM_FUNC_END(__tdcall_saved_ret) |
0 commit comments