Skip to content

KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

Sean Christopherson 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 17 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: VMX: Drop guest CPUID check for VMXE in vmx_set_cr4()arch/x86/kvm/vmx/vmx.c+3 -20 replies
2/6KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4()arch/x86/kvm/vmx/vmx.c+7 -120 replies
3/6KVM: SVM: Drop VMXE check from svm_set_cr4()arch/x86/kvm/svm/svm.c+0 -30 replies
4/6KVM: x86: Move vendor CR4 validity check to dedicated kvm_x86_ops hookarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h +4 more+34 -210 replies
5/6KVM: x86: Return bool instead of int for CR4 and SREGS validity checksarch/x86/kvm/svm/nested.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c +1 more+15 -190 replies
6/6KVM: selftests: Verify supported CR4 bits can be set before KVM_SET_CPUID2tools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/include/x86_64/vmx.h tools/testing/selftests/kvm/x86_64/set_sregs_test.c+108 -50 replies

Reviews trailers per patch

None of the 6 patches has a Reviewed-by or Acked-by.

PatchStas Sergeev
SeriesT-b
1/6
2/6
3/6
4/6
5/6
6/6

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: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2.

The overarching issue is that kvm_x86_ops.set_cr4() can fail, but its invocation from __set_sregs(), a.k.a. KVM_SET_SREGS, ignores the result. Fix the issue by moving all validity checks out of .set_cr4() in one way or another.

I intentionally omitted a Cc to stable. The first bug fix in particular may break stable trees as it simply removes a check, and I don't know that stable trees have the generic CR4 reserved bit check that is needed to prevent the guest from setting VMXE when nVMX is not allowed.

Sean Christopherson (6):
KVM: VMX: Drop guest CPUID check for VMXE in vmx_set_cr4()
KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4()
KVM: SVM: Drop VMXE check from svm_set_cr4()
KVM: x86: Move vendor CR4 validity check to dedicated kvm_x86_ops hook
KVM: x86: Return bool instead of int for CR4 and SREGS validity checks
KVM: selftests: Verify supported CR4 bits can be set before
KVM_SET_CPUID2

 arch/x86/include/asm/kvm_host.h               |  3 +-
 arch/x86/kvm/svm/nested.c                     |  2 +-
 arch/x86/kvm/svm/svm.c                        | 12 ++-
 arch/x86/kvm/svm/svm.h                        |  2 +-
 arch/x86/kvm/vmx/nested.c                     |  2 +-
 arch/x86/kvm/vmx/vmx.c                        | 35 +++----
 arch/x86/kvm/vmx/vmx.h                        |  2 +-
 arch/x86/kvm/x86.c                            | 28 +++---
 arch/x86/kvm/x86.h                            |  2 +-
 .../selftests/kvm/include/x86_64/processor.h  | 17 ++++
 .../selftests/kvm/include/x86_64/vmx.h        |  4 -
 .../selftests/kvm/x86_64/set_sregs_test.c     | 92 ++++++++++++++++++-
 12 files changed, 153 insertions(+), 48 deletions(-)
Signature · 1 line
2.28.0