KVM: x86: Suppress failures on userspace access to advertised, unsupported MSRs
authorSean Christopherson <seanjc@google.com>
Fri, 2 Aug 2024 18:19:34 +0000 (11:19 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 22 Aug 2024 19:07:38 +0000 (12:07 -0700)
commit64a5d7a1091ff6ee70d2155b9dccfe8107d35ffa
treed24a02b25badfaa4abf1c16f48d8f3d1eb70d7f2
parent3adef9034596a8ba6415e6e460209cd9fc524e81
KVM: x86: Suppress failures on userspace access to advertised, unsupported MSRs

Extend KVM's suppression of failures due to a userspace access to an
unsupported, but advertised as a "to save" MSR to all MSRs, not just those
that happen to reach the default case statements in kvm_get_msr_common()
and kvm_set_msr_common().  KVM's soon-to-be-established ABI is that if an
MSR is advertised to userspace, then userspace is allowed to read the MSR,
and write back the value that was read, i.e. why an MSR is unsupported
doesn't change KVM's ABI.

Practically speaking, this is very nearly a nop, as the only other paths
that return KVM_MSR_RET_UNSUPPORTED are {svm,vmx}_get_feature_msr(), and
it's unlikely, though not impossible, that userspace is using KVM_GET_MSRS
on unsupported MSRs.

The primary goal of moving the suppression to common code is to allow
returning KVM_MSR_RET_UNSUPPORTED as appropriate throughout KVM, without
having to manually handle the "is userspace accessing an advertised"
waiver.  I.e. this will allow formalizing KVM's ABI without incurring a
high maintenance cost.

Link: https://lore.kernel.org/r/20240802181935.292540-10-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c