]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: VMX: Adjust number of LBR records for PERF_CAPABILITIES at refresh
authorSean Christopherson <seanjc@google.com>
Wed, 27 Jul 2022 23:34:24 +0000 (23:34 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Aug 2022 19:08:30 +0000 (15:08 -0400)
commite087cb3d4a8dff980a8bac361fd190f77b12cdf6
treea917665371c90aaacd68fa3622398c5d7456d8ea
parent6953d88f6f46931394c791f3c704a055c0c7deb6
KVM: VMX: Adjust number of LBR records for PERF_CAPABILITIES at refresh

Now that the PMU is refreshed when MSR_IA32_PERF_CAPABILITIES is written
by host userspace, zero out the number of LBR records for a vCPU during
PMU refresh if PMU_CAP_LBR_FMT is not set in PERF_CAPABILITIES instead of
handling the check at run-time.

guest_cpuid_has() is expensive due to the linear search of guest CPUID
entries, intel_pmu_lbr_is_enabled() is checked on every VM-Enter, _and_
simply enumerating the same "Model" as the host causes KVM to set the
number of LBR records to a non-zero value.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220727233424.2968356-4-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/pmu_intel.c
arch/x86/kvm/vmx/vmx.h