aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLike Xu <likexu@tencent.com>2023-06-02 18:10:49 -0700
committerSean Christopherson <seanjc@google.com>2023-06-06 17:31:44 -0700
commit30dab5c0b65ea580878f36d6ae7ff85f06813387 (patch)
tree08f89e4e067e77a1aaae302d7f8bbdb14b2e4475
parentKVM: x86/pmu: Move reprogram_counters() to pmu.h (diff)
downloadwireguard-linux-30dab5c0b65ea580878f36d6ae7ff85f06813387.tar.xz
wireguard-linux-30dab5c0b65ea580878f36d6ae7ff85f06813387.zip
KVM: x86/pmu: Reject userspace attempts to set reserved GLOBAL_STATUS bits
Reject userspace writes to MSR_CORE_PERF_GLOBAL_STATUS that attempt to set reserved bits. Allowing userspace to stuff reserved bits doesn't harm KVM itself, but it's architecturally wrong and the guest can't clear the unsupported bits, e.g. makes the guest's PMI handler very confused. Signed-off-by: Like Xu <likexu@tencent.com> [sean: rewrite changelog to avoid use of #GP, rebase on name change] Link: https://lore.kernel.org/r/20230603011058.1038821-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--arch/x86/kvm/vmx/pmu_intel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index edcf8670eb4e..efd113f24c1b 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -402,6 +402,9 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
if (!msr_info->host_initiated)
return 1; /* RO MSR */
+ if (data & pmu->global_status_mask)
+ return 1;
+
pmu->global_status = data;
break;
case MSR_CORE_PERF_GLOBAL_CTRL: