]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: VMX: Mark all PERF_GLOBAL_(OVF)_CTRL bits reserved if there's no vPMU
authorSean Christopherson <seanjc@google.com>
Fri, 22 Jul 2022 22:44:06 +0000 (22:44 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:25 +0000 (14:24 +0200)
[ Upstream commit af639f518ae27a69a677b0d151231dec925f576f ]

Mark all MSR_CORE_PERF_GLOBAL_CTRL and MSR_CORE_PERF_GLOBAL_OVF_CTRL bits
as reserved if there is no guest vPMU.  The nVMX VM-Entry consistency
checks do not check for a valid vPMU prior to consuming the masks via
kvm_valid_perf_global_ctrl(), i.e. may incorrectly allow a non-zero mask
to be loaded via VM-Enter or VM-Exit (well, attempted to be loaded, the
actual MSR load will be rejected by intel_is_valid_msr()).

Fixes: 0b1741ba4689 ("KVM: Expose a version 2 architectural PMU to a guests")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220722224409.1336532-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/vmx/pmu_intel.c

index 9aee082deee9d1bdec9ea1f2f8c2e18d69c423fc..c66edf93e4a82a096fa00678074077f42595a2b7 100644 (file)
@@ -481,6 +481,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
        pmu->version = 0;
        pmu->reserved_bits = 0xffffffff00200000ull;
        pmu->raw_event_mask = X86_RAW_EVENT_MASK;
+       pmu->global_ctrl_mask = ~0ull;
+       pmu->global_ovf_ctrl_mask = ~0ull;
        pmu->fixed_ctr_ctrl_mask = ~0ull;
 
        entry = kvm_find_cpuid_entry(vcpu, 0xa, 0);