diff mbox

[1/3] target-i386: Make kvm_default_features an array

Message ID 1392821892-26682-2-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Feb. 19, 2014, 2:58 p.m. UTC
We will later make the KVM-specific code affect other feature words,
too.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Comments

Igor Mammedov Feb. 19, 2014, 4:38 p.m. UTC | #1
On Wed, 19 Feb 2014 11:58:10 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> We will later make the KVM-specific code affect other feature words,
> too.
patch doesn't apply to current master, is there dependencies on list?

> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  target-i386/cpu.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 5a530b5..ee9dff1 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -358,17 +358,22 @@ typedef struct model_features_t {
>      FeatureWord feat_word;
>  } model_features_t;
>  
> -static uint32_t kvm_default_features = (1 << KVM_FEATURE_CLOCKSOURCE) |
> +/* KVM-specific features that are automatically added to all CPU models
> + * when KVM is enabled.
> + */
> +static uint32_t kvm_default_features[FEATURE_WORDS] = {
> +    [FEAT_KVM] = (1 << KVM_FEATURE_CLOCKSOURCE) |
>          (1 << KVM_FEATURE_NOP_IO_DELAY) |
>          (1 << KVM_FEATURE_CLOCKSOURCE2) |
>          (1 << KVM_FEATURE_ASYNC_PF) |
>          (1 << KVM_FEATURE_STEAL_TIME) |
>          (1 << KVM_FEATURE_PV_EOI) |
> -        (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT);
> +        (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT),
> +};
>  
>  void disable_kvm_pv_eoi(void)
>  {
> -    kvm_default_features &= ~(1UL << KVM_FEATURE_PV_EOI);
> +    kvm_default_features[FEAT_KVM] &= ~(1UL << KVM_FEATURE_PV_EOI);
>  }
>  
>  void host_cpuid(uint32_t function, uint32_t count,
> @@ -1851,8 +1856,12 @@ static void x86_cpu_load_def(X86CPU *cpu, const char *name, Error **errp)
>  
>      /* Special cases not set in the X86CPUDefinition structs: */
>      if (kvm_enabled()) {
> -        env->features[FEAT_KVM] |= kvm_default_features;
> +        FeatureWord w;
> +        for (w = 0; w < FEATURE_WORDS; w++) {
> +            env->features[w] |= kvm_default_features[w];
> +        }
>      }
> +
>      env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
>  
>      /* sysenter isn't supported in compatibility mode on AMD,
Eduardo Habkost Feb. 19, 2014, 4:43 p.m. UTC | #2
On Wed, Feb 19, 2014 at 05:38:28PM +0100, Igor Mammedov wrote:
> On Wed, 19 Feb 2014 11:58:10 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > We will later make the KVM-specific code affect other feature words,
> > too.
> patch doesn't apply to current master, is there dependencies on list?

It is against the qom-cpu tree. I forgot to add it to Subject, sorry.

Git tree at:
https://github.com/ehabkost/qemu/tree/work/x2apic-kvm-only
diff mbox

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 5a530b5..ee9dff1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -358,17 +358,22 @@  typedef struct model_features_t {
     FeatureWord feat_word;
 } model_features_t;
 
-static uint32_t kvm_default_features = (1 << KVM_FEATURE_CLOCKSOURCE) |
+/* KVM-specific features that are automatically added to all CPU models
+ * when KVM is enabled.
+ */
+static uint32_t kvm_default_features[FEATURE_WORDS] = {
+    [FEAT_KVM] = (1 << KVM_FEATURE_CLOCKSOURCE) |
         (1 << KVM_FEATURE_NOP_IO_DELAY) |
         (1 << KVM_FEATURE_CLOCKSOURCE2) |
         (1 << KVM_FEATURE_ASYNC_PF) |
         (1 << KVM_FEATURE_STEAL_TIME) |
         (1 << KVM_FEATURE_PV_EOI) |
-        (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT);
+        (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT),
+};
 
 void disable_kvm_pv_eoi(void)
 {
-    kvm_default_features &= ~(1UL << KVM_FEATURE_PV_EOI);
+    kvm_default_features[FEAT_KVM] &= ~(1UL << KVM_FEATURE_PV_EOI);
 }
 
 void host_cpuid(uint32_t function, uint32_t count,
@@ -1851,8 +1856,12 @@  static void x86_cpu_load_def(X86CPU *cpu, const char *name, Error **errp)
 
     /* Special cases not set in the X86CPUDefinition structs: */
     if (kvm_enabled()) {
-        env->features[FEAT_KVM] |= kvm_default_features;
+        FeatureWord w;
+        for (w = 0; w < FEATURE_WORDS; w++) {
+            env->features[w] |= kvm_default_features[w];
+        }
     }
+
     env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
 
     /* sysenter isn't supported in compatibility mode on AMD,