Patchwork [11/37] target-i386: introduce vendor-override static property

login
register
mail settings
Submitter Igor Mammedov
Date Oct. 22, 2012, 3:02 p.m.
Message ID <1350918203-25198-12-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/193241/
State New
Headers show

Comments

Igor Mammedov - Oct. 22, 2012, 3:02 p.m.
currently 'cpuid_vendor_override' can be set only via cmd line cpu_model
string. But setting it in 'vendor' property prevents using 'vendor'
property on its own without setting cpuid_vendor_override.

So fix/remove enabling cpuid_vendor_override from "vendor" property setter.
It's up-to cpu_model string parser to maintain legacy behavior when user
overrides vendor on command line.

  - cpuid_vendor_override is converted to uint32_t so it could be used with
    DEFINE_PROP_BIT()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 6 ++++--
 target-i386/cpu.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4bbfe9b..fa974e7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -218,6 +218,7 @@  static Property cpu_x86_properties[] = {
     DEFINE_PROP_BIT("f-pfthreshold", X86CPU, env.cpuid_svm_features, 12, false),
     DEFINE_PROP_BIT("f-smep", X86CPU, env.cpuid_7_0_ebx_features,  7, false),
     DEFINE_PROP_BIT("f-smap", X86CPU, env.cpuid_7_0_ebx_features, 20, false),
+    DEFINE_PROP_BIT("vendor-override", X86CPU, env.cpuid_vendor_override, 0, false),
     DEFINE_PROP_END_OF_LIST(),
  };
 
@@ -1136,7 +1137,6 @@  static void x86_cpuid_set_vendor(Object *obj, const char *value,
         env->cpuid_vendor2 |= ((uint8_t)value[i + 4]) << (8 * i);
         env->cpuid_vendor3 |= ((uint8_t)value[i + 8]) << (8 * i);
     }
-    env->cpuid_vendor_override = 1;
 }
 
 static char *x86_cpuid_get_model_id(Object *obj, Error **errp)
@@ -1220,7 +1220,9 @@  static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp)
         env->cpuid_vendor2 = CPUID_VENDOR_INTEL_2;
         env->cpuid_vendor3 = CPUID_VENDOR_INTEL_3;
     }
-    env->cpuid_vendor_override = def->vendor_override;
+    if (def->vendor_override) {
+        object_property_set_bool(OBJECT(cpu), true, "vendor-override", errp);
+    }
     object_property_set_int(OBJECT(cpu), def->level, "level", errp);
     object_property_set_int(OBJECT(cpu), def->family, "family", errp);
     object_property_set_int(OBJECT(cpu), def->model, "model", errp);
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 7903413..69f8691 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -788,7 +788,7 @@  typedef struct CPUX86State {
     uint32_t cpuid_ext2_features;
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
-    int cpuid_vendor_override;
+    uint32_t cpuid_vendor_override;
     /* Store the results of Centaur's CPUID instructions */
     uint32_t cpuid_xlevel2;
     uint32_t cpuid_ext4_features;