diff mbox series

[v3,5/5] KVM: x86/pmu: Expose PEBS-via-PT in the KVM supported capabilities

Message ID 20210512084446.342526-6-like.xu@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: x86/pmu: Add support to enable guest PEBS via PT | expand

Commit Message

Like Xu May 12, 2021, 8:44 a.m. UTC
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 <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
 arch/x86/kvm/vmx/capabilities.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;
 }