diff options
author | Like Xu <like.xu@linux.intel.com> | 2021-02-01 08:10:38 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-02-04 13:27:26 +0300 |
commit | be635e34c284d08b1da7f93ddd6a2110617d15e7 (patch) | |
tree | 60dbea4f591e103ab02a2903e8565324bc9aec46 /arch/x86/kvm/vmx/capabilities.h | |
parent | 9aa4f622460f9287e57804dbeb219bfef29f04a1 (diff) | |
download | linux-be635e34c284d08b1da7f93ddd6a2110617d15e7.tar.xz |
KVM: vmx/pmu: Expose LBR_FMT in the MSR_IA32_PERF_CAPABILITIES
Userspace could enable guest LBR feature when the exactly supported
LBR format value is initialized to the MSR_IA32_PERF_CAPABILITIES
and the LBR is also compatible with vPMU version and host cpu model.
The LBR could be enabled on the guest if host perf supports LBR
(checked via x86_perf_get_lbr()) and the vcpu model is compatible
with the host one.
Signed-off-by: Like Xu <like.xu@linux.intel.com>
Message-Id: <20210201051039.255478-11-like.xu@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx/capabilities.h')
-rw-r--r-- | arch/x86/kvm/vmx/capabilities.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h index 8e6179586e27..d1d77985e889 100644 --- a/arch/x86/kvm/vmx/capabilities.h +++ b/arch/x86/kvm/vmx/capabilities.h @@ -380,11 +380,18 @@ static inline bool vmx_pt_mode_is_host_guest(void) static inline u64 vmx_get_perf_capabilities(void) { + u64 perf_cap = 0; + + if (boot_cpu_has(X86_FEATURE_PDCM)) + rdmsrl(MSR_IA32_PERF_CAPABILITIES, perf_cap); + + perf_cap &= PMU_CAP_LBR_FMT; + /* * Since counters are virtualized, KVM would support full * width counting unconditionally, even if the host lacks it. */ - return PMU_CAP_FW_WRITES; + return PMU_CAP_FW_WRITES | perf_cap; } static inline u64 vmx_supported_debugctl(void) |