KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs
authorSean Christopherson <seanjc@google.com>
Tue, 24 Jan 2023 23:49:05 +0000 (23:49 +0000)
committerSean Christopherson <seanjc@google.com>
Fri, 27 Jan 2023 02:03:42 +0000 (18:03 -0800)
commit2de154f541fc5b9f2aed3fe06e218130718ce320
tree5057807c74cbf9510013172252752bd75045180d
parente33b6d79acac169bfe1a9682fc5b4f8202fa4c41
KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs

Provide "error" semantics (read zeros, drop writes) for userspace accesses
to MSRs that are ultimately unsupported for whatever reason, but for which
KVM told userspace to save and restore the MSR, i.e. for MSRs that KVM
included in KVM_GET_MSR_INDEX_LIST.

Previously, KVM special cased a few PMU MSRs that were problematic at one
point or another.  Extend the treatment to all PMU MSRs, e.g. to avoid
spurious unsupported accesses.

Note, the logic can also be used for non-PMU MSRs, but as of today only
PMU MSRs can end up being unsupported after KVM told userspace to save and
restore them.

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