Skip to content

Commit 1e70c68

Browse files
kirylhansendc
authored andcommitted
x86/tdx: Do not corrupt frame-pointer in __tdx_hypercall()
If compiled with CONFIG_FRAME_POINTER=y, objtool is not happy that __tdx_hypercall() messes up RBP: objtool: __tdx_hypercall+0x7f: return with modified stack frame Rework the function to store TDX_HCALL_ flags on stack instead of RBP. [ dhansen: minor changelog tweaks ] Fixes: c30c4b2 ("x86/tdx: Refactor __tdx_hypercall() to allow pass down more arguments") Reported-by: kernel test robot <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/all/20230130135354.27674-1-kirill.shutemov%40linux.intel.com
1 parent 8de62af commit 1e70c68

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/x86/coco/tdx/tdcall.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ SYM_FUNC_START(__tdx_hypercall)
131131
push %r13
132132
push %r12
133133
push %rbx
134-
push %rbp
135134

136135
/* Free RDI and RSI to be used as TDVMCALL arguments */
137136
movq %rdi, %rax
138-
movq %rsi, %rbp
137+
push %rsi
139138

140139
/* Copy hypercall registers from arg struct: */
141140
movq TDX_HYPERCALL_r8(%rax), %r8
@@ -168,7 +167,7 @@ SYM_FUNC_START(__tdx_hypercall)
168167
* HLT operation indefinitely. Since this is the not the desired
169168
* result, conditionally call STI before TDCALL.
170169
*/
171-
testq $TDX_HCALL_ISSUE_STI, %rbp
170+
testq $TDX_HCALL_ISSUE_STI, 8(%rsp)
172171
jz .Lskip_sti
173172
sti
174173
.Lskip_sti:
@@ -188,7 +187,7 @@ SYM_FUNC_START(__tdx_hypercall)
188187
pop %rax
189188

190189
/* Copy hypercall result registers to arg struct if needed */
191-
testq $TDX_HCALL_HAS_OUTPUT, %rbp
190+
testq $TDX_HCALL_HAS_OUTPUT, (%rsp)
192191
jz .Lout
193192

194193
movq %r8, TDX_HYPERCALL_r8(%rax)
@@ -218,11 +217,12 @@ SYM_FUNC_START(__tdx_hypercall)
218217
xor %r10d, %r10d
219218
xor %r11d, %r11d
220219
xor %rdi, %rdi
221-
xor %rsi, %rsi
222220
xor %rdx, %rdx
223221

222+
/* Remove TDX_HCALL_* flags from the stack */
223+
pop %rsi
224+
224225
/* Restore callee-saved GPRs as mandated by the x86_64 ABI */
225-
pop %rbp
226226
pop %rbx
227227
pop %r12
228228
pop %r13

0 commit comments

Comments
 (0)