2021-05-12 08:48:27

by Like Xu

[permalink] [raw]
Subject: [PATCH v3 5/5] KVM: x86/pmu: Expose PEBS-via-PT in the KVM supported capabilities

The hypervisor userspace can dis/enable it via the MSR-based feature
"MSR_IA32_PERF_CAPABILITIES [bit 16]". If guest also has basic PT support,
it can output the PEBS records to the PT buffer.

Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Like Xu <[email protected]>
---
arch/x86/kvm/vmx/capabilities.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
index fd8c9822db9e..e04b50174dd5 100644
--- a/arch/x86/kvm/vmx/capabilities.h
+++ b/arch/x86/kvm/vmx/capabilities.h
@@ -398,8 +398,11 @@ static inline u64 vmx_get_perf_capabilities(void)

perf_cap |= host_perf_cap & PMU_CAP_LBR_FMT;

- if (vmx_pebs_supported())
+ if (vmx_pebs_supported()) {
perf_cap |= host_perf_cap & PERF_CAP_PEBS_MASK;
+ if (vmx_pt_mode_is_host_guest())
+ perf_cap |= host_perf_cap & PERF_CAP_PEBS_OUTPUT_PT;
+ }

return perf_cap;
}
--
2.31.1