On 5/5/2024 10:29 PM, Mingwei Zhang wrote: > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index a5024b7b0439..a18ba5ae5376 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -7860,6 +7860,11 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) > vmx->msr_ia32_feature_control_valid_bits &= > ~FEAT_CTL_SGX_LC_ENABLED; > > + if (kvm_pmu_check_rdpmc_passthrough(&vmx->vcpu)) > + exec_controls_clearbit(vmx, CPU_BASED_RDPMC_EXITING); > + else > + exec_controls_setbit(vmx, CPU_BASED_RDPMC_EXITING); > + Seems it's cleaner to put the code inside vmx_set_perf_global_ctrl(), and change the name to reflect that it handles all the PMU related VMCS controls. > /* Refresh #PF interception to account for MAXPHYADDR changes. */ > vmx_update_exception_bitmap(vcpu); > }