Skip to content

Commit 30dab5c

Browse files
Like Xusean-jc
authored andcommitted
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>
1 parent 8de1854 commit 30dab5c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
402402
if (!msr_info->host_initiated)
403403
return 1; /* RO MSR */
404404

405+
if (data & pmu->global_status_mask)
406+
return 1;
407+
405408
pmu->global_status = data;
406409
break;
407410
case MSR_CORE_PERF_GLOBAL_CTRL:

0 commit comments

Comments
 (0)