Skip to content

Commit 331282f

Browse files
committed
KVM: SVM: Drop 32-bit "support" from __svm_sev_es_vcpu_run()
Drop 32-bit "support" from __svm_sev_es_vcpu_run(), as SEV/SEV-ES firmly 64-bit only. The "support" was purely the result of bad copy+paste from __svm_vcpu_run(), which in turn was slightly less bad copy+paste from __vmx_vcpu_run(). Opportunistically convert to unadulterated register accesses so that it's easier (but still not easy) to follow which registers hold what arguments, and when. Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20240223204233.3337324-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 7774c8f commit 331282f

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

arch/x86/kvm/svm/vmenter.S

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -298,57 +298,44 @@ SYM_FUNC_END(__svm_vcpu_run)
298298
* @spec_ctrl_intercepted: bool
299299
*/
300300
SYM_FUNC_START(__svm_sev_es_vcpu_run)
301-
push %_ASM_BP
302-
#ifdef CONFIG_X86_64
301+
push %rbp
303302
push %r15
304303
push %r14
305304
push %r13
306305
push %r12
307-
#else
308-
push %edi
309-
push %esi
310-
#endif
311-
push %_ASM_BX
306+
push %rbx
312307

313308
/*
314309
* Save variables needed after vmexit on the stack, in inverse
315310
* order compared to when they are needed.
316311
*/
317312

318313
/* Accessed directly from the stack in RESTORE_HOST_SPEC_CTRL. */
319-
push %_ASM_ARG2
314+
push %rsi
320315

321316
/* Save @svm. */
322-
push %_ASM_ARG1
323-
324-
.ifnc _ASM_ARG1, _ASM_DI
325-
/*
326-
* Stash @svm in RDI early. On 32-bit, arguments are in RAX, RCX
327-
* and RDX which are clobbered by RESTORE_GUEST_SPEC_CTRL.
328-
*/
329-
mov %_ASM_ARG1, %_ASM_DI
330-
.endif
317+
push %rdi
331318

332319
/* Clobbers RAX, RCX, RDX. */
333320
RESTORE_GUEST_SPEC_CTRL
334321

335322
/* Get svm->current_vmcb->pa into RAX. */
336-
mov SVM_current_vmcb(%_ASM_DI), %_ASM_AX
337-
mov KVM_VMCB_pa(%_ASM_AX), %_ASM_AX
323+
mov SVM_current_vmcb(%rdi), %rax
324+
mov KVM_VMCB_pa(%rax), %rax
338325

339326
/* Enter guest mode */
340327
sti
341328

342-
1: vmrun %_ASM_AX
329+
1: vmrun %rax
343330

344331
2: cli
345332

346333
/* Pop @svm to RDI, guest registers have been saved already. */
347-
pop %_ASM_DI
334+
pop %rdi
348335

349336
#ifdef CONFIG_MITIGATION_RETPOLINE
350337
/* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */
351-
FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE
338+
FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE
352339
#endif
353340

354341
/* Clobbers RAX, RCX, RDX. */
@@ -364,26 +351,21 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run)
364351
UNTRAIN_RET_VM
365352

366353
/* "Pop" @spec_ctrl_intercepted. */
367-
pop %_ASM_BX
354+
pop %rbx
368355

369-
pop %_ASM_BX
356+
pop %rbx
370357

371-
#ifdef CONFIG_X86_64
372358
pop %r12
373359
pop %r13
374360
pop %r14
375361
pop %r15
376-
#else
377-
pop %esi
378-
pop %edi
379-
#endif
380-
pop %_ASM_BP
362+
pop %rbp
381363
RET
382364

383365
RESTORE_GUEST_SPEC_CTRL_BODY
384366
RESTORE_HOST_SPEC_CTRL_BODY
385367

386-
3: cmpb $0, _ASM_RIP(kvm_rebooting)
368+
3: cmpb $0, kvm_rebooting(%rip)
387369
jne 2b
388370
ud2
389371

0 commit comments

Comments
 (0)