[PATCH 19/23] KVM: x86/pmu: Always intercept GLOBAL_INUSE under PerfMon masking

Zide Chen <[email protected]>
Newsgroups org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Unlike IA32_PERF_GLOBAL_CTRL, hardware does not filter GLOBAL_INUSE
reads based on the PerfMon mask at all, so always intercept this MSR
and filter out host-owned bits in KVM.

Signed-off-by: Zide Chen <[email protected]>
---
 arch/x86/kvm/vmx/vmx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index a241efb99b3d..2bd1ffe65510 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -4339,8 +4339,15 @@ static void vmx_recalc_pmu_msr_intercepts(struct kvm_vcpu *vcpu)
 				  MSR_TYPE_RW, intercept);
 	vmx_set_intercept_for_msr(vcpu, MSR_CORE_PERF_GLOBAL_STATUS_SET,
 				  MSR_TYPE_RW, intercept || pmu->version < 4);
+
+	/*
+	 * IA32_PERF_GLOBAL_INUSE reads are not subject to PerfMon mask
+	 * filtering.
+	 */
 	vmx_set_intercept_for_msr(vcpu, MSR_CORE_PERF_GLOBAL_INUSE,
-				  MSR_TYPE_RW, intercept || pmu->version < 4);
+				  MSR_TYPE_RW,
+				  intercept || kvm_vcpu_has_perfmon_mask(vcpu) ||
+				  pmu->version < 4);
 
 	intercept = !has_mediated_pmu || !kvm_vcpu_has_perf_metrics(vcpu);
 	vmx_set_intercept_for_msr(vcpu, MSR_PERF_METRICS,
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.