Skip to content

KVM: nSVM: Fix issues when SMM is entered from L2

Vitaly Kuznetsov kvm lkml 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 10 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: nSVM: Check the value written to MSR_VM_HSAVE_PAarch/x86/kvm/svm/svm.c+4 -13 replies
2/6KVM: nSVM: Check that VM_HSAVE_PA MSR was set before VMRUNarch/x86/kvm/svm/nested.c+5 -01 reply
3/6KVM: nSVM: Introduce svm_copy_nonvmloadsave_state()arch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.h+23 -152 replies
4/6KVM: nSVM: Fix L1 state corruption upon return from SMMarch/x86/kvm/svm/svm.c+38 -11 reply
5/6KVM: nSVM: Restore nested control upon leaving SMMarch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+10 -31 reply
6/6KVM: selftests: smm_test: Test SMM enter from L2tools/testing/selftests/kvm/x86_64/smm_test.c+64 -61 reply

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchMaxim Levitsky
1/6R-b
2/6R-b
3/6
4/6R-b
5/6
6/6R-b

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/6] KVM: nSVM: Fix issues when SMM is entered from L2

This is a continuation of "[PATCH RFC] KVM: nSVM: Fix L1 state corruption upon return from SMM".

VMCB split commit 4995a3685f1b ("KVM: SVM: Use a separate vmcb for the nested L2 guest") broke return from SMM when we entered there from guest (L2) mode. Gen2 WS2016/Hyper-V is known to do this on boot. The problem appears to be that VMCB01 gets irreversibly destroyed during SMM execution. Previously, we used to have 'hsave' VMCB where regular (pre-SMM) L1's state was saved upon nested_svm_vmexit() but now we just switch to VMCB01 from VMCB02.

While writing a selftest for the issue, I've noticed that 'svm->nested.ctl' doesn't get restored after KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle when guest happens to be in SMM triggered from L2. "KVM: nSVM: Restore nested control upon leaving SMM" is aimed to fix that.

First two patches of the series add missing sanity checks for MSR_VM_HSAVE_PA which has to be page aligned and not zero.

Vitaly Kuznetsov (6):
KVM: nSVM: Check the value written to MSR_VM_HSAVE_PA
KVM: nSVM: Check that VM_HSAVE_PA MSR was set before VMRUN
KVM: nSVM: Introduce svm_copy_nonvmloadsave_state()
KVM: nSVM: Fix L1 state corruption upon return from SMM
KVM: nSVM: Restore nested control upon leaving SMM
KVM: selftests: smm_test: Test SMM enter from L2

 arch/x86/kvm/svm/nested.c                     | 45 +++++++-----
 arch/x86/kvm/svm/svm.c                        | 51 +++++++++++++-
 arch/x86/kvm/svm/svm.h                        |  4 ++
 tools/testing/selftests/kvm/x86_64/smm_test.c | 70 +++++++++++++++++--
 4 files changed, 144 insertions(+), 26 deletions(-)
Signature · 1 line
2.31.1