Skip to content

KVM: SVM: Clean up VMRUN=>#VMEXIT assembly

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 svm, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/8KVM: SVM: Create a stack frame in __svm_vcpu_run() for unwindingarch/x86/kvm/svm/vmenter.S+1 -00 replies
2/8KVM: SVM: Wrap __svm_sev_es_vcpu_run() with #ifdef CONFIG_KVM_AMD_SEVarch/x86/kvm/svm/vmenter.S+2 -00 replies
3/8KVM: SVM: Drop 32-bit "support" from __svm_sev_es_vcpu_run()arch/x86/kvm/svm/vmenter.S+13 -310 replies
4/8KVM: SVM: Clobber RAX instead of RBX when discarding spec_ctrl_interceptedarch/x86/kvm/svm/vmenter.S+2 -20 replies
5/8KVM: SVM: Save/restore non-volatile GPRs in SEV-ES VMRUN via host save areaarch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h arch/x86/kvm/svm/vmenter.S+35 -260 replies
6/8KVM: SVM: Save/restore args across SEV-ES VMRUN via host save areaarch/x86/kvm/svm/vmenter.S+13 -160 replies
7/8KVM: SVM: Create a stack frame in __svm_sev_es_vcpu_run()arch/x86/kvm/svm/vmenter.S+4 -00 replies
8/8KVM: x86: Stop compiling vmenter.S with OBJECT_FILES_NON_STANDARDarch/x86/kvm/Makefile+0 -40 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchTom Lendacky
SeriesR-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/8] KVM: SVM: Clean up VMRUN=>#VMEXIT assembly

Clean up SVM's enter/exit assembly code so that it can be compiled without OBJECT_FILES_NON_STANDARD. The "standard" __svm_vcpu_run() can't be made 100% bulletproof, as RBP isn't restored on #VMEXIT, but that's also the case for __vmx_vcpu_run(), and getting "close enough" is better than not even trying.

As for SEV-ES, after yet another refresher on swap types, I realized KVM can simply let the hardware restore registers after #VMEXIT, all that's missing is storing the current values to the host save area (I learned the hard way that they are swap Type B, *sigh*). Unless I'm missing something, this provides 100% accuracy when using stack frames for unwinding, and requires less assembly (though probably not fewer code bytes; I didn't check).

In between, build the SEV-ES code iff CONFIG_KVM_AMD_SEV=y, and yank out "support" for 32-bit kernels, which was unncessarily polluting the code.

I'm pretty sure I actually managed to test all of this, thanks to the SEV-ES smoke selftests, and a bit of hacking to disable V_SPEC_CTRL, passthrough SPEC_CTRL unconditionally, and have the selftests W/R SPEC_CTRL from its guest.

Sean Christopherson (8):
KVM: SVM: Create a stack frame in __svm_vcpu_run() for unwinding
KVM: SVM: Wrap __svm_sev_es_vcpu_run() with #ifdef CONFIG_KVM_AMD_SEV
KVM: SVM: Drop 32-bit "support" from __svm_sev_es_vcpu_run()
KVM: SVM: Clobber RAX instead of RBX when discarding
spec_ctrl_intercepted
KVM: SVM: Save/restore non-volatile GPRs in SEV-ES VMRUN via host save
area
KVM: SVM: Save/restore args across SEV-ES VMRUN via host save area
KVM: SVM: Create a stack frame in __svm_sev_es_vcpu_run()
KVM: x86: Stop compiling vmenter.S with OBJECT_FILES_NON_STANDARD

 arch/x86/kvm/Makefile      |  4 --
 arch/x86/kvm/svm/svm.c     | 17 ++++---
 arch/x86/kvm/svm/svm.h     |  3 +-
 arch/x86/kvm/svm/vmenter.S | 97 +++++++++++++++++---------------------
 4 files changed, 56 insertions(+), 65 deletions(-)

base-commit: ec1e3d33557babed2c2c2c7da6e84293c2f56f58

Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog