From: Wei Wang <wei.w.wang@intel.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
pbonzini@redhat.com, ak@linux.intel.com
Cc: kan.liang@intel.com, peterz@infradead.org, mingo@redhat.com,
rkrcmar@redhat.com, like.xu@intel.com, jannh@google.com,
arei.gonglei@huawei.com
Subject: Re: [PATCH v3 3/5] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest
Date: Thu, 20 Sep 2018 20:38:20 +0800 [thread overview]
Message-ID: <5BA394BC.1070804@intel.com> (raw)
In-Reply-To: <1537437959-8751-4-git-send-email-wei.w.wang@intel.com>
On 09/20/2018 06:05 PM, Wei Wang wrote:
> Bits [0, 5] of MSR_IA32_PERF_CAPABILITIES tell about the format of
> the addresses stored in the LBR stack. Expose those bits to the guest
> when the guest lbr feature is enabled.
>
> Signed-off-by: Like Xu <like.xu@intel.com>
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> ---
> arch/x86/include/asm/perf_event.h | 2 ++
> arch/x86/kvm/cpuid.c | 2 +-
> arch/x86/kvm/vmx.c | 7 +++++++
> 3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
> index 84cc8cb..e893a69 100644
> --- a/arch/x86/include/asm/perf_event.h
> +++ b/arch/x86/include/asm/perf_event.h
> @@ -79,6 +79,8 @@
> #define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6
> #define ARCH_PERFMON_EVENTS_COUNT 7
>
> +#define PERF_CAP_MASK_LBR_FMT 0x3f
> +
> /*
> * Intel "Architectural Performance Monitoring" CPUID
> * detection/enumeration details:
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 7bcfa61..3b8a57b 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -365,7 +365,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> F(XMM3) | F(PCLMULQDQ) | 0 /* DTES64, MONITOR */ |
> 0 /* DS-CPL, VMX, SMX, EST */ |
> 0 /* TM2 */ | F(SSSE3) | 0 /* CNXT-ID */ | 0 /* Reserved */ |
> - F(FMA) | F(CX16) | 0 /* xTPR Update, PDCM */ |
> + F(FMA) | F(CX16) | 0 /* xTPR Update*/ | F(PDCM) |
> F(PCID) | 0 /* Reserved, DCA */ | F(XMM4_1) |
> F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) |
> 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 533a327..92705b5 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -4134,6 +4134,13 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
> return 1;
> /* Otherwise falls through */
> + case MSR_IA32_PERF_CAPABILITIES:
> + if (!boot_cpu_has(X86_FEATURE_PDCM))
> + return 1;
> + msr_info->data = native_read_msr(MSR_IA32_PERF_CAPABILITIES);
> + if (vcpu->kvm->arch.guest_lbr_enabled)
> + msr_info->data &= PERF_CAP_MASK_LBR_FMT;
> + break;
Sorry about a mistake here. Will move "case MSR_IA32_PERF_CAPABILITIES"
one step above - above "case TSC_AUX".
Best,
Wei
next prev parent reply other threads:[~2018-09-20 12:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 10:05 [PATCH v3 0/5] Guest LBR Enabling Wei Wang
2018-09-20 10:05 ` [PATCH v3 1/5] perf/x86: add a function to get the lbr stack Wei Wang
2018-09-20 12:05 ` Peter Zijlstra
2018-09-20 12:07 ` Peter Zijlstra
2018-09-20 10:05 ` [PATCH v3 2/5] KVM/x86: KVM_CAP_X86_GUEST_LBR Wei Wang
2018-09-20 10:05 ` [PATCH v3 3/5] KVM/x86: expose MSR_IA32_PERF_CAPABILITIES to the guest Wei Wang
2018-09-20 12:38 ` Wei Wang [this message]
2018-09-20 10:05 ` [PATCH v3 4/5] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack Wei Wang
2018-09-20 12:17 ` Peter Zijlstra
2018-09-20 12:32 ` Peter Zijlstra
2018-09-27 13:45 ` Wang, Wei W
2018-09-20 15:30 ` Andi Kleen
2018-09-20 16:24 ` Peter Zijlstra
2018-09-27 10:10 ` Wang, Wei W
2018-09-27 10:05 ` Wang, Wei W
2018-09-20 10:05 ` [PATCH v3 5/5] KVM/x86/lbr: lazy save " Wei Wang
2018-09-20 12:07 ` Gonglei (Arei)
2018-09-27 14:11 ` Wang, Wei W
2018-09-20 12:37 ` Peter Zijlstra
2018-09-20 12:58 ` Wei Wang
2018-09-20 12:57 ` Peter Zijlstra
2018-09-20 11:34 ` [PATCH v3 0/5] Guest LBR Enabling Gonglei (Arei)
2018-09-20 12:36 ` Wei Wang
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=5BA394BC.1070804@intel.com \
--to=wei.w.wang@intel.com \
--cc=ak@linux.intel.com \
--cc=arei.gonglei@huawei.com \
--cc=jannh@google.com \
--cc=kan.liang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
/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