Re: [PATCH v11 07/11] KVM: x86: Expose MSR_IA32_PERF_CAPABILITIES for LBR record format

Peter Zijlstra
2020-05-19T10:53:49Z

On Thu, May 14, 2020 at 04:30:50PM +0800, Like Xu wrote:
> @@ -203,6 +206,12 @@ static int intel_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> case MSR_CORE_PERF_GLOBAL_OVF_CTRL:
> msr_info->data = pmu->global_ovf_ctrl;
> return 0;
> + case MSR_IA32_PERF_CAPABILITIES:
> + if (!msr_info->host_initiated &&
> + !guest_cpuid_has(vcpu, X86_FEATURE_PDCM))
> + return 1;

I know this is KVM code, so maybe they feel differently, but I find the
above indentation massively confusing. Consider using: "set cino=:0(0"
if you're a vim user.

> + msr_info->data = vcpu->arch.perf_capabilities;
> + return 0;
> default:
> if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) {
> u64 val = pmc_read_counter(pmc);
> @@ -261,6 +270,16 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> return 0;
> }
> break;
> + case MSR_IA32_PERF_CAPABILITIES:
> + if (!msr_info->host_initiated ||
> + !guest_cpuid_has(vcpu, X86_FEATURE_PDCM))
> + return 1;

Idem.

> + if (!(data & ~vmx_get_perf_capabilities()))
> + return 1;
> + if ((data ^ vmx_get_perf_capabilities()) & PERF_CAP_LBR_FMT)
> + return 1;
> + vcpu->arch.perf_capabilities = data;
> + return 0;
> default:
> if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) {
> if (!msr_info->host_initiated)