On 21/10/19 16:04, Like Xu wrote: > >> >> 2) introduce a new callback msr_idx_to_pmc that returns a struct >> kvm_pmc*, and change kvm_pmu_is_valid_msr to do > > For callback msr_idx_to_pmc, > how do we deal with the input 'MSR_CORE_PERF_FIXED_CTR_CTRL' > which may return several fixed kvm_pmcs not just one? For RDMSR, do not do anything. For WRMSR, you can handle it in the set_msr callback. >> >> static int kvm_pmu_mark_pmc_in_use(struct kvm_vcpu *vcpu, u32 msr) > > s/static int/static void/. > >> { >> struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); >> struct kvm_pmc *pmc = kvm_x86_ops->pmu_ops->msr_idx_to_pmc(vcpu, msr); > > We need 'if(pmc)' here. Agreed, sorry for the sloppiness. Never interpret my suggestions as more than pseudocode. :) Paolo