Re: [PATCH v2 20/54] KVM: x86/pmu: Allow RDPMC pass through when all counters exposed to guest

Mingwei Zhang
2024-05-30T05:20:07Z

On Wed, May 08, 2024, Chen, Zide wrote:
>
>
> 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.

I prefer putting them separately, but I think I could put the above code
into a different helper.

Thanks.
-Mingwei
>
> > /* Refresh #PF interception to account for MAXPHYADDR changes. */
> > vmx_update_exception_bitmap(vcpu);
> > }