mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Xu, Like" <like.xu@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
	ak@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Joerg Roedel <joro@8bytes.org>,
	Jim Mattson <jmattson@google.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Like Xu <like.xu@linux.intel.com>,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [RESEND v13 09/10] KVM: vmx/pmu: Expose LBR_FMT in the MSR_IA32_PERF_CAPABILITIES
Date: Wed, 27 Jan 2021 10:49:42 +0100	[thread overview]
Message-ID: <dfbd5e93-fd15-4185-9315-407011f9aa35@redhat.com> (raw)
In-Reply-To: <fb4c3124-997b-5897-e38f-1b9aa782e5e2@intel.com>

On 27/01/21 06:45, Xu, Like wrote:
> On 2021/1/26 17:30, Paolo Bonzini wrote:
>> On 08/01/21 02:37, Like Xu wrote:
>>> Userspace could enable guest LBR feature when the exactly supported
>>> LBR format value is initialized to the MSR_IA32_PERF_CAPABILITIES
>>> and the LBR is also compatible with vPMU version and host cpu model.
>>>
>>> Signed-off-by: Like Xu <like.xu@linux.intel.com>
>>> Reviewed-by: Andi Kleen <ak@linux.intel.com>
>>> ---
>>>   arch/x86/kvm/vmx/capabilities.h | 9 ++++++++-
>>>   arch/x86/kvm/vmx/vmx.c          | 7 +++++++
>>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/x86/kvm/vmx/capabilities.h 
>>> b/arch/x86/kvm/vmx/capabilities.h
>>> index 57b940c613ab..a9a7c4d1b634 100644
>>> --- a/arch/x86/kvm/vmx/capabilities.h
>>> +++ b/arch/x86/kvm/vmx/capabilities.h
>>> @@ -378,7 +378,14 @@ static inline u64 vmx_get_perf_capabilities(void)
>>>        * Since counters are virtualized, KVM would support full
>>>        * width counting unconditionally, even if the host lacks it.
>>>        */
>>> -    return PMU_CAP_FW_WRITES;
>>> +    u64 perf_cap = PMU_CAP_FW_WRITES;
>>> +
>>> +    if (boot_cpu_has(X86_FEATURE_PDCM))
>>> +        rdmsrl(MSR_IA32_PERF_CAPABILITIES, perf_cap);
>>> +
>>> +    perf_cap |= perf_cap & PMU_CAP_LBR_FMT;
>>> +
>>> +    return perf_cap;
>>>   }
>>>     static inline u64 vmx_supported_debugctl(void)
>>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>>> index ad3b079f6700..9cb5b1e4fc27 100644
>>> --- a/arch/x86/kvm/vmx/vmx.c
>>> +++ b/arch/x86/kvm/vmx/vmx.c
>>> @@ -2229,6 +2229,13 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, 
>>> struct msr_data *msr_info)
>>>       case MSR_IA32_PERF_CAPABILITIES:
>>>           if (data && !vcpu_to_pmu(vcpu)->version)
>>>               return 1;
>>> +        if (data & PMU_CAP_LBR_FMT) {
>>> +            if ((data & PMU_CAP_LBR_FMT) !=
>>> +                (vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT))
>>> +                return 1;
>>> +            if (!intel_pmu_lbr_is_compatible(vcpu))
>>> +                return 1;
>>> +        }
>>>           ret = kvm_set_msr_common(vcpu, msr_info);
>>>           break;
>>>
>>
>> Please move this hunk to patch 4.
>>
>> Paolo
>>
> Thanks, I'll do this part early in the next version.
> 
> I would have thought that we need to
> make the interface exposing as the last enabling step.

That's the right thing to do for vmx_get_perf_capabilities().  However, 
checking the values of MSR_IA32_PERF_CAPABILITIES can be done early.

Paolo


  reply	other threads:[~2021-01-27  9:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  1:36 [RESEND v13 00/10] KVM: x86/pmu: Guest Last Branch Recording Enabling Like Xu
2021-01-08  1:36 ` [RESEND v13 01/10] KVM: x86: Move common set/get handler of MSR_IA32_DEBUGCTLMSR to VMX Like Xu
2021-01-26  9:25   ` Paolo Bonzini
2021-01-08  1:36 ` [RESEND v13 02/10] KVM: x86/vmx: Make vmx_set_intercept_for_msr() non-static Like Xu
2021-01-08  1:36 ` [RESEND v13 03/10] KVM: x86/pmu: Use IA32_PERF_CAPABILITIES to adjust features visibility Like Xu
2021-01-26  9:42   ` Paolo Bonzini
2021-01-27  6:04     ` Like Xu
2021-01-27  9:48       ` Paolo Bonzini
2021-02-01  5:28       ` Like Xu
2021-01-08  1:36 ` [RESEND v13 04/10] KVM: vmx/pmu: Clear PMU_CAP_LBR_FMT when guest LBR is disabled Like Xu
2021-01-08  1:36 ` [RESEND v13 05/10] KVM: vmx/pmu: Create a guest LBR event when vcpu sets DEBUGCTLMSR_LBR Like Xu
2021-01-08  1:37 ` [RESEND v13 06/10] KVM: vmx/pmu: Pass-through LBR msrs when the guest LBR event is ACTIVE Like Xu
2021-01-08  1:37 ` [RESEND v13 07/10] KVM: vmx/pmu: Reduce the overhead of LBR pass-through or cancellation Like Xu
2021-01-26  9:27   ` Paolo Bonzini
2021-01-08  1:37 ` [RESEND v13 08/10] KVM: vmx/pmu: Emulate legacy freezing LBRs on virtual PMI Like Xu
2021-01-08  1:37 ` [RESEND v13 09/10] KVM: vmx/pmu: Expose LBR_FMT in the MSR_IA32_PERF_CAPABILITIES Like Xu
2021-01-26  9:30   ` Paolo Bonzini
2021-01-27  5:45     ` Xu, Like
2021-01-27  9:49       ` Paolo Bonzini [this message]
2021-01-08  1:37 ` [RESEND v13 10/10] KVM: vmx/pmu: Release guest LBR event via lazy release mechanism Like Xu
2021-01-26  9:33   ` Paolo Bonzini
2021-01-15  8:19 ` [RESEND v13 00/10] KVM: x86/pmu: Guest Last Branch Recording Enabling Alex Shi
2021-01-15  8:51   ` Xu, Like

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dfbd5e93-fd15-4185-9315-407011f9aa35@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kan.liang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu@intel.com \
    --cc=like.xu@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=wei.w.wang@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®