qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: "Kang, Luwei" <luwei.kang@intel.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"rth@twiddle.net" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] i386: extended the cpuid level when Intel PT is enabled
Date: Sat, 26 Jan 2019 00:51:29 -0200	[thread overview]
Message-ID: <20190126025129.GN4136@habkost.net> (raw)
In-Reply-To: <82D7661F83C1A047AF7DC287873BF1E172CCDB7C@SHSMSX101.ccr.corp.intel.com>

On Fri, Jan 25, 2019 at 02:21:20AM +0000, Kang, Luwei wrote:
> > > Intel Processor Trace required CPUID[0x14] but the cpuid level is 0xd
> > > when create a kvm guest with e.g. "-cpu qemu64,+intel-pt".
> > >
> > > Signed-off-by: Luwei Kang <luwei.kang@intel.com>
> > > ---
> > >  target/i386/cpu.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c index
> > > 2f54125..da477b3 100644
> > > --- a/target/i386/cpu.c
> > > +++ b/target/i386/cpu.c
> > > @@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
> > >          x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX);
> > >          x86_cpu_adjust_feat_level(cpu, FEAT_SVM);
> > >          x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE);
> > > +
> > > +        /* Intel Processor Trace requires CPUID[0x14] */
> > > +        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
> > > +             kvm_enabled()) {
> > > +            x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
> > > +        }
> > 
> > This will require a new machine-type compatibility flag to enable the new behavior, so we don't change CPUID data under the guest feet during live migration.
> 
> Hi Eduardo,
>     Thanks for your reply. I have some question on your comments.
>     The cpuid level come from specific machine-type (e.g. qemu64, Skylake-Server) and they are all 0xd, but Intel PT required 0x14 so I extend the cpuid level.
>     I don't fully understand what is the "require a new machine-type compatibility flag" mean, I need to add a new flag in each machine-type? 
>     I try to do live migration with "-cpu qemu64,+intel-pt" and "-cpu host" are all passed test. We didn't change the cpuid data during live migration just initialize the cpuid data when create a new vcpu. Please correct me if anything wrong.

CPUID data is not sent as part of the migration stream (it is
recreated on the migration destination), so if "-cpu qemu,+intel-pt"
results in different CPUID data, migration between QEMU 4.0 and
3.1 will make CPUID level change during live migration.

This is not a serious issue, but it might confuse software
running on the guest.

We can fix that doing this:

target/i386/cpu.c:

static Property x86_cpu_properties[] = {
    ...
    DEFINE_PROP_BOOL("x-intel-pt-auto-level", X86CPU, intel_pt_auto_level, true),
    ....
}
...
static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
{
    ...
        /* Intel Processor Trace requires CPUID[0x14] */
        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && cpu->intel_pt_auto_level) {
            x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
        }
    ...
}

hw/i386/pc.c:

GlobalProperty pc_compat_3_1[] = {
    ...
    { TYPE_X86_CPU, "x-intel-pt-auto-leevl", "off" },
};

> Thanks,
> Luwei Kang
> 
> > 
> > > +
> > >          /* SVM requires CPUID[0x8000000A] */
> > >          if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) {
> > >              x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel,
> > > 0x8000000A);
> > > --
> > > 1.8.3.1
> > >
> > 
> > --
> > Eduardo

-- 
Eduardo

  reply	other threads:[~2019-01-26  2:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25  1:54 [Qemu-devel] [PATCH] i386: extended the cpuid level when Intel PT is enabled Luwei Kang
2019-01-24 18:39 ` Eduardo Habkost
2019-01-25  2:21   ` Kang, Luwei
2019-01-26  2:51     ` Eduardo Habkost [this message]
2019-01-28  6:06       ` Kang, Luwei
2019-01-28 18:03         ` Eduardo Habkost
2019-01-29  0:29           ` 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=20190126025129.GN4136@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=luwei.kang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).