From: Eduardo Habkost <ehabkost@redhat.com>
To: Luwei Kang <luwei.kang@intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, pbonzini@redhat.com,
rth@twiddle.net, mtosatti@redhat.com,
Chao Peng <chao.p.peng@linux.intel.com>
Subject: Re: [PATCH RESEND v1 1/2] i386: Add Intel Processor Trace feature support
Date: Fri, 12 Jan 2018 12:22:52 -0200 [thread overview]
Message-ID: <20180112142252.GG6646@localhost.localdomain> (raw)
In-Reply-To: <1515443797-10837-1-git-send-email-luwei.kang@intel.com>
On Tue, Jan 09, 2018 at 04:36:36AM +0800, Luwei Kang wrote:
> From: Chao Peng <chao.p.peng@linux.intel.com>
>
> Expose Intel Processor Trace feature to guest.
>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> Signed-off-by: Luwei Kang <luwei.kang@intel.com>
> ---
> target/i386/cpu.c | 19 ++++++++++++++++++-
> target/i386/cpu.h | 1 +
> target/i386/kvm.c | 23 +++++++++++++++++++++++
> 3 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 3818d72..57f8370 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -427,7 +427,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
> NULL, NULL, "mpx", NULL,
> "avx512f", "avx512dq", "rdseed", "adx",
> "smap", "avx512ifma", "pcommit", "clflushopt",
> - "clwb", NULL, "avx512pf", "avx512er",
> + "clwb", "intel-pt", "avx512pf", "avx512er",
> "avx512cd", "sha-ni", "avx512bw", "avx512vl",
> },
> .cpuid_eax = 7,
> @@ -3006,6 +3006,23 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
> }
> break;
> }
> + case 0x14: {
> + if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
> + kvm_enabled()) {
> + KVMState *s = cs->kvm_state;
> +
> + *eax = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EAX);
> + *ebx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EBX);
> + *ecx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_ECX);
> + *edx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EDX);
If you are forwarding host info directly to the guest, the
feature is not migration-safe. The new feature needs to be added
to feature_word_info[FEAT_7_0_EBX].unmigratable_flags.
> + } else {
> + *eax = 0;
> + *ebx = 0;
> + *ecx = 0;
> + *edx = 0;
> + }
> + break;
> + }
> case 0x40000000:
> /*
> * CPUID code in kvm_arch_init_vcpu() ignores stuff
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 62c4742..58a4b6c 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -642,6 +642,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
> #define CPUID_7_0_EBX_PCOMMIT (1U << 22) /* Persistent Commit */
> #define CPUID_7_0_EBX_CLFLUSHOPT (1U << 23) /* Flush a Cache Line Optimized */
> #define CPUID_7_0_EBX_CLWB (1U << 24) /* Cache Line Write Back */
> +#define CPUID_7_0_EBX_INTEL_PT (1U << 25) /* Intel Processor Trace */
> #define CPUID_7_0_EBX_AVX512PF (1U << 26) /* AVX-512 Prefetch */
> #define CPUID_7_0_EBX_AVX512ER (1U << 27) /* AVX-512 Exponential and Reciprocal */
> #define CPUID_7_0_EBX_AVX512CD (1U << 28) /* AVX-512 Conflict Detection */
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 6f69e2f..e13ab58 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -863,6 +863,29 @@ int kvm_arch_init_vcpu(CPUState *cs)
> c = &cpuid_data.entries[cpuid_i++];
> }
> break;
> + case 0x14: {
> + uint32_t times;
> +
> + c->function = i;
> + c->index = 0;
> + c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> + cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
> + times = c->eax;
> +
> + for (j = 1; j <= times; ++j) {
> + if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
> + fprintf(stderr, "cpuid_data is full, no space for "
> + "cpuid(eax:0x14,ecx:0x%x)\n", j);
> + abort();
> + }
> + c = &cpuid_data.entries[cpuid_i++];
> + c->function = i;
> + c->index = j;
> + c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> + cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx);
> + }
> + break;
> + }
> default:
> c->function = i;
> c->flags = 0;
> --
> 1.8.3.1
>
--
Eduardo
WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com>
To: Luwei Kang <luwei.kang@intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, pbonzini@redhat.com,
rth@twiddle.net, mtosatti@redhat.com,
Chao Peng <chao.p.peng@linux.intel.com>
Subject: Re: [Qemu-devel] [PATCH RESEND v1 1/2] i386: Add Intel Processor Trace feature support
Date: Fri, 12 Jan 2018 12:22:52 -0200 [thread overview]
Message-ID: <20180112142252.GG6646@localhost.localdomain> (raw)
In-Reply-To: <1515443797-10837-1-git-send-email-luwei.kang@intel.com>
On Tue, Jan 09, 2018 at 04:36:36AM +0800, Luwei Kang wrote:
> From: Chao Peng <chao.p.peng@linux.intel.com>
>
> Expose Intel Processor Trace feature to guest.
>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> Signed-off-by: Luwei Kang <luwei.kang@intel.com>
> ---
> target/i386/cpu.c | 19 ++++++++++++++++++-
> target/i386/cpu.h | 1 +
> target/i386/kvm.c | 23 +++++++++++++++++++++++
> 3 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 3818d72..57f8370 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -427,7 +427,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
> NULL, NULL, "mpx", NULL,
> "avx512f", "avx512dq", "rdseed", "adx",
> "smap", "avx512ifma", "pcommit", "clflushopt",
> - "clwb", NULL, "avx512pf", "avx512er",
> + "clwb", "intel-pt", "avx512pf", "avx512er",
> "avx512cd", "sha-ni", "avx512bw", "avx512vl",
> },
> .cpuid_eax = 7,
> @@ -3006,6 +3006,23 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
> }
> break;
> }
> + case 0x14: {
> + if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
> + kvm_enabled()) {
> + KVMState *s = cs->kvm_state;
> +
> + *eax = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EAX);
> + *ebx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EBX);
> + *ecx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_ECX);
> + *edx = kvm_arch_get_supported_cpuid(s, 0x14, count, R_EDX);
If you are forwarding host info directly to the guest, the
feature is not migration-safe. The new feature needs to be added
to feature_word_info[FEAT_7_0_EBX].unmigratable_flags.
> + } else {
> + *eax = 0;
> + *ebx = 0;
> + *ecx = 0;
> + *edx = 0;
> + }
> + break;
> + }
> case 0x40000000:
> /*
> * CPUID code in kvm_arch_init_vcpu() ignores stuff
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 62c4742..58a4b6c 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -642,6 +642,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
> #define CPUID_7_0_EBX_PCOMMIT (1U << 22) /* Persistent Commit */
> #define CPUID_7_0_EBX_CLFLUSHOPT (1U << 23) /* Flush a Cache Line Optimized */
> #define CPUID_7_0_EBX_CLWB (1U << 24) /* Cache Line Write Back */
> +#define CPUID_7_0_EBX_INTEL_PT (1U << 25) /* Intel Processor Trace */
> #define CPUID_7_0_EBX_AVX512PF (1U << 26) /* AVX-512 Prefetch */
> #define CPUID_7_0_EBX_AVX512ER (1U << 27) /* AVX-512 Exponential and Reciprocal */
> #define CPUID_7_0_EBX_AVX512CD (1U << 28) /* AVX-512 Conflict Detection */
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 6f69e2f..e13ab58 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -863,6 +863,29 @@ int kvm_arch_init_vcpu(CPUState *cs)
> c = &cpuid_data.entries[cpuid_i++];
> }
> break;
> + case 0x14: {
> + uint32_t times;
> +
> + c->function = i;
> + c->index = 0;
> + c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> + cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
> + times = c->eax;
> +
> + for (j = 1; j <= times; ++j) {
> + if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
> + fprintf(stderr, "cpuid_data is full, no space for "
> + "cpuid(eax:0x14,ecx:0x%x)\n", j);
> + abort();
> + }
> + c = &cpuid_data.entries[cpuid_i++];
> + c->function = i;
> + c->index = j;
> + c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> + cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx);
> + }
> + break;
> + }
> default:
> c->function = i;
> c->flags = 0;
> --
> 1.8.3.1
>
--
Eduardo
next prev parent reply other threads:[~2018-01-12 14:23 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 20:36 [PATCH RESEND v1 1/2] i386: Add Intel Processor Trace feature support Luwei Kang
2018-01-08 20:36 ` [Qemu-devel] " Luwei Kang
2018-01-08 20:36 ` [PATCH RESEND v1 2/2] i386: Add support to get/set/migrate Intel Processor Trace feature Luwei Kang
2018-01-08 20:36 ` [Qemu-devel] " Luwei Kang
2018-01-12 14:22 ` Eduardo Habkost [this message]
2018-01-12 14:22 ` [Qemu-devel] [PATCH RESEND v1 1/2] i386: Add Intel Processor Trace feature support Eduardo Habkost
2018-01-15 7:19 ` Kang, Luwei
2018-01-15 7:19 ` [Qemu-devel] " Kang, Luwei
2018-01-15 9:33 ` Paolo Bonzini
2018-01-15 9:33 ` [Qemu-devel] " Paolo Bonzini
2018-01-15 14:04 ` Eduardo Habkost
2018-01-15 14:04 ` [Qemu-devel] " Eduardo Habkost
2018-01-15 14:25 ` Jiri Denemark
2018-01-15 14:25 ` [Qemu-devel] " Jiri Denemark
2018-01-15 14:31 ` Eduardo Habkost
2018-01-15 14:31 ` [Qemu-devel] " Eduardo Habkost
2018-01-16 6:10 ` Kang, Luwei
2018-01-16 6:10 ` [Qemu-devel] " Kang, Luwei
2018-01-16 11:51 ` Eduardo Habkost
2018-01-16 11:51 ` [Qemu-devel] " Eduardo Habkost
2018-01-17 10:32 ` Kang, Luwei
2018-01-17 10:32 ` [Qemu-devel] " Kang, Luwei
2018-01-18 2:42 ` Eduardo Habkost
2018-01-18 2:42 ` [Qemu-devel] " Eduardo Habkost
2018-01-18 5:33 ` Kang, Luwei
2018-01-18 5:33 ` [Qemu-devel] " Kang, Luwei
2018-01-18 13:24 ` Eduardo Habkost
2018-01-18 13:24 ` [Qemu-devel] " Eduardo Habkost
2018-01-18 13:39 ` Paolo Bonzini
2018-01-18 13:39 ` [Qemu-devel] " Paolo Bonzini
2018-01-18 14:37 ` Eduardo Habkost
2018-01-18 14:37 ` [Qemu-devel] " Eduardo Habkost
2018-01-18 14:44 ` Paolo Bonzini
2018-01-18 14:44 ` [Qemu-devel] " Paolo Bonzini
2018-01-18 16:52 ` Eduardo Habkost
2018-01-18 16:52 ` [Qemu-devel] " Eduardo Habkost
2018-01-18 16:53 ` Paolo Bonzini
2018-01-18 16:53 ` [Qemu-devel] " Paolo Bonzini
2018-01-22 10:36 ` Kang, Luwei
2018-01-22 10:36 ` [Qemu-devel] " Kang, Luwei
2018-01-26 9:19 ` Paolo Bonzini
2018-01-26 9:19 ` [Qemu-devel] " Paolo Bonzini
2018-01-22 10:45 ` Kang, Luwei
2018-01-22 10:45 ` [Qemu-devel] " Kang, Luwei
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=20180112142252.GG6646@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=luwei.kang@intel.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.