Skip to content

KVM: nVMX: Fixes for VMX capability MSR invariance

Oliver Upton kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: nVMX: Don't change VM-{Entry,Exit} ctrl MSRs on PMU CPUID updatearch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/nested.h arch/x86/kvm/vmx/pmu_intel.c+0 -240 replies
2/4KVM: nVMX: Don't change VM-{Entry,Exit} ctrl MSRs on MPX CPUID updatearch/x86/kvm/vmx/vmx.c+1 -200 replies
3/4selftests: KVM: Add test for "load IA32_PERF_GLOBAL_CTRL" invariancetools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/x86_64/vmx_capability_msrs_test.c+84 -00 replies
4/4selftests: KVM: Add test case for "{load/clear} IA32_BNDCFGS" invariancetools/testing/selftests/kvm/include/x86_64/vmx.h tools/testing/selftests/kvm/x86_64/vmx_capability_msrs_test.c+39 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] KVM: nVMX: Fixes for VMX capability MSR invariance

Ultimately, it is the responsibility of userspace to configure an appropriate MSR value for the CPUID it provides its guest. However, there are a few bits in VMX capability MSRs where KVM intervenes. The "load IA32_PERF_GLOBAL_CTRL", "load IA32_BNDCFGS", and "clear IA32_BNDCFGS" bits in the VMX VM-{Entry,Exit} control capability MSRs are updated every time userspace sets the guest's CPUID. In so doing, there is an imposed ordering between ioctls, that userspace must set MSR values *after* setting the guest's CPUID.

Such ordering requirements should be entirely avoided. This series stops KVM from modifying VMX VM-{Entry,Exit} control capability MSRs when the CPUID changes. With this series applied, MSR writes from userspace before and after KVM_SET_CPUID2 are preserved.

This series cleanly applies to 5.17-rc2. Confirmed the bug with the included selftest, and also verified the fix. Tested with KVM selftests on a Skylake box.

Oliver Upton (4):
KVM: nVMX: Don't change VM-{Entry,Exit} ctrl MSRs on PMU CPUID update
KVM: nVMX: Don't change VM-{Entry,Exit} ctrl MSRs on MPX CPUID update
selftests: KVM: Add test for "load IA32_PERF_GLOBAL_CTRL" invariance
selftests: KVM: Add test case for "{load/clear} IA32_BNDCFGS"
invariance

 arch/x86/kvm/vmx/nested.c                     |  21 ----
 arch/x86/kvm/vmx/nested.h                     |   1 -
 arch/x86/kvm/vmx/pmu_intel.c                  |   2 -
 arch/x86/kvm/vmx/vmx.c                        |  21 +---
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/vmx.h        |   2 +
 .../kvm/x86_64/vmx_capability_msrs_test.c     | 119 ++++++++++++++++++
 8 files changed, 124 insertions(+), 44 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/vmx_capability_msrs_test.c
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog