All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-i386: Support migratable=no properly
@ 2014-08-20 20:30 Eduardo Habkost
  2014-08-21 20:14 ` Eduardo Habkost
  0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2014-08-20 20:30 UTC (permalink / raw)
  To: qemu-stable, Andreas Färber
  Cc: Igor Mammedov, Marcelo Tosatti, Paolo Bonzini

When the "migratable" property was implemented, the behavior was tested
by changing the default on the code, but actually using the option on
the command-line (e.g. "-cpu host,migratable=false") doesn't work as
expected. This is a regression for a common use case of "-cpu host",
which is to enable features that are supported by the host CPU + kernel
before feature-specific code is added to QEMU.

Fix this by initializing the feature words for "-cpu host" on
x86_cpu_parse_featurestr(), right after parsing the CPU options.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
I was considering a more complex (but less hacky) fix, by introducing an
enum FeatureBit { OFF, ON, HOST }, making FeatureWord a 32-element
FeatureBit array, and initializing the actual feature bits on
x86_cpu_realizefn(). But as this is a patch for qemu-stable, I kept the
fix as simple as possible.
---
 target-i386/cpu-qom.h |  1 +
 target-i386/cpu.c     | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 71a1b97..7755466 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -92,6 +92,7 @@ typedef struct X86CPU {
     bool enforce_cpuid;
     bool expose_kvm;
     bool migratable;
+    bool host_features;
 
     /* if true the CPUID code directly forward host cache leaves to the guest */
     bool cache_info_passthrough;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6d008ab..c0f8efc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1318,18 +1318,18 @@ static void host_x86_cpu_initfn(Object *obj)
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
     KVMState *s = kvm_state;
-    FeatureWord w;
 
     assert(kvm_enabled());
 
+    /* We can't fill the features array here because we don't know yet if
+     * "migratable" is true or false.
+     */
+    cpu->host_features = true;
+
     env->cpuid_level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
     env->cpuid_xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
     env->cpuid_xlevel2 = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
 
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        env->features[w] =
-            x86_cpu_get_supported_feature_word(w, cpu->migratable);
-    }
     object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
 }
 
@@ -1828,6 +1828,13 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
         featurestr = strtok(NULL, ",");
     }
 
+    if (cpu->host_features) {
+        for (w = 0; w < FEATURE_WORDS; w++) {
+            env->features[w] =
+                x86_cpu_get_supported_feature_word(w, cpu->migratable);
+        }
+    }
+
     for (w = 0; w < FEATURE_WORDS; w++) {
         env->features[w] |= plus_features[w];
         env->features[w] &= ~minus_features[w];
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] target-i386: Support migratable=no properly
  2014-08-20 20:30 [Qemu-devel] [PATCH] target-i386: Support migratable=no properly Eduardo Habkost
@ 2014-08-21 20:14 ` Eduardo Habkost
  2014-09-02 15:08   ` [Qemu-devel] [Qemu-stable] " Michael Roth
  0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2014-08-21 20:14 UTC (permalink / raw)
  To: qemu-devel, qemu-stable, Andreas Färber
  Cc: Igor Mammedov, Marcelo Tosatti, Paolo Bonzini

Forgot to add qemu-devel to "To:". Adding it.

On Wed, Aug 20, 2014 at 05:30:12PM -0300, Eduardo Habkost wrote:
> When the "migratable" property was implemented, the behavior was tested
> by changing the default on the code, but actually using the option on
> the command-line (e.g. "-cpu host,migratable=false") doesn't work as
> expected. This is a regression for a common use case of "-cpu host",
> which is to enable features that are supported by the host CPU + kernel
> before feature-specific code is added to QEMU.
> 
> Fix this by initializing the feature words for "-cpu host" on
> x86_cpu_parse_featurestr(), right after parsing the CPU options.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> I was considering a more complex (but less hacky) fix, by introducing an
> enum FeatureBit { OFF, ON, HOST }, making FeatureWord a 32-element
> FeatureBit array, and initializing the actual feature bits on
> x86_cpu_realizefn(). But as this is a patch for qemu-stable, I kept the
> fix as simple as possible.
> ---
>  target-i386/cpu-qom.h |  1 +
>  target-i386/cpu.c     | 17 ++++++++++++-----
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
> index 71a1b97..7755466 100644
> --- a/target-i386/cpu-qom.h
> +++ b/target-i386/cpu-qom.h
> @@ -92,6 +92,7 @@ typedef struct X86CPU {
>      bool enforce_cpuid;
>      bool expose_kvm;
>      bool migratable;
> +    bool host_features;
>  
>      /* if true the CPUID code directly forward host cache leaves to the guest */
>      bool cache_info_passthrough;
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 6d008ab..c0f8efc 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1318,18 +1318,18 @@ static void host_x86_cpu_initfn(Object *obj)
>      X86CPU *cpu = X86_CPU(obj);
>      CPUX86State *env = &cpu->env;
>      KVMState *s = kvm_state;
> -    FeatureWord w;
>  
>      assert(kvm_enabled());
>  
> +    /* We can't fill the features array here because we don't know yet if
> +     * "migratable" is true or false.
> +     */
> +    cpu->host_features = true;
> +
>      env->cpuid_level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
>      env->cpuid_xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
>      env->cpuid_xlevel2 = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
>  
> -    for (w = 0; w < FEATURE_WORDS; w++) {
> -        env->features[w] =
> -            x86_cpu_get_supported_feature_word(w, cpu->migratable);
> -    }
>      object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
>  }
>  
> @@ -1828,6 +1828,13 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
>          featurestr = strtok(NULL, ",");
>      }
>  
> +    if (cpu->host_features) {
> +        for (w = 0; w < FEATURE_WORDS; w++) {
> +            env->features[w] =
> +                x86_cpu_get_supported_feature_word(w, cpu->migratable);
> +        }
> +    }
> +
>      for (w = 0; w < FEATURE_WORDS; w++) {
>          env->features[w] |= plus_features[w];
>          env->features[w] &= ~minus_features[w];
> -- 
> 1.9.3
> 

-- 
Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-stable] [PATCH] target-i386: Support migratable=no properly
  2014-08-21 20:14 ` Eduardo Habkost
@ 2014-09-02 15:08   ` Michael Roth
  2014-09-04 15:19     ` Eduardo Habkost
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Roth @ 2014-09-02 15:08 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel, qemu-stable, Andreas Färber
  Cc: Igor Mammedov, Marcelo Tosatti, Paolo Bonzini

Quoting Eduardo Habkost (2014-08-21 15:14:38)
> Forgot to add qemu-devel to "To:". Adding it.
> 
> On Wed, Aug 20, 2014 at 05:30:12PM -0300, Eduardo Habkost wrote:
> > When the "migratable" property was implemented, the behavior was tested
> > by changing the default on the code, but actually using the option on
> > the command-line (e.g. "-cpu host,migratable=false") doesn't work as
> > expected. This is a regression for a common use case of "-cpu host",
> > which is to enable features that are supported by the host CPU + kernel
> > before feature-specific code is added to QEMU.
> > 
> > Fix this by initializing the feature words for "-cpu host" on
> > x86_cpu_parse_featurestr(), right after parsing the CPU options.
> > 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Ping for stable 2.1.1, freeze is Wednesday.

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> > ---
> > I was considering a more complex (but less hacky) fix, by introducing an
> > enum FeatureBit { OFF, ON, HOST }, making FeatureWord a 32-element
> > FeatureBit array, and initializing the actual feature bits on
> > x86_cpu_realizefn(). But as this is a patch for qemu-stable, I kept the
> > fix as simple as possible.
> > ---
> >  target-i386/cpu-qom.h |  1 +
> >  target-i386/cpu.c     | 17 ++++++++++++-----
> >  2 files changed, 13 insertions(+), 5 deletions(-)
> > 
> > diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
> > index 71a1b97..7755466 100644
> > --- a/target-i386/cpu-qom.h
> > +++ b/target-i386/cpu-qom.h
> > @@ -92,6 +92,7 @@ typedef struct X86CPU {
> >      bool enforce_cpuid;
> >      bool expose_kvm;
> >      bool migratable;
> > +    bool host_features;
> >  
> >      /* if true the CPUID code directly forward host cache leaves to the guest */
> >      bool cache_info_passthrough;
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 6d008ab..c0f8efc 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -1318,18 +1318,18 @@ static void host_x86_cpu_initfn(Object *obj)
> >      X86CPU *cpu = X86_CPU(obj);
> >      CPUX86State *env = &cpu->env;
> >      KVMState *s = kvm_state;
> > -    FeatureWord w;
> >  
> >      assert(kvm_enabled());
> >  
> > +    /* We can't fill the features array here because we don't know yet if
> > +     * "migratable" is true or false.
> > +     */
> > +    cpu->host_features = true;
> > +
> >      env->cpuid_level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
> >      env->cpuid_xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
> >      env->cpuid_xlevel2 = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
> >  
> > -    for (w = 0; w < FEATURE_WORDS; w++) {
> > -        env->features[w] =
> > -            x86_cpu_get_supported_feature_word(w, cpu->migratable);
> > -    }
> >      object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
> >  }
> >  
> > @@ -1828,6 +1828,13 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
> >          featurestr = strtok(NULL, ",");
> >      }
> >  
> > +    if (cpu->host_features) {
> > +        for (w = 0; w < FEATURE_WORDS; w++) {
> > +            env->features[w] =
> > +                x86_cpu_get_supported_feature_word(w, cpu->migratable);
> > +        }
> > +    }
> > +
> >      for (w = 0; w < FEATURE_WORDS; w++) {
> >          env->features[w] |= plus_features[w];
> >          env->features[w] &= ~minus_features[w];
> > -- 
> > 1.9.3
> > 
> 
> -- 
> Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-stable] [PATCH] target-i386: Support migratable=no properly
  2014-09-02 15:08   ` [Qemu-devel] [Qemu-stable] " Michael Roth
@ 2014-09-04 15:19     ` Eduardo Habkost
  2014-09-04 15:50       ` Andreas Färber
  0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2014-09-04 15:19 UTC (permalink / raw)
  To: Michael Roth
  Cc: Marcelo Tosatti, qemu-devel, qemu-stable, Paolo Bonzini,
	Igor Mammedov, Andreas Färber

On Tue, Sep 02, 2014 at 10:08:56AM -0500, Michael Roth wrote:
> Quoting Eduardo Habkost (2014-08-21 15:14:38)
> > Forgot to add qemu-devel to "To:". Adding it.
> > 
> > On Wed, Aug 20, 2014 at 05:30:12PM -0300, Eduardo Habkost wrote:
> > > When the "migratable" property was implemented, the behavior was tested
> > > by changing the default on the code, but actually using the option on
> > > the command-line (e.g. "-cpu host,migratable=false") doesn't work as
> > > expected. This is a regression for a common use case of "-cpu host",
> > > which is to enable features that are supported by the host CPU + kernel
> > > before feature-specific code is added to QEMU.
> > > 
> > > Fix this by initializing the feature words for "-cpu host" on
> > > x86_cpu_parse_featurestr(), right after parsing the CPU options.
> > > 
> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> Ping for stable 2.1.1, freeze is Wednesday.
> 
> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Ping? Who can help me get this applied?

I was expecting to need to argue to get this considered as -stable
material, but not to have trouble getting it applied to master...

-- 
Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-stable] [PATCH] target-i386: Support migratable=no properly
  2014-09-04 15:19     ` Eduardo Habkost
@ 2014-09-04 15:50       ` Andreas Färber
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2014-09-04 15:50 UTC (permalink / raw)
  To: Eduardo Habkost, Michael Roth
  Cc: Paolo Bonzini, Igor Mammedov, Marcelo Tosatti, qemu-devel, qemu-stable

Am 04.09.2014 17:19, schrieb Eduardo Habkost:
> On Tue, Sep 02, 2014 at 10:08:56AM -0500, Michael Roth wrote:
>> Quoting Eduardo Habkost (2014-08-21 15:14:38)
>>> Forgot to add qemu-devel to "To:". Adding it.
>>>
>>> On Wed, Aug 20, 2014 at 05:30:12PM -0300, Eduardo Habkost wrote:
>>>> When the "migratable" property was implemented, the behavior was tested
>>>> by changing the default on the code, but actually using the option on
>>>> the command-line (e.g. "-cpu host,migratable=false") doesn't work as
>>>> expected. This is a regression for a common use case of "-cpu host",
>>>> which is to enable features that are supported by the host CPU + kernel
>>>> before feature-specific code is added to QEMU.
>>>>
>>>> Fix this by initializing the feature words for "-cpu host" on
>>>> x86_cpu_parse_featurestr(), right after parsing the CPU options.
>>>>
>>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>
>> Ping for stable 2.1.1, freeze is Wednesday.
>>
>> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> 
> Ping? Who can help me get this applied?
> 
> I was expecting to need to argue to get this considered as -stable
> material, but not to have trouble getting it applied to master...

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-04 15:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 20:30 [Qemu-devel] [PATCH] target-i386: Support migratable=no properly Eduardo Habkost
2014-08-21 20:14 ` Eduardo Habkost
2014-09-02 15:08   ` [Qemu-devel] [Qemu-stable] " Michael Roth
2014-09-04 15:19     ` Eduardo Habkost
2014-09-04 15:50       ` Andreas Färber

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.