[RFC PATCH 14/41] KVM: x86/pmu: Allow RDPMC pass through

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mingwei Zhang <mizhang@xxxxxxxxxx>

Clear RDPMC_EXITING in vmcs cpu based execution control to allow rdpmc
instruction to proceed without VMEXIT. This gives performance to
passthrough PMU. Clear RDPMC in vmx_vcpu_after_set_cpuid() when guest
enables PMU and passthrough PMU is allowed.

The passthrough RDPMC allows guest to read several PMU MSRs including
unexposed counters like fixed counter 3 as well as IA32_PERF_METRICS.

To cope with this issue, these MSRs will be cleared in later commits when
context switching to VM guest.

Co-developed-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxx>
Signed-off-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxx>
Signed-off-by: Mingwei Zhang <mizhang@xxxxxxxxxx>
---
 arch/x86/kvm/vmx/vmx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index e4610b80e519..33cb69ff0804 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7819,6 +7819,9 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
 		vmx->msr_ia32_feature_control_valid_bits &=
 			~FEAT_CTL_SGX_LC_ENABLED;
 
+	if (is_passthrough_pmu_enabled(&vmx->vcpu))
+		exec_controls_clearbit(vmx, CPU_BASED_RDPMC_EXITING);
+
 	/* Refresh #PF interception to account for MAXPHYADDR changes. */
 	vmx_update_exception_bitmap(vcpu);
 }
-- 
2.34.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux