public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Allow exposure of VMware backdoor Pseudo-PMCs when !enable_pmu
@ 2023-08-22  8:03 Like Xu
  2023-08-23 20:35 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Like Xu @ 2023-08-22  8:03 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: Paolo Bonzini, kvm, linux-kernel

From: Like Xu <likexu@tencent.com>

Fix kvm_pmu_rdpmc() logic to allow exposure of VMware backdoor Pseudo-PMCs
if pmu is globally disabled.

In this usage scenario, once vmware_backdoor is enabled, the VMs can fully
utilize all of the vmware_backdoor-related resources, not just part of it,
i.e., vcpu should always be able to access the VMware backdoor Pseudo-PMCs
via RDPMC. Since the enable_pmu is more concerned with the visibility of
hardware pmu resources on the host, fix it to decouple the two knobs.

The test case vmware_backdoors from KUT is used for validation.

Cc: Arbel Moshe <arbel.moshe@oracle.com>
Cc: Liran Alon <liran.alon@oracle.com>
Cc: Nikita Leshenko <nikita.leshchenko@oracle.com>
Signed-off-by: Like Xu <likexu@tencent.com>
---
 arch/x86/kvm/pmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index edb89b51b383..c896328b2b5a 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -526,12 +526,12 @@ int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data)
 	struct kvm_pmc *pmc;
 	u64 mask = fast_mode ? ~0u : ~0ull;
 
-	if (!pmu->version)
-		return 1;
-
 	if (is_vmware_backdoor_pmc(idx))
 		return kvm_pmu_rdpmc_vmware(vcpu, idx, data);
 
+	if (!pmu->version)
+		return 1;
+
 	pmc = static_call(kvm_x86_pmu_rdpmc_ecx_to_pmc)(vcpu, idx, &mask);
 	if (!pmc)
 		return 1;

base-commit: fff2e47e6c3b8050ca26656693caa857e3a8b740
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-11 21:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22  8:03 [PATCH] KVM: x86: Allow exposure of VMware backdoor Pseudo-PMCs when !enable_pmu Like Xu
2023-08-23 20:35 ` Sean Christopherson
2023-09-11  9:59   ` Like Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox