On Wed, Feb 02, 2022, Jim Mattson wrote: > On Wed, Feb 2, 2022 at 4:33 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > > > On Wed, Feb 02, 2022, Jim Mattson wrote: > > > On Wed, Feb 2, 2022 at 3:04 PM Oliver Upton <oupton@xxxxxxxxxx> wrote: > > > > > > > > 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. > > > > > > Do you mean *before*? > > > > No, after, otherwise the CPUID updates will override the MSR updates. > > Wasn't that the intention behind this code in the first place (to > override KVM_SET_MSR based on CPUID bits)? If not, what was the > intention behind this code? The MPX side is from commit 5f76f6f5ff96 ("KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled"), which was a miguided "fix" to workaround an L1 KVM bug in L0. And also to workaround an L0 userspace bug (failure to set VMX MSRs). The PMU bug looks to be a similar snafu, it appears to workaround a userspace bug (again, failure to set VMX MSRs) in KVM. But once userspace started taking ownership of VMX MSRs, KVM's hack-a-fixes just got in the way :-/