All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
@ 2013-07-15 22:25 Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 01/20] target-i386: Move hyperv_* static globals to X86CPU Igor Mammedov
                   ` (30 more replies)
  0 siblings, 31 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

It's reordered and rebased v8 plus CPUID feature bits conversion to properties
and cleanups that are removing unused anymore *_feature_name arrays.

dynamic => static properties conversion is still making sense as cleanup of
initfn(), consolidating all properties in one place and making uniform
property setters signatures, so it was kept.

hyperv and dynamic => static properties conversion are covered by virt-test's
qemu_cpu test group.

On top of that, CPUID feature bits conversion and cleanups it's allowed.

git for testing: https://github.com/imammedo/qemu/tree/x86-cpu-properties.v9

v8-v9:
* reorder hyperv/check/force and cpu_x86_parse_featurestr() cleanups to be the first
* when converting dynamic properties inline custom DEFINE_PROP_FOO directly in
  cpu_x86_properties property array. (req: afaerber)
* change "f-" CPUID feature bits prefix to "feat-" (req: afaerber)
* replace F_* macros with a single X86CPU_FEAT() macro and simplify it setting
default value to 0, intended for defaults to be set by initfn()
* kvmclock: fix endless loop on compat kvmclock2 append
* converted check_features_against_host() and x86_cpu_list() to use
  static properties definition for feature name lookups, removing along the way
  unused anymore *_feature_name arrays.

v7-v8:
* split out dynamic properties convertion patch into per property patches
  to simplify review
* drop feature bits convertion

v6-v7:
* convert globals check_cpuid, enforce_cpuid and  hyperv_* to fields of
  CPUState
* Make PropertyInfo-s static
* maintain legacy kvmclock semantic in cpu_x86_parse_featurestr()
* existing properties code are not moved around, just fixed signatures where
  it's needed and used visitors.

v5-v6:
* when converting feature names to property names, replace '_' with '-'
* separate patches converting existing dynamic properties into one, were
  squashed into one [1/9] and change tested with virt-test(next).
* patches that were touching +-foo features are squashed into one [9/9],
  to avoid behavior change between them(f-kvmclock property).
* the rest of conversions were basicaly rebased on top of current qom-cpu-next
  tree, with small corrections

Igor Mammedov (20):
  target-i386: Move hyperv_* static globals to X86CPU
  target-i386: convert 'hv_spinlocks' to static property
  target-i386: convert 'hv_relaxed' to static property
  target-i386: convert 'hv_vapic' to static property
  target-i386: convert 'check' and 'enforce' to static properties
  target-i386: cleanup 'foo' feature handling'
  target-i386: cleanup 'foo=val' feature handling
  target-i386: cpu: convert 'level' to static property
  target-i386: cpu: convert 'xlevel' to static property
  target-i386: cpu: convert 'family' to static property
  target-i386: cpu: convert 'model' to static property
  target-i386: cpu: convert 'stepping' to static property
  target-i386: cpu: convert 'vendor' to static property
  target-i386: cpu: convert 'model-id' to static property
  target-i386: cpu: convert 'tsc-frequency' to static property
  target-i386: set [+-]feature using static properties
  qdev: introduce qdev_prop_find_bit()
  target-i386: use static properties in check_features_against_host() to
    print CPUID feature names
  target-i386: use static properties to list CPUID features
  target-i386: remove unused *_feature_name arrays

 hw/core/qdev-properties.c    |  15 +
 include/hw/qdev-properties.h |  13 +
 target-i386/Makefile.objs    |   2 +-
 target-i386/cpu-qom.h        |   6 +
 target-i386/cpu.c            | 705 +++++++++++++++++++++----------------------
 target-i386/cpu.h            |   4 +
 target-i386/hyperv.c         |  64 ----
 target-i386/hyperv.h         |  45 ---
 target-i386/kvm.c            |  36 ++-
 9 files changed, 415 insertions(+), 475 deletions(-)
 delete mode 100644 target-i386/hyperv.c
 delete mode 100644 target-i386/hyperv.h

-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 01/20] target-i386: Move hyperv_* static globals to X86CPU
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property Igor Mammedov
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

- since hyperv_* helper functions are used only in target-i386/kvm.c
  move them there as static helpers

Requested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Vadim Rozenfeld <vrozenfe@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/Makefile.objs |  2 +-
 target-i386/cpu-qom.h     |  4 +++
 target-i386/cpu.c         | 16 ++++++++----
 target-i386/cpu.h         |  4 +++
 target-i386/hyperv.c      | 64 -----------------------------------------------
 target-i386/hyperv.h      | 45 ---------------------------------
 target-i386/kvm.c         | 36 ++++++++++++++++++--------
 7 files changed, 46 insertions(+), 125 deletions(-)
 delete mode 100644 target-i386/hyperv.c
 delete mode 100644 target-i386/hyperv.h

diff --git a/target-i386/Makefile.objs b/target-i386/Makefile.objs
index c1d4f05..887dca7 100644
--- a/target-i386/Makefile.objs
+++ b/target-i386/Makefile.objs
@@ -2,7 +2,7 @@ obj-y += translate.o helper.o cpu.o
 obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
 obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
-obj-$(CONFIG_KVM) += kvm.o hyperv.o
+obj-$(CONFIG_KVM) += kvm.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-$(CONFIG_LINUX_USER) += ioport-user.o
 obj-$(CONFIG_BSD_USER) += ioport-user.o
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 7e55e5f..18f08b8 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -66,6 +66,10 @@ typedef struct X86CPU {
 
     CPUX86State env;
 
+    bool hyperv_vapic;
+    bool hyperv_relaxed_timing;
+    int hyperv_spinlock_attempts;
+
     /* Features that were filtered out because of missing host capabilities */
     uint32_t filtered_features[FEATURE_WORDS];
 } X86CPU;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e3f75a8..14e9c7e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -35,8 +35,6 @@
 #include "qapi/visitor.h"
 #include "sysemu/arch_init.h"
 
-#include "hyperv.h"
-
 #include "hw/hw.h"
 #if defined(CONFIG_KVM)
 #include <linux/kvm_para.h>
@@ -1587,12 +1585,19 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 object_property_parse(OBJECT(cpu), num, "tsc-frequency", errp);
             } else if (!strcmp(featurestr, "hv-spinlocks")) {
                 char *err;
+                const int min = 0xFFF;
                 numvalue = strtoul(val, &err, 0);
                 if (!*val || *err) {
                     error_setg(errp, "bad numerical value %s", val);
                     goto out;
                 }
-                hyperv_set_spinlock_retries(numvalue);
+                if (numvalue < min) {
+                    fprintf(stderr, "hv-spinlocks value shall always be >= 0x%x"
+                            ", fixup will be removed in future versions\n",
+                            min);
+                    numvalue = min;
+                }
+                cpu->hyperv_spinlock_attempts = numvalue;
             } else {
                 error_setg(errp, "unrecognized feature %s", featurestr);
                 goto out;
@@ -1602,9 +1607,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         } else if (!strcmp(featurestr, "enforce")) {
             check_cpuid = enforce_cpuid = 1;
         } else if (!strcmp(featurestr, "hv_relaxed")) {
-            hyperv_enable_relaxed_timing(true);
+            cpu->hyperv_relaxed_timing = true;
         } else if (!strcmp(featurestr, "hv_vapic")) {
-            hyperv_enable_vapic_recommended(true);
+            cpu->hyperv_vapic = true;
         } else {
             error_setg(errp, "feature string `%s' not in format (+feature|"
                        "-feature|feature=xyz)", featurestr);
@@ -2479,6 +2484,7 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features, NULL);
 
+    cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
     env->cpuid_apic_id = x86_cpu_apic_id_from_index(cs->cpu_index);
 
     /* init various static tables used in TCG mode */
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 2d005b3..6c3eb86 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -549,6 +549,10 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */
 
+#ifndef HYPERV_SPINLOCK_NEVER_RETRY
+#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
+#endif
+
 #define EXCP00_DIVZ	0
 #define EXCP01_DB	1
 #define EXCP02_NMI	2
diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c
deleted file mode 100644
index f284e99..0000000
--- a/target-i386/hyperv.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * QEMU Hyper-V support
- *
- * Copyright Red Hat, Inc. 2011
- *
- * Author: Vadim Rozenfeld     <vrozenfe@redhat.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "hyperv.h"
-
-static bool hyperv_vapic;
-static bool hyperv_relaxed_timing;
-static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
-
-void hyperv_enable_vapic_recommended(bool val)
-{
-    hyperv_vapic = val;
-}
-
-void hyperv_enable_relaxed_timing(bool val)
-{
-    hyperv_relaxed_timing = val;
-}
-
-void hyperv_set_spinlock_retries(int val)
-{
-    hyperv_spinlock_attempts = val;
-    if (hyperv_spinlock_attempts < 0xFFF) {
-        hyperv_spinlock_attempts = 0xFFF;
-    }
-}
-
-bool hyperv_enabled(void)
-{
-    return hyperv_hypercall_available() || hyperv_relaxed_timing_enabled();
-}
-
-bool hyperv_hypercall_available(void)
-{
-    if (hyperv_vapic ||
-        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
-      return true;
-    }
-    return false;
-}
-
-bool hyperv_vapic_recommended(void)
-{
-    return hyperv_vapic;
-}
-
-bool hyperv_relaxed_timing_enabled(void)
-{
-    return hyperv_relaxed_timing;
-}
-
-int hyperv_get_spinlock_retries(void)
-{
-    return hyperv_spinlock_attempts;
-}
diff --git a/target-i386/hyperv.h b/target-i386/hyperv.h
deleted file mode 100644
index bacb1d4..0000000
--- a/target-i386/hyperv.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * QEMU Hyper-V support
- *
- * Copyright Red Hat, Inc. 2011
- *
- * Author: Vadim Rozenfeld     <vrozenfe@redhat.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef QEMU_HW_HYPERV_H
-#define QEMU_HW_HYPERV_H 1
-
-#include "qemu-common.h"
-#ifdef CONFIG_KVM
-#include <asm/hyperv.h>
-#endif
-
-#ifndef HYPERV_SPINLOCK_NEVER_RETRY
-#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
-#endif
-
-#ifndef KVM_CPUID_SIGNATURE_NEXT
-#define KVM_CPUID_SIGNATURE_NEXT                0x40000100
-#endif
-
-#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_KVM)
-void hyperv_enable_vapic_recommended(bool val);
-void hyperv_enable_relaxed_timing(bool val);
-void hyperv_set_spinlock_retries(int val);
-#else
-static inline void hyperv_enable_vapic_recommended(bool val) { }
-static inline void hyperv_enable_relaxed_timing(bool val) { }
-static inline void hyperv_set_spinlock_retries(int val) { }
-#endif
-
-bool hyperv_enabled(void);
-bool hyperv_hypercall_available(void);
-bool hyperv_vapic_recommended(void);
-bool hyperv_relaxed_timing_enabled(void);
-int hyperv_get_spinlock_retries(void);
-
-#endif /* QEMU_HW_HYPERV_H */
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 8315489..6da8895 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -31,7 +31,7 @@
 #include "hw/i386/pc.h"
 #include "hw/i386/apic.h"
 #include "exec/ioport.h"
-#include "hyperv.h"
+#include <asm/hyperv.h>
 #include "hw/pci/pci.h"
 
 //#define DEBUG_KVM
@@ -420,6 +420,22 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)
     return cpu->env.cpuid_apic_id;
 }
 
+#ifndef KVM_CPUID_SIGNATURE_NEXT
+#define KVM_CPUID_SIGNATURE_NEXT                0x40000100
+#endif
+
+static bool hyperv_hypercall_available(X86CPU *cpu)
+{
+    return cpu->hyperv_vapic ||
+           (cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY);
+}
+
+static bool hyperv_enabled(X86CPU *cpu)
+{
+    return hyperv_hypercall_available(cpu) ||
+           cpu->hyperv_relaxed_timing;
+}
+
 #define KVM_MAX_CPUID_ENTRIES  100
 
 int kvm_arch_init_vcpu(CPUState *cs)
@@ -442,7 +458,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_SIGNATURE;
-    if (!hyperv_enabled()) {
+    if (!hyperv_enabled(cpu)) {
         memcpy(signature, "KVMKVMKVM\0\0\0", 12);
         c->eax = 0;
     } else {
@@ -458,7 +474,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
     c->function = KVM_CPUID_FEATURES;
     c->eax = env->features[FEAT_KVM];
 
-    if (hyperv_enabled()) {
+    if (hyperv_enabled(cpu)) {
         memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
         c->eax = signature[0];
 
@@ -471,10 +487,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
         c = &cpuid_data.entries[cpuid_i++];
         memset(c, 0, sizeof(*c));
         c->function = HYPERV_CPUID_FEATURES;
-        if (hyperv_relaxed_timing_enabled()) {
+        if (cpu->hyperv_relaxed_timing) {
             c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
         }
-        if (hyperv_vapic_recommended()) {
+        if (cpu->hyperv_vapic) {
             c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
             c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
         }
@@ -482,13 +498,13 @@ int kvm_arch_init_vcpu(CPUState *cs)
         c = &cpuid_data.entries[cpuid_i++];
         memset(c, 0, sizeof(*c));
         c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
-        if (hyperv_relaxed_timing_enabled()) {
+        if (cpu->hyperv_relaxed_timing) {
             c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
         }
-        if (hyperv_vapic_recommended()) {
+        if (cpu->hyperv_vapic) {
             c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
         }
-        c->ebx = hyperv_get_spinlock_retries();
+        c->ebx = cpu->hyperv_spinlock_attempts;
 
         c = &cpuid_data.entries[cpuid_i++];
         memset(c, 0, sizeof(*c));
@@ -1114,11 +1130,11 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
             kvm_msr_entry_set(&msrs[n++], MSR_KVM_STEAL_TIME,
                               env->steal_time_msr);
         }
-        if (hyperv_hypercall_available()) {
+        if (hyperv_hypercall_available(cpu)) {
             kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_GUEST_OS_ID, 0);
             kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL, 0);
         }
-        if (hyperv_vapic_recommended()) {
+        if (cpu->hyperv_vapic) {
             kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
         }
     }
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 01/20] target-i386: Move hyperv_* static globals to X86CPU Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-11-27 17:55   ` Andreas Färber
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 03/20] target-i386: convert 'hv_relaxed' " Igor Mammedov
                   ` (28 subsequent siblings)
  30 siblings, 1 reply; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
 - rebase on top of hyperv_spinlock_attempts in X86CPU
---
 target-i386/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 14e9c7e..00c2882 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
     error_propagate(errp, err);
 }
 
+static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    int64_t value = cpu->hyperv_spinlock_attempts;
+
+    visit_type_int(v, &value, name, errp);
+}
+
+static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    const int64_t min = 0xFFF;
+    const int64_t max = UINT_MAX;
+    X86CPU *cpu = X86_CPU(obj);
+    int64_t value;
+
+    visit_type_int(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+
+    if (value < min || value > max) {
+        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
+                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
+                  object_get_typename(obj), name ? name : "null",
+                  value, min, max);
+        return;
+    }
+    cpu->hyperv_spinlock_attempts = value;
+}
+
+static PropertyInfo qdev_prop_spinlocks = {
+    .name  = "int",
+    .get   = x86_get_hv_spinlocks,
+    .set   = x86_set_hv_spinlocks,
+};
+
+static Property cpu_x86_properties[] = {
+    { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
 {
     x86_def_t *def;
@@ -1586,6 +1629,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
             } else if (!strcmp(featurestr, "hv-spinlocks")) {
                 char *err;
                 const int min = 0xFFF;
+                char num[32];
                 numvalue = strtoul(val, &err, 0);
                 if (!*val || *err) {
                     error_setg(errp, "bad numerical value %s", val);
@@ -1597,7 +1641,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                             min);
                     numvalue = min;
                 }
-                cpu->hyperv_spinlock_attempts = numvalue;
+                snprintf(num, sizeof(num), "%" PRId32, numvalue);
+                object_property_parse(OBJECT(cpu), num, featurestr, errp);
             } else {
                 error_setg(errp, "unrecognized feature %s", featurestr);
                 goto out;
@@ -2521,6 +2566,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     xcc->parent_realize = dc->realize;
     dc->realize = x86_cpu_realizefn;
     dc->bus_type = TYPE_ICC_BUS;
+    dc->props = cpu_x86_properties;
 
     xcc->parent_reset = cc->reset;
     cc->reset = x86_cpu_reset;
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 03/20] target-i386: convert 'hv_relaxed' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 01/20] target-i386: Move hyperv_* static globals to X86CPU Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 04/20] target-i386: convert 'hv_vapic' " Igor Mammedov
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
v2:
 - rebase on top of hyperv_relaxed_timing in X86CPU
---
 target-i386/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 00c2882..001c5ff 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1513,6 +1513,7 @@ static PropertyInfo qdev_prop_spinlocks = {
 
 static Property cpu_x86_properties[] = {
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
+    DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1652,7 +1653,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         } else if (!strcmp(featurestr, "enforce")) {
             check_cpuid = enforce_cpuid = 1;
         } else if (!strcmp(featurestr, "hv_relaxed")) {
-            cpu->hyperv_relaxed_timing = true;
+            object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp);
         } else if (!strcmp(featurestr, "hv_vapic")) {
             cpu->hyperv_vapic = true;
         } else {
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 04/20] target-i386: convert 'hv_vapic' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (2 preceding siblings ...)
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 03/20] target-i386: convert 'hv_relaxed' " Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 05/20] target-i386: convert 'check' and 'enforce' to static properties Igor Mammedov
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
 - rebase on top of hv_vapic in X86CPU
---
 target-i386/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 001c5ff..3013722 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1514,6 +1514,7 @@ static PropertyInfo qdev_prop_spinlocks = {
 static Property cpu_x86_properties[] = {
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
+    DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1655,7 +1656,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         } else if (!strcmp(featurestr, "hv_relaxed")) {
             object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp);
         } else if (!strcmp(featurestr, "hv_vapic")) {
-            cpu->hyperv_vapic = true;
+            object_property_parse(OBJECT(cpu), "on", "hv-vapic", errp);
         } else {
             error_setg(errp, "feature string `%s' not in format (+feature|"
                        "-feature|feature=xyz)", featurestr);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 05/20] target-i386: convert 'check' and 'enforce' to static properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (3 preceding siblings ...)
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 04/20] target-i386: convert 'hv_vapic' " Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling' Igor Mammedov
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

* additionally convert check_cpuid & enforce_cpuid to bool and make them
  members of CPUX86State
* make 'enforce' feature independent from 'check'

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - put check_cpuid and enforce_cpuid into X86CPU
---
 target-i386/cpu-qom.h |  2 ++
 target-i386/cpu.c     | 13 ++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 18f08b8..302fa2e 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -69,6 +69,8 @@ typedef struct X86CPU {
     bool hyperv_vapic;
     bool hyperv_relaxed_timing;
     int hyperv_spinlock_attempts;
+    bool check_cpuid;
+    bool enforce_cpuid;
 
     /* Features that were filtered out because of missing host capabilities */
     uint32_t filtered_features[FEATURE_WORDS];
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3013722..56333db 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -233,9 +233,6 @@ typedef struct model_features_t {
     FeatureWord feat_word;
 } model_features_t;
 
-int check_cpuid = 0;
-int enforce_cpuid = 0;
-
 static uint32_t kvm_default_features = (1 << KVM_FEATURE_CLOCKSOURCE) |
         (1 << KVM_FEATURE_NOP_IO_DELAY) |
         (1 << KVM_FEATURE_CLOCKSOURCE2) |
@@ -1515,6 +1512,8 @@ static Property cpu_x86_properties[] = {
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
     DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false),
+    DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
+    DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1650,9 +1649,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 goto out;
             }
         } else if (!strcmp(featurestr, "check")) {
-            check_cpuid = 1;
+            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
         } else if (!strcmp(featurestr, "enforce")) {
-            check_cpuid = enforce_cpuid = 1;
+            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
         } else if (!strcmp(featurestr, "hv_relaxed")) {
             object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp);
         } else if (!strcmp(featurestr, "hv_vapic")) {
@@ -2416,8 +2415,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES;
         env->features[FEAT_SVM] &= TCG_SVM_FEATURES;
     } else {
-        if (check_cpuid && kvm_check_features_against_host(cpu)
-            && enforce_cpuid) {
+        if ((cpu->check_cpuid || cpu->enforce_cpuid)
+            && kvm_check_features_against_host(cpu) && cpu->enforce_cpuid) {
             error_setg(&local_err,
                        "Host's CPU doesn't support requested features");
             goto out;
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling'
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (4 preceding siblings ...)
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 05/20] target-i386: convert 'check' and 'enforce' to static properties Igor Mammedov
@ 2013-07-15 22:25 ` Igor Mammedov
  2013-12-16 16:51   ` Eric Blake
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 07/20] target-i386: cleanup 'foo=val' feature handling Igor Mammedov
                   ` (24 subsequent siblings)
  30 siblings, 1 reply; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

features check, enforce, hv_relaxed and hv_vapic are treated as boolean set to 'on'
when passed from command line, so it's not neccessary to handle each of them
separetly. Collapse them to one catch-all branch which will treat
any feature in format 'foo' as boolean set to 'on'.

PS:
Any unknown feature will be rejected by CPU property setter so there is no
need to check for unknown feature in cpu_x86_parse_featurestr(), therefore
it's replaced by above mentioned catch-all handler.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
v2:
  * use feat2prop() to perform name convertion for hv_vapic and hv_relaxed
---
 target-i386/cpu.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 56333db..42c54df 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1648,18 +1648,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 error_setg(errp, "unrecognized feature %s", featurestr);
                 goto out;
             }
-        } else if (!strcmp(featurestr, "check")) {
-            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
-        } else if (!strcmp(featurestr, "enforce")) {
-            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
-        } else if (!strcmp(featurestr, "hv_relaxed")) {
-            object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp);
-        } else if (!strcmp(featurestr, "hv_vapic")) {
-            object_property_parse(OBJECT(cpu), "on", "hv-vapic", errp);
         } else {
-            error_setg(errp, "feature string `%s' not in format (+feature|"
-                       "-feature|feature=xyz)", featurestr);
-            goto out;
+            feat2prop(featurestr);
+            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
         }
         if (error_is_set(errp)) {
             goto out;
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 07/20] target-i386: cleanup 'foo=val' feature handling
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (5 preceding siblings ...)
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling' Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property Igor Mammedov
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

features family, model, stepping, level, hv_spinlocks are treated similarly
when passed from command line, so it's not necessary to handle each of them
individually. Collapse them to one catch-all branch which will treat
any not explicitly handled feature in format 'foo=val'.

PS:
Any unknown feature will be rejected by property setter so there is no
need to check for unknown feature in cpu_x86_parse_featurestr(), therefore
it's replaced by above mentioned catch-all handler.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - style fixes
---
 target-i386/cpu.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 42c54df..edf15ad 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1586,15 +1586,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         } else if ((val = strchr(featurestr, '='))) {
             *val = 0; val++;
             feat2prop(featurestr);
-            if (!strcmp(featurestr, "family")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
-            } else if (!strcmp(featurestr, "model")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
-            } else if (!strcmp(featurestr, "stepping")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
-            } else if (!strcmp(featurestr, "level")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
-            } else if (!strcmp(featurestr, "xlevel")) {
+            if (!strcmp(featurestr, "xlevel")) {
                 char *err;
                 char num[32];
 
@@ -1610,10 +1602,6 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 }
                 snprintf(num, sizeof(num), "%" PRIu32, numvalue);
                 object_property_parse(OBJECT(cpu), num, featurestr, errp);
-            } else if (!strcmp(featurestr, "vendor")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
-            } else if (!strcmp(featurestr, "model-id")) {
-                object_property_parse(OBJECT(cpu), val, featurestr, errp);
             } else if (!strcmp(featurestr, "tsc-freq")) {
                 int64_t tsc_freq;
                 char *err;
@@ -1645,8 +1633,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 snprintf(num, sizeof(num), "%" PRId32, numvalue);
                 object_property_parse(OBJECT(cpu), num, featurestr, errp);
             } else {
-                error_setg(errp, "unrecognized feature %s", featurestr);
-                goto out;
+                object_property_parse(OBJECT(cpu), val, featurestr, errp);
             }
         } else {
             feat2prop(featurestr);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (6 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 07/20] target-i386: cleanup 'foo=val' feature handling Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 09/20] target-i386: cpu: convert 'xlevel' " Igor Mammedov
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index edf15ad..9ca6ab4 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1261,22 +1261,6 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
     env->cpuid_version |= value & 0xf;
 }
 
-static void x86_cpuid_get_level(Object *obj, Visitor *v, void *opaque,
-                                const char *name, Error **errp)
-{
-    X86CPU *cpu = X86_CPU(obj);
-
-    visit_type_uint32(v, &cpu->env.cpuid_level, name, errp);
-}
-
-static void x86_cpuid_set_level(Object *obj, Visitor *v, void *opaque,
-                                const char *name, Error **errp)
-{
-    X86CPU *cpu = X86_CPU(obj);
-
-    visit_type_uint32(v, &cpu->env.cpuid_level, name, errp);
-}
-
 static void x86_cpuid_get_xlevel(Object *obj, Visitor *v, void *opaque,
                                  const char *name, Error **errp)
 {
@@ -1514,6 +1498,7 @@ static Property cpu_x86_properties[] = {
     DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false),
     DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
+    DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2483,9 +2468,6 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "stepping", "int",
                         x86_cpuid_version_get_stepping,
                         x86_cpuid_version_set_stepping, NULL, NULL, NULL);
-    object_property_add(obj, "level", "int",
-                        x86_cpuid_get_level,
-                        x86_cpuid_set_level, NULL, NULL, NULL);
     object_property_add(obj, "xlevel", "int",
                         x86_cpuid_get_xlevel,
                         x86_cpuid_set_xlevel, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 09/20] target-i386: cpu: convert 'xlevel' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (7 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 10/20] target-i386: cpu: convert 'family' " Igor Mammedov
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9ca6ab4..39295ba 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1261,22 +1261,6 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
     env->cpuid_version |= value & 0xf;
 }
 
-static void x86_cpuid_get_xlevel(Object *obj, Visitor *v, void *opaque,
-                                 const char *name, Error **errp)
-{
-    X86CPU *cpu = X86_CPU(obj);
-
-    visit_type_uint32(v, &cpu->env.cpuid_xlevel, name, errp);
-}
-
-static void x86_cpuid_set_xlevel(Object *obj, Visitor *v, void *opaque,
-                                 const char *name, Error **errp)
-{
-    X86CPU *cpu = X86_CPU(obj);
-
-    visit_type_uint32(v, &cpu->env.cpuid_xlevel, name, errp);
-}
-
 static char *x86_cpuid_get_vendor(Object *obj, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
@@ -1499,6 +1483,7 @@ static Property cpu_x86_properties[] = {
     DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
     DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
+    DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2468,9 +2453,6 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "stepping", "int",
                         x86_cpuid_version_get_stepping,
                         x86_cpuid_version_set_stepping, NULL, NULL, NULL);
-    object_property_add(obj, "xlevel", "int",
-                        x86_cpuid_get_xlevel,
-                        x86_cpuid_set_xlevel, NULL, NULL, NULL);
     object_property_add_str(obj, "vendor",
                             x86_cpuid_get_vendor,
                             x86_cpuid_set_vendor, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 10/20] target-i386: cpu: convert 'family' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (8 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 09/20] target-i386: cpu: convert 'xlevel' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 11/20] target-i386: cpu: convert 'model' " Igor Mammedov
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 39295ba..68b7694 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1190,6 +1190,12 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,
     }
 }
 
+static PropertyInfo qdev_prop_family = {
+    .name  = "uint32",
+    .get   = x86_cpuid_version_get_family,
+    .set   = x86_cpuid_version_set_family,
+};
+
 static void x86_cpuid_version_get_model(Object *obj, Visitor *v, void *opaque,
                                         const char *name, Error **errp)
 {
@@ -1484,6 +1490,7 @@ static Property cpu_x86_properties[] = {
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
     DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
     DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
+    { .name = "family", .info = &qdev_prop_family },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2444,9 +2451,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add(obj, "family", "int",
-                        x86_cpuid_version_get_family,
-                        x86_cpuid_version_set_family, NULL, NULL, NULL);
     object_property_add(obj, "model", "int",
                         x86_cpuid_version_get_model,
                         x86_cpuid_version_set_model, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 11/20] target-i386: cpu: convert 'model' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (9 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 10/20] target-i386: cpu: convert 'family' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 12/20] target-i386: cpu: convert 'stepping' " Igor Mammedov
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 68b7694..4b8bcf1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1231,6 +1231,12 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque,
     env->cpuid_version |= ((value & 0xf) << 4) | ((value >> 4) << 16);
 }
 
+static PropertyInfo qdev_prop_model = {
+    .name  = "uint32",
+    .get   = x86_cpuid_version_get_model,
+    .set   = x86_cpuid_version_set_model,
+};
+
 static void x86_cpuid_version_get_stepping(Object *obj, Visitor *v,
                                            void *opaque, const char *name,
                                            Error **errp)
@@ -1491,6 +1497,7 @@ static Property cpu_x86_properties[] = {
     DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
     DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
     { .name = "family", .info = &qdev_prop_family },
+    { .name = "model", .info = &qdev_prop_model },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2451,9 +2458,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add(obj, "model", "int",
-                        x86_cpuid_version_get_model,
-                        x86_cpuid_version_set_model, NULL, NULL, NULL);
     object_property_add(obj, "stepping", "int",
                         x86_cpuid_version_get_stepping,
                         x86_cpuid_version_set_stepping, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 12/20] target-i386: cpu: convert 'stepping' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (10 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 11/20] target-i386: cpu: convert 'model' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 13/20] target-i386: cpu: convert 'vendor' " Igor Mammedov
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
  v2:
    - afaerber: inline property definition inside of
                property array.
---
 target-i386/cpu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4b8bcf1..c1fe87e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1273,6 +1273,12 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
     env->cpuid_version |= value & 0xf;
 }
 
+static PropertyInfo qdev_prop_stepping = {
+    .name  = "uint32",
+    .get   = x86_cpuid_version_get_stepping,
+    .set   = x86_cpuid_version_set_stepping,
+};
+
 static char *x86_cpuid_get_vendor(Object *obj, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
@@ -1498,6 +1504,7 @@ static Property cpu_x86_properties[] = {
     DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
     { .name = "family", .info = &qdev_prop_family },
     { .name = "model", .info = &qdev_prop_model },
+    { .name = "stepping", .info = &qdev_prop_stepping },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2458,9 +2465,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add(obj, "stepping", "int",
-                        x86_cpuid_version_get_stepping,
-                        x86_cpuid_version_set_stepping, NULL, NULL, NULL);
     object_property_add_str(obj, "vendor",
                             x86_cpuid_get_vendor,
                             x86_cpuid_set_vendor, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 13/20] target-i386: cpu: convert 'vendor' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (11 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 12/20] target-i386: cpu: convert 'stepping' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 14/20] target-i386: cpu: convert 'model-id' " Igor Mammedov
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c1fe87e..2ae3565 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1279,7 +1279,8 @@ static PropertyInfo qdev_prop_stepping = {
     .set   = x86_cpuid_version_set_stepping,
 };
 
-static char *x86_cpuid_get_vendor(Object *obj, Error **errp)
+static void x86_cpuid_get_vendor(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
@@ -1288,16 +1289,23 @@ static char *x86_cpuid_get_vendor(Object *obj, Error **errp)
     value = (char *)g_malloc(CPUID_VENDOR_SZ + 1);
     x86_cpu_vendor_words2str(value, env->cpuid_vendor1, env->cpuid_vendor2,
                              env->cpuid_vendor3);
-    return value;
+    visit_type_str(v, &value, name, errp);
+    g_free(value);
 }
 
-static void x86_cpuid_set_vendor(Object *obj, const char *value,
-                                 Error **errp)
+static void x86_cpuid_set_vendor(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
+    char *value;
     int i;
 
+    visit_type_str(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+
     if (strlen(value) != CPUID_VENDOR_SZ) {
         error_set(errp, QERR_PROPERTY_VALUE_BAD, "",
                   "vendor", value);
@@ -1312,8 +1320,15 @@ 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);
     }
+    g_free(value);
 }
 
+static PropertyInfo qdev_prop_vendor = {
+    .name  = "string",
+    .get   = x86_cpuid_get_vendor,
+    .set   = x86_cpuid_set_vendor,
+};
+
 static char *x86_cpuid_get_model_id(Object *obj, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
@@ -1505,6 +1520,7 @@ static Property cpu_x86_properties[] = {
     { .name = "family", .info = &qdev_prop_family },
     { .name = "model", .info = &qdev_prop_model },
     { .name = "stepping", .info = &qdev_prop_stepping },
+    { .name = "vendor", .info  = &qdev_prop_vendor },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2465,9 +2481,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add_str(obj, "vendor",
-                            x86_cpuid_get_vendor,
-                            x86_cpuid_set_vendor, NULL);
     object_property_add_str(obj, "model-id",
                             x86_cpuid_get_model_id,
                             x86_cpuid_set_model_id, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 14/20] target-i386: cpu: convert 'model-id' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (12 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 13/20] target-i386: cpu: convert 'vendor' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/20] target-i386: cpu: convert 'tsc-frequency' " Igor Mammedov
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

* check "if (model_id == NULL)" looks unnecessary now, since all
builtin model-ids are not NULL and user shouldn't be able to set
it NULL (cpumodel string parsing code takes care of it, if feature
is specified as "model-id=" on command line, its parsing will
result in an empty string as value).

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2ae3565..2c8e710 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1329,7 +1329,8 @@ static PropertyInfo qdev_prop_vendor = {
     .set   = x86_cpuid_set_vendor,
 };
 
-static char *x86_cpuid_get_model_id(Object *obj, Error **errp)
+static void x86_cpuid_get_model_id(Object *obj, Visitor *v, void *opaque,
+                                   const char *name, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
@@ -1341,18 +1342,21 @@ static char *x86_cpuid_get_model_id(Object *obj, Error **errp)
         value[i] = env->cpuid_model[i >> 2] >> (8 * (i & 3));
     }
     value[48] = '\0';
-    return value;
+    visit_type_str(v, &value, name, errp);
+    g_free(value);
 }
 
-static void x86_cpuid_set_model_id(Object *obj, const char *model_id,
-                                   Error **errp)
+static void x86_cpuid_set_model_id(Object *obj, Visitor *v, void *opaque,
+                                   const char *name, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
     int c, len, i;
+    char *model_id;
 
-    if (model_id == NULL) {
-        model_id = "";
+    visit_type_str(v, &model_id, name, errp);
+    if (error_is_set(errp)) {
+        return;
     }
     len = strlen(model_id);
     memset(env->cpuid_model, 0, 48);
@@ -1364,8 +1368,15 @@ static void x86_cpuid_set_model_id(Object *obj, const char *model_id,
         }
         env->cpuid_model[i >> 2] |= c << (8 * (i & 3));
     }
+    g_free(model_id);
 }
 
+static PropertyInfo qdev_prop_model_id = {
+    .name  = "string",
+    .get   = x86_cpuid_get_model_id,
+    .set   = x86_cpuid_set_model_id,
+};
+
 static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque,
                                    const char *name, Error **errp)
 {
@@ -1521,6 +1532,7 @@ static Property cpu_x86_properties[] = {
     { .name = "model", .info = &qdev_prop_model },
     { .name = "stepping", .info = &qdev_prop_stepping },
     { .name = "vendor", .info  = &qdev_prop_vendor },
+    { .name  = "model-id", .info  = &qdev_prop_model_id },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2481,9 +2493,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add_str(obj, "model-id",
-                            x86_cpuid_get_model_id,
-                            x86_cpuid_set_model_id, NULL);
     object_property_add(obj, "tsc-frequency", "int",
                         x86_cpuid_get_tsc_freq,
                         x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 15/20] target-i386: cpu: convert 'tsc-frequency' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (13 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 14/20] target-i386: cpu: convert 'model-id' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/21] target-i386: cpu: substitute '_' with '-' for +-foo feature bits as well Igor Mammedov
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2c8e710..04c0a09 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1408,6 +1408,12 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     cpu->env.tsc_khz = value / 1000;
 }
 
+static PropertyInfo qdev_prop_tsc_freq = {
+    .name  = "int64",
+    .get   = x86_cpuid_get_tsc_freq,
+    .set   = x86_cpuid_set_tsc_freq,
+};
+
 static void x86_cpuid_get_apic_id(Object *obj, Visitor *v, void *opaque,
                                   const char *name, Error **errp)
 {
@@ -1533,6 +1539,7 @@ static Property cpu_x86_properties[] = {
     { .name = "stepping", .info = &qdev_prop_stepping },
     { .name = "vendor", .info  = &qdev_prop_vendor },
     { .name  = "model-id", .info  = &qdev_prop_model_id },
+    { .name  = "tsc-frequency", .info  = &qdev_prop_tsc_freq },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2493,9 +2500,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add(obj, "tsc-frequency", "int",
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
     object_property_add(obj, "apic-id", "int",
                         x86_cpuid_get_apic_id,
                         x86_cpuid_set_apic_id, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 15/21] target-i386: cpu: substitute '_' with '-' for +-foo feature bits as well
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (14 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/20] target-i386: cpu: convert 'tsc-frequency' " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/21] target-i386: cpu: convert 'tsc-frequency' to static property Igor Mammedov
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2c8e710..12d5d29 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1598,13 +1598,13 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
 
     while (featurestr) {
         char *val;
+        feat2prop(featurestr);
         if (featurestr[0] == '+') {
             add_flagname_to_bitmaps(featurestr + 1, plus_features);
         } else if (featurestr[0] == '-') {
             add_flagname_to_bitmaps(featurestr + 1, minus_features);
         } else if ((val = strchr(featurestr, '='))) {
             *val = 0; val++;
-            feat2prop(featurestr);
             if (!strcmp(featurestr, "xlevel")) {
                 char *err;
                 char num[32];
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 16/21] target-i386: cpu: convert 'tsc-frequency' to static property
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (15 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/21] target-i386: cpu: substitute '_' with '-' for +-foo feature bits as well Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/20] target-i386: set [+-]feature using static properties Igor Mammedov
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - afaerber: inline property definition inside of
              property array.
---
 target-i386/cpu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 12d5d29..7a3adc1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1408,6 +1408,12 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     cpu->env.tsc_khz = value / 1000;
 }
 
+static PropertyInfo qdev_prop_tsc_freq = {
+    .name  = "int64",
+    .get   = x86_cpuid_get_tsc_freq,
+    .set   = x86_cpuid_set_tsc_freq,
+};
+
 static void x86_cpuid_get_apic_id(Object *obj, Visitor *v, void *opaque,
                                   const char *name, Error **errp)
 {
@@ -1533,6 +1539,7 @@ static Property cpu_x86_properties[] = {
     { .name = "stepping", .info = &qdev_prop_stepping },
     { .name = "vendor", .info  = &qdev_prop_vendor },
     { .name  = "model-id", .info  = &qdev_prop_model_id },
+    { .name  = "tsc-frequency", .info  = &qdev_prop_tsc_freq },
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2493,9 +2500,6 @@ static void x86_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
-    object_property_add(obj, "tsc-frequency", "int",
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
     object_property_add(obj, "apic-id", "int",
                         x86_cpuid_get_apic_id,
                         x86_cpuid_set_apic_id, NULL, NULL, NULL);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 16/20] target-i386: set [+-]feature using static properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (16 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/21] target-i386: cpu: convert 'tsc-frequency' to static property Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

 * Define static properties for cpuid feature bits
    * property names of CPUID feature bits are changed to have "feat-"
      prefix, so that it would be easy to distinguish them from other
      properties.

 * Convert [+-]cpuid_features to a set(QDict) of key, value pairs, where
     +foo => (feat-foo, on)
     -foo => (feat-foo, off)
     [+-] unknown foo => (feat-foo, on/off) - it's expected to be rejected
                                              by property setter later
   QDict is used as convinience sturcture to keep '-foo' semantic.
   Once all +-foo are parsed, collected features are applied to CPU instance.

 * When parsing 'kvmclock' feature, set additional feat-kvmclock2 feature
   in cpu_x86_parse_featurestr() to mantain legacy kvmclock flag behavior

 * Cleanup unused anymore:
     add_flagname_to_bitmaps(), lookup_feature(), altcmp(), sstrcmp(),

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 v6:
   - substitute '_' with '-' for +-foo feature bits as well
   - change "f-" feature prefix to "feat-" (req: afaerber)
   - replace F_* macros with a single X86CPU_FEAT() macro
   - simplify F_XXX macros to set default value to 0, defaults to be handled
     in initfn()
   - ammend F_XXX macros to use feature-words
   - kvmclock fix endless loop on compat kvmclock2 append
 v5:
   - instead of introducing composit f-kvmclock property to maintain
     legace behavior, set additional f-kvmclock2 in cpu_x86_parse_featurestr()
     when kvmclock is parsed.
 v4:
   - major patch reordering, rebasing on current qom-cpu-next
   - merged patches: "define static properties..." and "set [+-]feature..."
   - merge in "make 'f-kvmclock' compatible..." to aviod behavior breakage
   - use register name in feature macros, so that if we rename cpuid_* fields,
     it wouldn't involve mass rename in features array.
   - when converting feature names into property names, replace '_' with '-',
       Requested-By: Don Slutz <Don@cloudswitch.com>,
         mgs-id: <5085D4AA.1060208@CloudSwitch.Com>

 v3:
   - new static properties after rebase:
      - add features "f-rdseed" & "f-adx"
      - add features added by c8acc380
      - add features f-kvm_steal_tm and f-kvmclock_stable
      - ext4 features f-xstore, f-xstore-en, f-xcrypt, f-xcrypt-en,
        f-ace2, f-ace2-en, f-phe, f-phe-en, f-pmm, f-pmm-en

   - f-hypervisor set default to false as for the rest of features
   - define helper FEAT for declaring CPUID feature properties to
     make shorter lines (<80 characters)

 v2:
   - use X86CPU as a type to count of offset correctly, because env field
     isn't starting at CPUstate beginning, but located after it.
---
 target-i386/cpu.c | 302 +++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 196 insertions(+), 106 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 04c0a09..b49af58 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -280,85 +280,6 @@ void host_cpuid(uint32_t function, uint32_t count,
 #endif
 }
 
-#define iswhite(c) ((c) && ((c) <= ' ' || '~' < (c)))
-
-/* general substring compare of *[s1..e1) and *[s2..e2).  sx is start of
- * a substring.  ex if !NULL points to the first char after a substring,
- * otherwise the string is assumed to sized by a terminating nul.
- * Return lexical ordering of *s1:*s2.
- */
-static int sstrcmp(const char *s1, const char *e1, const char *s2,
-    const char *e2)
-{
-    for (;;) {
-        if (!*s1 || !*s2 || *s1 != *s2)
-            return (*s1 - *s2);
-        ++s1, ++s2;
-        if (s1 == e1 && s2 == e2)
-            return (0);
-        else if (s1 == e1)
-            return (*s2);
-        else if (s2 == e2)
-            return (*s1);
-    }
-}
-
-/* compare *[s..e) to *altstr.  *altstr may be a simple string or multiple
- * '|' delimited (possibly empty) strings in which case search for a match
- * within the alternatives proceeds left to right.  Return 0 for success,
- * non-zero otherwise.
- */
-static int altcmp(const char *s, const char *e, const char *altstr)
-{
-    const char *p, *q;
-
-    for (q = p = altstr; ; ) {
-        while (*p && *p != '|')
-            ++p;
-        if ((q == p && !*s) || (q != p && !sstrcmp(s, e, q, p)))
-            return (0);
-        if (!*p)
-            return (1);
-        else
-            q = ++p;
-    }
-}
-
-/* search featureset for flag *[s..e), if found set corresponding bit in
- * *pval and return true, otherwise return false
- */
-static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
-                           const char **featureset)
-{
-    uint32_t mask;
-    const char **ppc;
-    bool found = false;
-
-    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
-        if (*ppc && !altcmp(s, e, *ppc)) {
-            *pval |= mask;
-            found = true;
-        }
-    }
-    return found;
-}
-
-static void add_flagname_to_bitmaps(const char *flagname,
-                                    FeatureWordArray words)
-{
-    FeatureWord w;
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        FeatureWordInfo *wi = &feature_word_info[w];
-        if (wi->feat_names &&
-            lookup_feature(&words[w], flagname, NULL, wi->feat_names)) {
-            break;
-        }
-    }
-    if (w == FEATURE_WORDS) {
-        fprintf(stderr, "CPU feature %s not found\n", flagname);
-    }
-}
-
 typedef struct x86_def_t {
     const char *name;
     uint32_t level;
@@ -1526,6 +1447,9 @@ static PropertyInfo qdev_prop_spinlocks = {
     .set   = x86_set_hv_spinlocks,
 };
 
+#define X86CPU_FEAT(_name, _bit, _leaf) \
+    DEFINE_PROP_BIT(_name, X86CPU, env.features[_leaf], _bit, 0)
+
 static Property cpu_x86_properties[] = {
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
@@ -1540,6 +1464,153 @@ static Property cpu_x86_properties[] = {
     { .name = "vendor", .info  = &qdev_prop_vendor },
     { .name  = "model-id", .info  = &qdev_prop_model_id },
     { .name  = "tsc-frequency", .info  = &qdev_prop_tsc_freq },
+    X86CPU_FEAT("feat-fpu",     0, FEAT_1_EDX),
+    X86CPU_FEAT("feat-vme",     1, FEAT_1_EDX),
+    X86CPU_FEAT("feat-de",      2, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pse",     3, FEAT_1_EDX),
+    X86CPU_FEAT("feat-tsc",     4, FEAT_1_EDX),
+    X86CPU_FEAT("feat-msr",     5, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pae",     6, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mce",     7, FEAT_1_EDX),
+    X86CPU_FEAT("feat-cx8",     8, FEAT_1_EDX),
+    X86CPU_FEAT("feat-apic",    9, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sep",     11, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mtrr",    12, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pge",     13, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mca",     14, FEAT_1_EDX),
+    X86CPU_FEAT("feat-cmov",    15, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pat",     16, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pse36",   17, FEAT_1_EDX),
+    /* Intel psn */
+    X86CPU_FEAT("feat-pn",      18, FEAT_1_EDX),
+    /* Intel clfsh */
+    X86CPU_FEAT("feat-clflush", 19, FEAT_1_EDX),
+    /* Intel dts */
+    X86CPU_FEAT("feat-ds",      21, FEAT_1_EDX),
+    X86CPU_FEAT("feat-acpi",    22, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mmx",     23, FEAT_1_EDX),
+    X86CPU_FEAT("feat-fxsr",    24, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sse",     25, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sse2",    26, FEAT_1_EDX),
+    X86CPU_FEAT("feat-ss",      27, FEAT_1_EDX),
+    /* Intel htt */
+    X86CPU_FEAT("feat-ht",      28, FEAT_1_EDX),
+    X86CPU_FEAT("feat-tm",      29, FEAT_1_EDX),
+    X86CPU_FEAT("feat-ia64",    30, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pbe",     31, FEAT_1_EDX),
+    /* Intel */
+    X86CPU_FEAT("feat-pni",          0, FEAT_1_ECX),
+    /* AMD sse3 */
+    X86CPU_FEAT("feat-sse3",         0, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pclmulqdq",    1, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pclmuldq",     1, FEAT_1_ECX),
+    X86CPU_FEAT("feat-dtes64",       2, FEAT_1_ECX),
+    X86CPU_FEAT("feat-monitor",      3, FEAT_1_ECX),
+    X86CPU_FEAT("feat-ds-cpl",       4, FEAT_1_ECX),
+    X86CPU_FEAT("feat-vmx",          5, FEAT_1_ECX),
+    X86CPU_FEAT("feat-smx",          6, FEAT_1_ECX),
+    X86CPU_FEAT("feat-est",          7, FEAT_1_ECX),
+    X86CPU_FEAT("feat-tm2",          8, FEAT_1_ECX),
+    X86CPU_FEAT("feat-ssse3",        9, FEAT_1_ECX),
+    X86CPU_FEAT("feat-cid",          10, FEAT_1_ECX),
+    X86CPU_FEAT("feat-fma",          12, FEAT_1_ECX),
+    X86CPU_FEAT("feat-cx16",         13, FEAT_1_ECX),
+    X86CPU_FEAT("feat-xtpr",         14, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pdcm",         15, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pcid",         17, FEAT_1_ECX),
+    X86CPU_FEAT("feat-dca",          18, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4-1",       19, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4.1",       19, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4-2",       20, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4.2",       20, FEAT_1_ECX),
+    X86CPU_FEAT("feat-x2apic",       21, FEAT_1_ECX),
+    X86CPU_FEAT("feat-movbe",        22, FEAT_1_ECX),
+    X86CPU_FEAT("feat-popcnt",       23, FEAT_1_ECX),
+    X86CPU_FEAT("feat-tsc-deadline", 24, FEAT_1_ECX),
+    X86CPU_FEAT("feat-aes",          25, FEAT_1_ECX),
+    X86CPU_FEAT("feat-xsave",        26, FEAT_1_ECX),
+    X86CPU_FEAT("feat-osxsave",      27, FEAT_1_ECX),
+    X86CPU_FEAT("feat-avx",          28, FEAT_1_ECX),
+    X86CPU_FEAT("feat-f16c",         29, FEAT_1_ECX),
+    X86CPU_FEAT("feat-rdrand",       30, FEAT_1_ECX),
+    X86CPU_FEAT("feat-hypervisor",   31, FEAT_1_ECX),
+    X86CPU_FEAT("feat-syscall",  11, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-nx",       20, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-xd",       20, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-mmxext",   22, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-fxsr-opt", 25, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-ffxsr",    25, FEAT_8000_0001_EDX),
+    /* AMD Page1GB */
+    X86CPU_FEAT("feat-pdpe1gb",  26, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-rdtscp",   27, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-lm",       29, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-i64",      29, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-3dnowext", 30, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-3dnow",    31, FEAT_8000_0001_EDX),
+    /* AMD LahfSahf */
+    X86CPU_FEAT("feat-lahf-lm",       0, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-cmp-legacy",    1, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-svm",           2, FEAT_8000_0001_ECX),
+    /* AMD ExtApicSpace */
+    X86CPU_FEAT("feat-extapic",       3, FEAT_8000_0001_ECX),
+    /* AMD AltMovCr8 */
+    X86CPU_FEAT("feat-cr8legacy",     4, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-abm",           5, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-sse4a",         6, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-misalignsse",   7, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-3dnowprefetch", 8, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-osvw",          9, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-ibs",           10, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-xop",           11, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-skinit",        12, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-wdt",           13, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-lwp",           15, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-fma4",          16, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-tce",           17, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-nodeid-msr",    19, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-tbm",           21, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-topoext",       22, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-perfctr-core",  23, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-perfctr-nb",    24, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-xstore",    2, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xstore-en", 3, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xcrypt",    6, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xcrypt-en", 7, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-ace2",      8, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-ace2-en",   9, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-phe",      10, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-phe-en",   11, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-pmm",      12, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-pmm-en",   13, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-kvmclock",        0, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-nopiodelay",  1, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-mmu",         2, FEAT_KVM),
+    X86CPU_FEAT("feat-kvmclock2",       3, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-asyncpf",     4, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-steal-tm",    5, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-pv-eoi",      6, FEAT_KVM),
+    X86CPU_FEAT("feat-npt",           0, FEAT_SVM),
+    X86CPU_FEAT("feat-lbrv",          1, FEAT_SVM),
+    X86CPU_FEAT("feat-svm-lock",      2, FEAT_SVM),
+    X86CPU_FEAT("feat-nrip-save",     3, FEAT_SVM),
+    X86CPU_FEAT("feat-tsc-scale",     4, FEAT_SVM),
+    X86CPU_FEAT("feat-vmcb-clean",    5, FEAT_SVM),
+    X86CPU_FEAT("feat-flushbyasid",   6, FEAT_SVM),
+    X86CPU_FEAT("feat-decodeassists", 7, FEAT_SVM),
+    X86CPU_FEAT("feat-pause-filter",  10, FEAT_SVM),
+    X86CPU_FEAT("feat-pfthreshold",   12, FEAT_SVM),
+    X86CPU_FEAT("feat-fsgsbase",  0, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-bmi1",    3, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-hle",     4, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-avx2",    5, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-smep",    7, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-bmi2",    8, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-erms",    9, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-invpcid", 10, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-rtm",     11, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-rdseed",  18, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-adx",     19, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-smap",    20, FEAT_7_0_EBX),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1594,24 +1665,48 @@ static inline void feat2prop(char *s)
 static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
 {
     char *featurestr; /* Single 'key=value" string being parsed */
-    /* Features to be added */
-    FeatureWordArray plus_features = { 0 };
-    /* Features to be removed */
-    FeatureWordArray minus_features = { 0 };
     uint32_t numvalue;
-    CPUX86State *env = &cpu->env;
+    QDict *props = qdict_new();
+    const QDictEntry *ent;
 
     featurestr = features ? strtok(features, ",") : NULL;
 
     while (featurestr) {
         char *val;
-        if (featurestr[0] == '+') {
-            add_flagname_to_bitmaps(featurestr + 1, plus_features);
-        } else if (featurestr[0] == '-') {
-            add_flagname_to_bitmaps(featurestr + 1, minus_features);
+        feat2prop(featurestr);
+        if (featurestr[0] == '+' || featurestr[0] == '-') {
+            const gchar *feat = featurestr + 1;
+            gchar *cpuid_fname = NULL;
+            bool set_kvmclock2 = false;
+
+            if (strncmp(feat, "feat-", 5)) {
+                cpuid_fname = g_strconcat("feat-", feat, NULL);
+                feat = cpuid_fname;
+            }
+
+            if (!strcmp(feat, "feat-kvmclock")) {
+                set_kvmclock2 = true;
+            }
+
+        rep_feat_set:
+            if (featurestr[0] == '+') {
+                /* preseve legacy behaviour, if feature was disabled once
+                 * do not allow to enable it again */
+                if (!qdict_haskey(props, feat)) {
+                    qdict_put(props, feat, qstring_from_str("on"));
+                }
+            } else {
+                qdict_put(props, feat, qstring_from_str("off"));
+            }
+
+            if (set_kvmclock2) {
+                feat = "feat-kvmclock2";
+                set_kvmclock2 = false;
+                goto rep_feat_set;
+            }
+            g_free(cpuid_fname);
         } else if ((val = strchr(featurestr, '='))) {
             *val = 0; val++;
-            feat2prop(featurestr);
             if (!strcmp(featurestr, "xlevel")) {
                 char *err;
                 char num[32];
@@ -1662,7 +1757,6 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 object_property_parse(OBJECT(cpu), val, featurestr, errp);
             }
         } else {
-            feat2prop(featurestr);
             object_property_parse(OBJECT(cpu), "on", featurestr, errp);
         }
         if (error_is_set(errp)) {
@@ -1670,24 +1764,20 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         }
         featurestr = strtok(NULL, ",");
     }
-    env->features[FEAT_1_EDX] |= plus_features[FEAT_1_EDX];
-    env->features[FEAT_1_ECX] |= plus_features[FEAT_1_ECX];
-    env->features[FEAT_8000_0001_EDX] |= plus_features[FEAT_8000_0001_EDX];
-    env->features[FEAT_8000_0001_ECX] |= plus_features[FEAT_8000_0001_ECX];
-    env->features[FEAT_C000_0001_EDX] |= plus_features[FEAT_C000_0001_EDX];
-    env->features[FEAT_KVM] |= plus_features[FEAT_KVM];
-    env->features[FEAT_SVM] |= plus_features[FEAT_SVM];
-    env->features[FEAT_7_0_EBX] |= plus_features[FEAT_7_0_EBX];
-    env->features[FEAT_1_EDX] &= ~minus_features[FEAT_1_EDX];
-    env->features[FEAT_1_ECX] &= ~minus_features[FEAT_1_ECX];
-    env->features[FEAT_8000_0001_EDX] &= ~minus_features[FEAT_8000_0001_EDX];
-    env->features[FEAT_8000_0001_ECX] &= ~minus_features[FEAT_8000_0001_ECX];
-    env->features[FEAT_C000_0001_EDX] &= ~minus_features[FEAT_C000_0001_EDX];
-    env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM];
-    env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM];
-    env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX];
+
+    for (ent = qdict_first(props); ent; ent = qdict_next(props, ent)) {
+        const QString *qval = qobject_to_qstring(qdict_entry_value(ent));
+        /* TODO: switch to using global properties after subclasses are done */
+        object_property_parse(OBJECT(cpu), qstring_get_str(qval),
+                              qdict_entry_key(ent), errp);
+        if (error_is_set(errp)) {
+            QDECREF(props);
+            return;
+        }
+    }
 
 out:
+    QDECREF(props);
     return;
 }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit()
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (17 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/20] target-i386: set [+-]feature using static properties Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce qdev_prop_find_bit() Igor Mammedov
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

helper to find a static property corresponding to a specific bit
in specified field.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/core/qdev-properties.c    | 15 +++++++++++++++
 include/hw/qdev-properties.h | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3a324fb..5c3575b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -964,6 +964,21 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
     return NULL;
 }
 
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr)
+{
+    const Property *prop;
+
+    QDEV_CLASS_FOREACH(dc, dc) {
+        QDEV_PROP_FOREACH(prop, dc) {
+            if (prop->offset == offset && prop->bitnr == bitnr) {
+                return prop;
+            }
+        }
+    }
+    return NULL;
+}
+
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value)
 {
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 39448b7..cf57e3a 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -192,4 +192,22 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
  */
 void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
                                  Error **errp);
+
+#define QDEV_PROP_FOREACH(_var, _class)                                       \
+    for ((_var) = DEVICE_CLASS((_class))->props;                              \
+         (_var) && (_var)->name;                                              \
+         (_var)++)
+
+#define QDEV_CLASS_FOREACH(_var, _class)                                      \
+    for ((_var) = (_class);                                                   \
+         (_var) != DEVICE_CLASS(object_class_by_name(TYPE_DEVICE));           \
+         (_var) = DEVICE_CLASS(object_class_get_parent(OBJECT_CLASS((_var)))))
+
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr);
+#define QDEV_FIND_PROP_FROM_BIT(_class, _state, _field, _bitnr)               \
+    qdev_prop_find_bit(_class,                                                \
+                       offsetof(_state, _field) +                             \
+                       type_check(uint32_t, typeof_field(_state, _field)),    \
+                       _bitnr)
 #endif
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 17/20] qdev: introduce qdev_prop_find_bit()
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (18 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties Igor Mammedov
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

helper to find a static property corresponding to a specific bit
in a specified field.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/core/qdev-properties.c    | 15 +++++++++++++++
 include/hw/qdev-properties.h | 13 +++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3a324fb..5c3575b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -964,6 +964,21 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
     return NULL;
 }
 
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr)
+{
+    const Property *prop;
+
+    QDEV_CLASS_FOREACH(dc, dc) {
+        QDEV_PROP_FOREACH(prop, dc) {
+            if (prop->offset == offset && prop->bitnr == bitnr) {
+                return prop;
+            }
+        }
+    }
+    return NULL;
+}
+
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value)
 {
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 39448b7..759141f 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -192,4 +192,17 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
  */
 void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
                                  Error **errp);
+
+#define QDEV_PROP_FOREACH(_var, _class)                                       \
+    for ((_var) = DEVICE_CLASS((_class))->props;                              \
+         (_var) && (_var)->name;                                              \
+         (_var)++)
+
+#define QDEV_CLASS_FOREACH(_var, _class)                                      \
+    for ((_var) = (_class);                                                   \
+         (_var) != DEVICE_CLASS(object_class_by_name(TYPE_DEVICE));           \
+         (_var) = DEVICE_CLASS(object_class_get_parent(OBJECT_CLASS((_var)))))
+
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr);
 #endif
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (19 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce qdev_prop_find_bit() Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-10-15 16:22   ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/21] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
                   ` (9 subsequent siblings)
  30 siblings, 1 reply; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

 * Define static properties for cpuid feature bits
    * property names of CPUID feature bits are changed to have "feat-"
      prefix, so that it would be easy to distinguish them from other
      properties.

 * Convert [+-]cpuid_features to a set(QDict) of key, value pairs, where
     +foo => (feat-foo, on)
     -foo => (feat-foo, off)
     [+-] unknown foo => (feat-foo, on/off) - it's expected to be rejected
                                              by property setter later
   QDict is used as convinience sturcture to keep '-foo' semantic.
   Once all +-foo are parsed, collected features are applied to CPU instance.

 * When parsing 'kvmclock' feature, set additional feat-kvmclock2 feature
   in cpu_x86_parse_featurestr() to mantain legacy kvmclock flag behavior

 * Cleanup unused anymore:
     add_flagname_to_bitmaps(), lookup_feature(), altcmp(), sstrcmp(),

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 v6:
   - change "f-" feature prefix to "feat-" (req: afaerber)
   - replace F_* macros with a single X86CPU_FEAT() macro
   - simplify F_XXX macros to set default value to 0, defaults to be handled
     in initfn()
   - ammend F_XXX macros to use feature-words
   - kvmclock fix endless loop on compat kvmclock2 append
 v5:
   - instead of introducing composit f-kvmclock property to maintain
     legace behavior, set additional f-kvmclock2 in cpu_x86_parse_featurestr()
     when kvmclock is parsed.
 v4:
   - major patch reordering, rebasing on current qom-cpu-next
   - merged patches: "define static properties..." and "set [+-]feature..."
   - merge in "make 'f-kvmclock' compatible..." to aviod behavior breakage
   - use register name in feature macros, so that if we rename cpuid_* fields,
     it wouldn't involve mass rename in features array.
   - when converting feature names into property names, replace '_' with '-',
       Requested-By: Don Slutz <Don@cloudswitch.com>,
         mgs-id: <5085D4AA.1060208@CloudSwitch.Com>

 v3:
   - new static properties after rebase:
      - add features "f-rdseed" & "f-adx"
      - add features added by c8acc380
      - add features f-kvm_steal_tm and f-kvmclock_stable
      - ext4 features f-xstore, f-xstore-en, f-xcrypt, f-xcrypt-en,
        f-ace2, f-ace2-en, f-phe, f-phe-en, f-pmm, f-pmm-en

   - f-hypervisor set default to false as for the rest of features
   - define helper FEAT for declaring CPUID feature properties to
     make shorter lines (<80 characters)

 v2:
   - use X86CPU as a type to count of offset correctly, because env field
     isn't starting at CPUstate beginning, but located after it.
---
 target-i386/cpu.c | 300 +++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 195 insertions(+), 105 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7a3adc1..b49af58 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -280,85 +280,6 @@ void host_cpuid(uint32_t function, uint32_t count,
 #endif
 }
 
-#define iswhite(c) ((c) && ((c) <= ' ' || '~' < (c)))
-
-/* general substring compare of *[s1..e1) and *[s2..e2).  sx is start of
- * a substring.  ex if !NULL points to the first char after a substring,
- * otherwise the string is assumed to sized by a terminating nul.
- * Return lexical ordering of *s1:*s2.
- */
-static int sstrcmp(const char *s1, const char *e1, const char *s2,
-    const char *e2)
-{
-    for (;;) {
-        if (!*s1 || !*s2 || *s1 != *s2)
-            return (*s1 - *s2);
-        ++s1, ++s2;
-        if (s1 == e1 && s2 == e2)
-            return (0);
-        else if (s1 == e1)
-            return (*s2);
-        else if (s2 == e2)
-            return (*s1);
-    }
-}
-
-/* compare *[s..e) to *altstr.  *altstr may be a simple string or multiple
- * '|' delimited (possibly empty) strings in which case search for a match
- * within the alternatives proceeds left to right.  Return 0 for success,
- * non-zero otherwise.
- */
-static int altcmp(const char *s, const char *e, const char *altstr)
-{
-    const char *p, *q;
-
-    for (q = p = altstr; ; ) {
-        while (*p && *p != '|')
-            ++p;
-        if ((q == p && !*s) || (q != p && !sstrcmp(s, e, q, p)))
-            return (0);
-        if (!*p)
-            return (1);
-        else
-            q = ++p;
-    }
-}
-
-/* search featureset for flag *[s..e), if found set corresponding bit in
- * *pval and return true, otherwise return false
- */
-static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
-                           const char **featureset)
-{
-    uint32_t mask;
-    const char **ppc;
-    bool found = false;
-
-    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
-        if (*ppc && !altcmp(s, e, *ppc)) {
-            *pval |= mask;
-            found = true;
-        }
-    }
-    return found;
-}
-
-static void add_flagname_to_bitmaps(const char *flagname,
-                                    FeatureWordArray words)
-{
-    FeatureWord w;
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        FeatureWordInfo *wi = &feature_word_info[w];
-        if (wi->feat_names &&
-            lookup_feature(&words[w], flagname, NULL, wi->feat_names)) {
-            break;
-        }
-    }
-    if (w == FEATURE_WORDS) {
-        fprintf(stderr, "CPU feature %s not found\n", flagname);
-    }
-}
-
 typedef struct x86_def_t {
     const char *name;
     uint32_t level;
@@ -1526,6 +1447,9 @@ static PropertyInfo qdev_prop_spinlocks = {
     .set   = x86_set_hv_spinlocks,
 };
 
+#define X86CPU_FEAT(_name, _bit, _leaf) \
+    DEFINE_PROP_BIT(_name, X86CPU, env.features[_leaf], _bit, 0)
+
 static Property cpu_x86_properties[] = {
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
@@ -1540,6 +1464,153 @@ static Property cpu_x86_properties[] = {
     { .name = "vendor", .info  = &qdev_prop_vendor },
     { .name  = "model-id", .info  = &qdev_prop_model_id },
     { .name  = "tsc-frequency", .info  = &qdev_prop_tsc_freq },
+    X86CPU_FEAT("feat-fpu",     0, FEAT_1_EDX),
+    X86CPU_FEAT("feat-vme",     1, FEAT_1_EDX),
+    X86CPU_FEAT("feat-de",      2, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pse",     3, FEAT_1_EDX),
+    X86CPU_FEAT("feat-tsc",     4, FEAT_1_EDX),
+    X86CPU_FEAT("feat-msr",     5, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pae",     6, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mce",     7, FEAT_1_EDX),
+    X86CPU_FEAT("feat-cx8",     8, FEAT_1_EDX),
+    X86CPU_FEAT("feat-apic",    9, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sep",     11, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mtrr",    12, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pge",     13, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mca",     14, FEAT_1_EDX),
+    X86CPU_FEAT("feat-cmov",    15, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pat",     16, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pse36",   17, FEAT_1_EDX),
+    /* Intel psn */
+    X86CPU_FEAT("feat-pn",      18, FEAT_1_EDX),
+    /* Intel clfsh */
+    X86CPU_FEAT("feat-clflush", 19, FEAT_1_EDX),
+    /* Intel dts */
+    X86CPU_FEAT("feat-ds",      21, FEAT_1_EDX),
+    X86CPU_FEAT("feat-acpi",    22, FEAT_1_EDX),
+    X86CPU_FEAT("feat-mmx",     23, FEAT_1_EDX),
+    X86CPU_FEAT("feat-fxsr",    24, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sse",     25, FEAT_1_EDX),
+    X86CPU_FEAT("feat-sse2",    26, FEAT_1_EDX),
+    X86CPU_FEAT("feat-ss",      27, FEAT_1_EDX),
+    /* Intel htt */
+    X86CPU_FEAT("feat-ht",      28, FEAT_1_EDX),
+    X86CPU_FEAT("feat-tm",      29, FEAT_1_EDX),
+    X86CPU_FEAT("feat-ia64",    30, FEAT_1_EDX),
+    X86CPU_FEAT("feat-pbe",     31, FEAT_1_EDX),
+    /* Intel */
+    X86CPU_FEAT("feat-pni",          0, FEAT_1_ECX),
+    /* AMD sse3 */
+    X86CPU_FEAT("feat-sse3",         0, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pclmulqdq",    1, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pclmuldq",     1, FEAT_1_ECX),
+    X86CPU_FEAT("feat-dtes64",       2, FEAT_1_ECX),
+    X86CPU_FEAT("feat-monitor",      3, FEAT_1_ECX),
+    X86CPU_FEAT("feat-ds-cpl",       4, FEAT_1_ECX),
+    X86CPU_FEAT("feat-vmx",          5, FEAT_1_ECX),
+    X86CPU_FEAT("feat-smx",          6, FEAT_1_ECX),
+    X86CPU_FEAT("feat-est",          7, FEAT_1_ECX),
+    X86CPU_FEAT("feat-tm2",          8, FEAT_1_ECX),
+    X86CPU_FEAT("feat-ssse3",        9, FEAT_1_ECX),
+    X86CPU_FEAT("feat-cid",          10, FEAT_1_ECX),
+    X86CPU_FEAT("feat-fma",          12, FEAT_1_ECX),
+    X86CPU_FEAT("feat-cx16",         13, FEAT_1_ECX),
+    X86CPU_FEAT("feat-xtpr",         14, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pdcm",         15, FEAT_1_ECX),
+    X86CPU_FEAT("feat-pcid",         17, FEAT_1_ECX),
+    X86CPU_FEAT("feat-dca",          18, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4-1",       19, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4.1",       19, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4-2",       20, FEAT_1_ECX),
+    X86CPU_FEAT("feat-sse4.2",       20, FEAT_1_ECX),
+    X86CPU_FEAT("feat-x2apic",       21, FEAT_1_ECX),
+    X86CPU_FEAT("feat-movbe",        22, FEAT_1_ECX),
+    X86CPU_FEAT("feat-popcnt",       23, FEAT_1_ECX),
+    X86CPU_FEAT("feat-tsc-deadline", 24, FEAT_1_ECX),
+    X86CPU_FEAT("feat-aes",          25, FEAT_1_ECX),
+    X86CPU_FEAT("feat-xsave",        26, FEAT_1_ECX),
+    X86CPU_FEAT("feat-osxsave",      27, FEAT_1_ECX),
+    X86CPU_FEAT("feat-avx",          28, FEAT_1_ECX),
+    X86CPU_FEAT("feat-f16c",         29, FEAT_1_ECX),
+    X86CPU_FEAT("feat-rdrand",       30, FEAT_1_ECX),
+    X86CPU_FEAT("feat-hypervisor",   31, FEAT_1_ECX),
+    X86CPU_FEAT("feat-syscall",  11, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-nx",       20, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-xd",       20, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-mmxext",   22, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-fxsr-opt", 25, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-ffxsr",    25, FEAT_8000_0001_EDX),
+    /* AMD Page1GB */
+    X86CPU_FEAT("feat-pdpe1gb",  26, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-rdtscp",   27, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-lm",       29, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-i64",      29, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-3dnowext", 30, FEAT_8000_0001_EDX),
+    X86CPU_FEAT("feat-3dnow",    31, FEAT_8000_0001_EDX),
+    /* AMD LahfSahf */
+    X86CPU_FEAT("feat-lahf-lm",       0, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-cmp-legacy",    1, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-svm",           2, FEAT_8000_0001_ECX),
+    /* AMD ExtApicSpace */
+    X86CPU_FEAT("feat-extapic",       3, FEAT_8000_0001_ECX),
+    /* AMD AltMovCr8 */
+    X86CPU_FEAT("feat-cr8legacy",     4, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-abm",           5, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-sse4a",         6, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-misalignsse",   7, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-3dnowprefetch", 8, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-osvw",          9, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-ibs",           10, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-xop",           11, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-skinit",        12, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-wdt",           13, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-lwp",           15, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-fma4",          16, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-tce",           17, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-nodeid-msr",    19, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-tbm",           21, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-topoext",       22, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-perfctr-core",  23, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-perfctr-nb",    24, FEAT_8000_0001_ECX),
+    X86CPU_FEAT("feat-xstore",    2, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xstore-en", 3, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xcrypt",    6, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-xcrypt-en", 7, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-ace2",      8, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-ace2-en",   9, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-phe",      10, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-phe-en",   11, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-pmm",      12, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-pmm-en",   13, FEAT_C000_0001_EDX),
+    X86CPU_FEAT("feat-kvmclock",        0, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-nopiodelay",  1, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-mmu",         2, FEAT_KVM),
+    X86CPU_FEAT("feat-kvmclock2",       3, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-asyncpf",     4, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-steal-tm",    5, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-pv-eoi",      6, FEAT_KVM),
+    X86CPU_FEAT("feat-npt",           0, FEAT_SVM),
+    X86CPU_FEAT("feat-lbrv",          1, FEAT_SVM),
+    X86CPU_FEAT("feat-svm-lock",      2, FEAT_SVM),
+    X86CPU_FEAT("feat-nrip-save",     3, FEAT_SVM),
+    X86CPU_FEAT("feat-tsc-scale",     4, FEAT_SVM),
+    X86CPU_FEAT("feat-vmcb-clean",    5, FEAT_SVM),
+    X86CPU_FEAT("feat-flushbyasid",   6, FEAT_SVM),
+    X86CPU_FEAT("feat-decodeassists", 7, FEAT_SVM),
+    X86CPU_FEAT("feat-pause-filter",  10, FEAT_SVM),
+    X86CPU_FEAT("feat-pfthreshold",   12, FEAT_SVM),
+    X86CPU_FEAT("feat-fsgsbase",  0, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-bmi1",    3, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-hle",     4, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-avx2",    5, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-smep",    7, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-bmi2",    8, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-erms",    9, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-invpcid", 10, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-rtm",     11, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-rdseed",  18, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-adx",     19, FEAT_7_0_EBX),
+    X86CPU_FEAT("feat-smap",    20, FEAT_7_0_EBX),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1594,22 +1665,46 @@ static inline void feat2prop(char *s)
 static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
 {
     char *featurestr; /* Single 'key=value" string being parsed */
-    /* Features to be added */
-    FeatureWordArray plus_features = { 0 };
-    /* Features to be removed */
-    FeatureWordArray minus_features = { 0 };
     uint32_t numvalue;
-    CPUX86State *env = &cpu->env;
+    QDict *props = qdict_new();
+    const QDictEntry *ent;
 
     featurestr = features ? strtok(features, ",") : NULL;
 
     while (featurestr) {
         char *val;
         feat2prop(featurestr);
-        if (featurestr[0] == '+') {
-            add_flagname_to_bitmaps(featurestr + 1, plus_features);
-        } else if (featurestr[0] == '-') {
-            add_flagname_to_bitmaps(featurestr + 1, minus_features);
+        if (featurestr[0] == '+' || featurestr[0] == '-') {
+            const gchar *feat = featurestr + 1;
+            gchar *cpuid_fname = NULL;
+            bool set_kvmclock2 = false;
+
+            if (strncmp(feat, "feat-", 5)) {
+                cpuid_fname = g_strconcat("feat-", feat, NULL);
+                feat = cpuid_fname;
+            }
+
+            if (!strcmp(feat, "feat-kvmclock")) {
+                set_kvmclock2 = true;
+            }
+
+        rep_feat_set:
+            if (featurestr[0] == '+') {
+                /* preseve legacy behaviour, if feature was disabled once
+                 * do not allow to enable it again */
+                if (!qdict_haskey(props, feat)) {
+                    qdict_put(props, feat, qstring_from_str("on"));
+                }
+            } else {
+                qdict_put(props, feat, qstring_from_str("off"));
+            }
+
+            if (set_kvmclock2) {
+                feat = "feat-kvmclock2";
+                set_kvmclock2 = false;
+                goto rep_feat_set;
+            }
+            g_free(cpuid_fname);
         } else if ((val = strchr(featurestr, '='))) {
             *val = 0; val++;
             if (!strcmp(featurestr, "xlevel")) {
@@ -1662,7 +1757,6 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                 object_property_parse(OBJECT(cpu), val, featurestr, errp);
             }
         } else {
-            feat2prop(featurestr);
             object_property_parse(OBJECT(cpu), "on", featurestr, errp);
         }
         if (error_is_set(errp)) {
@@ -1670,24 +1764,20 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
         }
         featurestr = strtok(NULL, ",");
     }
-    env->features[FEAT_1_EDX] |= plus_features[FEAT_1_EDX];
-    env->features[FEAT_1_ECX] |= plus_features[FEAT_1_ECX];
-    env->features[FEAT_8000_0001_EDX] |= plus_features[FEAT_8000_0001_EDX];
-    env->features[FEAT_8000_0001_ECX] |= plus_features[FEAT_8000_0001_ECX];
-    env->features[FEAT_C000_0001_EDX] |= plus_features[FEAT_C000_0001_EDX];
-    env->features[FEAT_KVM] |= plus_features[FEAT_KVM];
-    env->features[FEAT_SVM] |= plus_features[FEAT_SVM];
-    env->features[FEAT_7_0_EBX] |= plus_features[FEAT_7_0_EBX];
-    env->features[FEAT_1_EDX] &= ~minus_features[FEAT_1_EDX];
-    env->features[FEAT_1_ECX] &= ~minus_features[FEAT_1_ECX];
-    env->features[FEAT_8000_0001_EDX] &= ~minus_features[FEAT_8000_0001_EDX];
-    env->features[FEAT_8000_0001_ECX] &= ~minus_features[FEAT_8000_0001_ECX];
-    env->features[FEAT_C000_0001_EDX] &= ~minus_features[FEAT_C000_0001_EDX];
-    env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM];
-    env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM];
-    env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX];
+
+    for (ent = qdict_first(props); ent; ent = qdict_next(props, ent)) {
+        const QString *qval = qobject_to_qstring(qdict_entry_value(ent));
+        /* TODO: switch to using global properties after subclasses are done */
+        object_property_parse(OBJECT(cpu), qstring_get_str(qval),
+                              qdict_entry_key(ent), errp);
+        if (error_is_set(errp)) {
+            QDECREF(props);
+            return;
+        }
+    }
 
 out:
+    QDECREF(props);
     return;
 }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 18/21] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit()
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (20 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/20] target-i386: use static properties in check_features_against_host() to print CPUID feature names Igor Mammedov
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

helper to find a static property corresponding to a specific bit
in specified field.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/core/qdev-properties.c    | 15 +++++++++++++++
 include/hw/qdev-properties.h | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3a324fb..5c3575b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -964,6 +964,21 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
     return NULL;
 }
 
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr)
+{
+    const Property *prop;
+
+    QDEV_CLASS_FOREACH(dc, dc) {
+        QDEV_PROP_FOREACH(prop, dc) {
+            if (prop->offset == offset && prop->bitnr == bitnr) {
+                return prop;
+            }
+        }
+    }
+    return NULL;
+}
+
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value)
 {
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 39448b7..cf57e3a 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -192,4 +192,22 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
  */
 void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
                                  Error **errp);
+
+#define QDEV_PROP_FOREACH(_var, _class)                                       \
+    for ((_var) = DEVICE_CLASS((_class))->props;                              \
+         (_var) && (_var)->name;                                              \
+         (_var)++)
+
+#define QDEV_CLASS_FOREACH(_var, _class)                                      \
+    for ((_var) = (_class);                                                   \
+         (_var) != DEVICE_CLASS(object_class_by_name(TYPE_DEVICE));           \
+         (_var) = DEVICE_CLASS(object_class_get_parent(OBJECT_CLASS((_var)))))
+
+const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset,
+                                   const uint8_t bitnr);
+#define QDEV_FIND_PROP_FROM_BIT(_class, _state, _field, _bitnr)               \
+    qdev_prop_find_bit(_class,                                                \
+                       offsetof(_state, _field) +                             \
+                       type_check(uint32_t, typeof_field(_state, _field)),    \
+                       _bitnr)
 #endif
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 18/20] target-i386: use static properties in check_features_against_host() to print CPUID feature names
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (21 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/21] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/21] " Igor Mammedov
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b49af58..f3de420 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -996,24 +996,6 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 #endif /* CONFIG_KVM */
 }
 
-static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
-{
-    int i;
-
-    for (i = 0; i < 32; ++i)
-        if (1 << i & mask) {
-            const char *reg = get_register_name_32(f->cpuid_reg);
-            assert(reg);
-            fprintf(stderr, "warning: host doesn't support requested feature: "
-                "CPUID.%02XH:%s%s%s [bit %d]\n",
-                f->cpuid_eax, reg,
-                f->feat_names[i] ? "." : "",
-                f->feat_names[i] ? f->feat_names[i] : "", i);
-            break;
-        }
-    return 0;
-}
-
 /* Check if all requested cpu flags are making their way to the guest
  *
  * Returns 0 if all flags are supported by the host, non-zero otherwise.
@@ -1052,6 +1034,7 @@ static int kvm_check_features_against_host(X86CPU *cpu)
             &host_def.features[FEAT_KVM],
             FEAT_KVM },
     };
+    const DeviceClass *dc = DEVICE_CLASS(object_get_class(OBJECT(cpu)));
 
     assert(kvm_enabled());
 
@@ -1059,10 +1042,22 @@ static int kvm_check_features_against_host(X86CPU *cpu)
     for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i) {
         FeatureWord w = ft[i].feat_word;
         FeatureWordInfo *wi = &feature_word_info[w];
+        int offset = (char *)&((X86CPU *)0)->env.features[w] - (char *)0;
         for (mask = 1; mask; mask <<= 1) {
             if (*ft[i].guest_feat & mask &&
                 !(*ft[i].host_feat & mask)) {
-                unavailable_host_feature(wi, mask);
+                int bitnr = ffsl(mask) - 1;
+                const Property *prop = qdev_prop_find_bit(dc, offset, bitnr);
+                const char *name = prop ? prop->name : NULL;
+                const char *reg = get_register_name_32(wi->cpuid_reg);
+
+                assert(reg);
+                fprintf(stderr, "warning: host doesn't support requested"
+                        "feature: CPUID.%02XH:%s%s%s [bit %d]\n",
+                         wi->cpuid_eax,
+                         reg, name ? "." : "",
+                         name ? name : "",
+                         bitnr);
                 rv = 1;
             }
         }
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 19/21] target-i386: use static properties in check_features_against_host() to print CPUID feature names
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (22 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/20] target-i386: use static properties in check_features_against_host() to print CPUID feature names Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/20] target-i386: use static properties to list CPUID features Igor Mammedov
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b49af58..f3de420 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -996,24 +996,6 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 #endif /* CONFIG_KVM */
 }
 
-static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
-{
-    int i;
-
-    for (i = 0; i < 32; ++i)
-        if (1 << i & mask) {
-            const char *reg = get_register_name_32(f->cpuid_reg);
-            assert(reg);
-            fprintf(stderr, "warning: host doesn't support requested feature: "
-                "CPUID.%02XH:%s%s%s [bit %d]\n",
-                f->cpuid_eax, reg,
-                f->feat_names[i] ? "." : "",
-                f->feat_names[i] ? f->feat_names[i] : "", i);
-            break;
-        }
-    return 0;
-}
-
 /* Check if all requested cpu flags are making their way to the guest
  *
  * Returns 0 if all flags are supported by the host, non-zero otherwise.
@@ -1052,6 +1034,7 @@ static int kvm_check_features_against_host(X86CPU *cpu)
             &host_def.features[FEAT_KVM],
             FEAT_KVM },
     };
+    const DeviceClass *dc = DEVICE_CLASS(object_get_class(OBJECT(cpu)));
 
     assert(kvm_enabled());
 
@@ -1059,10 +1042,22 @@ static int kvm_check_features_against_host(X86CPU *cpu)
     for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i) {
         FeatureWord w = ft[i].feat_word;
         FeatureWordInfo *wi = &feature_word_info[w];
+        int offset = (char *)&((X86CPU *)0)->env.features[w] - (char *)0;
         for (mask = 1; mask; mask <<= 1) {
             if (*ft[i].guest_feat & mask &&
                 !(*ft[i].host_feat & mask)) {
-                unavailable_host_feature(wi, mask);
+                int bitnr = ffsl(mask) - 1;
+                const Property *prop = qdev_prop_find_bit(dc, offset, bitnr);
+                const char *name = prop ? prop->name : NULL;
+                const char *reg = get_register_name_32(wi->cpuid_reg);
+
+                assert(reg);
+                fprintf(stderr, "warning: host doesn't support requested"
+                        "feature: CPUID.%02XH:%s%s%s [bit %d]\n",
+                         wi->cpuid_eax,
+                         reg, name ? "." : "",
+                         name ? name : "",
+                         bitnr);
                 rv = 1;
             }
         }
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 19/20] target-i386: use static properties to list CPUID features
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (23 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/21] " Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/20] target-i386: remove unused *_feature_name arrays Igor Mammedov
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

- it breaks compatibility with previous output format by printing all features
  in one string with "feat-" prefixes and all "_" replaced by "-"

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 44 ++++++++++----------------------------------
 1 file changed, 10 insertions(+), 34 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f3de420..f01e496 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1776,42 +1776,13 @@ out:
     return;
 }
 
-/* generate a composite string into buf of all cpuid names in featureset
- * selected by fbits.  indicate truncation at bufsize in the event of overflow.
- * if flags, suppress names undefined in featureset.
- */
-static void listflags(char *buf, int bufsize, uint32_t fbits,
-    const char **featureset, uint32_t flags)
-{
-    const char **p = &featureset[31];
-    char *q, *b, bit;
-    int nc;
-
-    b = 4 <= bufsize ? buf + (bufsize -= 3) - 1 : NULL;
-    *buf = '\0';
-    for (q = buf, bit = 31; fbits && bufsize; --p, fbits &= ~(1 << bit), --bit)
-        if (fbits & 1 << bit && (*p || !flags)) {
-            if (*p)
-                nc = snprintf(q, bufsize, "%s%s", q == buf ? "" : " ", *p);
-            else
-                nc = snprintf(q, bufsize, "%s[%d]", q == buf ? "" : " ", bit);
-            if (bufsize <= nc) {
-                if (b) {
-                    memcpy(b, "...", sizeof("..."));
-                }
-                return;
-            }
-            q += nc;
-            bufsize -= nc;
-        }
-}
-
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     x86_def_t *def;
     char buf[256];
     int i;
+    const Property *prop;
 
     for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
         def = &builtin_x86_defs[i];
@@ -1825,12 +1796,17 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 #endif
 
     (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
-    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
-        FeatureWordInfo *fw = &feature_word_info[i];
 
-        listflags(buf, sizeof(buf), (uint32_t)~0, fw->feat_names, 1);
-        (*cpu_fprintf)(f, "  %s\n", buf);
+    (*cpu_fprintf)(f, " ");
+    QDEV_PROP_FOREACH(prop, object_class_by_name(TYPE_X86_CPU)) {
+        const char *name = prop ? prop->name : "";
+
+        if (!g_str_has_prefix(name, "feat-")) {
+            continue;
+        }
+        (*cpu_fprintf)(f, " %s", name);
     }
+    (*cpu_fprintf)(f, "\n");
 }
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 20/20] target-i386: remove unused *_feature_name arrays
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (24 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/20] target-i386: use static properties to list CPUID features Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/21] target-i386: use static properties to list CPUID features Igor Mammedov
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 99 -------------------------------------------------------
 1 file changed, 99 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f01e496..43fc1c7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -60,98 +60,7 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
     dst[CPUID_VENDOR_SZ] = '\0';
 }
 
-/* feature flags taken from "Intel Processor Identification and the CPUID
- * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
- * between feature naming conventions, aliases may be added.
- */
-static const char *feature_name[] = {
-    "fpu", "vme", "de", "pse",
-    "tsc", "msr", "pae", "mce",
-    "cx8", "apic", NULL, "sep",
-    "mtrr", "pge", "mca", "cmov",
-    "pat", "pse36", "pn" /* Intel psn */, "clflush" /* Intel clfsh */,
-    NULL, "ds" /* Intel dts */, "acpi", "mmx",
-    "fxsr", "sse", "sse2", "ss",
-    "ht" /* Intel htt */, "tm", "ia64", "pbe",
-};
-static const char *ext_feature_name[] = {
-    "pni|sse3" /* Intel,AMD sse3 */, "pclmulqdq|pclmuldq", "dtes64", "monitor",
-    "ds_cpl", "vmx", "smx", "est",
-    "tm2", "ssse3", "cid", NULL,
-    "fma", "cx16", "xtpr", "pdcm",
-    NULL, "pcid", "dca", "sse4.1|sse4_1",
-    "sse4.2|sse4_2", "x2apic", "movbe", "popcnt",
-    "tsc-deadline", "aes", "xsave", "osxsave",
-    "avx", "f16c", "rdrand", "hypervisor",
-};
-/* Feature names that are already defined on feature_name[] but are set on
- * CPUID[8000_0001].EDX on AMD CPUs don't have their names on
- * ext2_feature_name[]. They are copied automatically to cpuid_ext2_features
- * if and only if CPU vendor is AMD.
- */
-static const char *ext2_feature_name[] = {
-    NULL /* fpu */, NULL /* vme */, NULL /* de */, NULL /* pse */,
-    NULL /* tsc */, NULL /* msr */, NULL /* pae */, NULL /* mce */,
-    NULL /* cx8 */ /* AMD CMPXCHG8B */, NULL /* apic */, NULL, "syscall",
-    NULL /* mtrr */, NULL /* pge */, NULL /* mca */, NULL /* cmov */,
-    NULL /* pat */, NULL /* pse36 */, NULL, NULL /* Linux mp */,
-    "nx|xd", NULL, "mmxext", NULL /* mmx */,
-    NULL /* fxsr */, "fxsr_opt|ffxsr", "pdpe1gb" /* AMD Page1GB */, "rdtscp",
-    NULL, "lm|i64", "3dnowext", "3dnow",
-};
-static const char *ext3_feature_name[] = {
-    "lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD ExtApicSpace */,
-    "cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
-    "3dnowprefetch", "osvw", "ibs", "xop",
-    "skinit", "wdt", NULL, "lwp",
-    "fma4", "tce", NULL, "nodeid_msr",
-    NULL, "tbm", "topoext", "perfctr_core",
-    "perfctr_nb", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *ext4_feature_name[] = {
-    NULL, NULL, "xstore", "xstore-en",
-    NULL, NULL, "xcrypt", "xcrypt-en",
-    "ace2", "ace2-en", "phe", "phe-en",
-    "pmm", "pmm-en", NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
-    "kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *svm_feature_name[] = {
-    "npt", "lbrv", "svm_lock", "nrip_save",
-    "tsc_scale", "vmcb_clean",  "flushbyasid", "decodeassists",
-    NULL, NULL, "pause_filter", NULL,
-    "pfthreshold", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *cpuid_7_0_ebx_feature_name[] = {
-    "fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
-    "bmi2", "erms", "invpcid", "rtm", NULL, NULL, NULL, NULL,
-    NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-};
-
 typedef struct FeatureWordInfo {
-    const char **feat_names;
     uint32_t cpuid_eax;   /* Input EAX for CPUID */
     bool cpuid_needs_ecx; /* CPUID instruction uses ECX as input */
     uint32_t cpuid_ecx;   /* Input ECX value for CPUID */
@@ -160,35 +69,27 @@ typedef struct FeatureWordInfo {
 
 static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
     [FEAT_1_EDX] = {
-        .feat_names = feature_name,
         .cpuid_eax = 1, .cpuid_reg = R_EDX,
     },
     [FEAT_1_ECX] = {
-        .feat_names = ext_feature_name,
         .cpuid_eax = 1, .cpuid_reg = R_ECX,
     },
     [FEAT_8000_0001_EDX] = {
-        .feat_names = ext2_feature_name,
         .cpuid_eax = 0x80000001, .cpuid_reg = R_EDX,
     },
     [FEAT_8000_0001_ECX] = {
-        .feat_names = ext3_feature_name,
         .cpuid_eax = 0x80000001, .cpuid_reg = R_ECX,
     },
     [FEAT_C000_0001_EDX] = {
-        .feat_names = ext4_feature_name,
         .cpuid_eax = 0xC0000001, .cpuid_reg = R_EDX,
     },
     [FEAT_KVM] = {
-        .feat_names = kvm_feature_name,
         .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
     },
     [FEAT_SVM] = {
-        .feat_names = svm_feature_name,
         .cpuid_eax = 0x8000000A, .cpuid_reg = R_EDX,
     },
     [FEAT_7_0_EBX] = {
-        .feat_names = cpuid_7_0_ebx_feature_name,
         .cpuid_eax = 7,
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
         .cpuid_reg = R_EBX,
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 20/21] target-i386: use static properties to list CPUID features
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (25 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/20] target-i386: remove unused *_feature_name arrays Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 21/21] target-i386: remove unused *_feature_name arrays Igor Mammedov
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

- breaks compabilty with previous output format by printing all features
  in one string with "feat-" prefixes.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 44 ++++++++++----------------------------------
 1 file changed, 10 insertions(+), 34 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f3de420..f01e496 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1776,42 +1776,13 @@ out:
     return;
 }
 
-/* generate a composite string into buf of all cpuid names in featureset
- * selected by fbits.  indicate truncation at bufsize in the event of overflow.
- * if flags, suppress names undefined in featureset.
- */
-static void listflags(char *buf, int bufsize, uint32_t fbits,
-    const char **featureset, uint32_t flags)
-{
-    const char **p = &featureset[31];
-    char *q, *b, bit;
-    int nc;
-
-    b = 4 <= bufsize ? buf + (bufsize -= 3) - 1 : NULL;
-    *buf = '\0';
-    for (q = buf, bit = 31; fbits && bufsize; --p, fbits &= ~(1 << bit), --bit)
-        if (fbits & 1 << bit && (*p || !flags)) {
-            if (*p)
-                nc = snprintf(q, bufsize, "%s%s", q == buf ? "" : " ", *p);
-            else
-                nc = snprintf(q, bufsize, "%s[%d]", q == buf ? "" : " ", bit);
-            if (bufsize <= nc) {
-                if (b) {
-                    memcpy(b, "...", sizeof("..."));
-                }
-                return;
-            }
-            q += nc;
-            bufsize -= nc;
-        }
-}
-
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     x86_def_t *def;
     char buf[256];
     int i;
+    const Property *prop;
 
     for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
         def = &builtin_x86_defs[i];
@@ -1825,12 +1796,17 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 #endif
 
     (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
-    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
-        FeatureWordInfo *fw = &feature_word_info[i];
 
-        listflags(buf, sizeof(buf), (uint32_t)~0, fw->feat_names, 1);
-        (*cpu_fprintf)(f, "  %s\n", buf);
+    (*cpu_fprintf)(f, " ");
+    QDEV_PROP_FOREACH(prop, object_class_by_name(TYPE_X86_CPU)) {
+        const char *name = prop ? prop->name : "";
+
+        if (!g_str_has_prefix(name, "feat-")) {
+            continue;
+        }
+        (*cpu_fprintf)(f, " %s", name);
     }
+    (*cpu_fprintf)(f, "\n");
 }
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 21/21] target-i386: remove unused *_feature_name arrays
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (26 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/21] target-i386: use static properties to list CPUID features Igor Mammedov
@ 2013-07-15 22:26 ` Igor Mammedov
  2013-10-14 12:09 ` [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-07-15 22:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld, Paolo Bonzini,
	Andreas Färber

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 99 -------------------------------------------------------
 1 file changed, 99 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f01e496..43fc1c7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -60,98 +60,7 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
     dst[CPUID_VENDOR_SZ] = '\0';
 }
 
-/* feature flags taken from "Intel Processor Identification and the CPUID
- * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
- * between feature naming conventions, aliases may be added.
- */
-static const char *feature_name[] = {
-    "fpu", "vme", "de", "pse",
-    "tsc", "msr", "pae", "mce",
-    "cx8", "apic", NULL, "sep",
-    "mtrr", "pge", "mca", "cmov",
-    "pat", "pse36", "pn" /* Intel psn */, "clflush" /* Intel clfsh */,
-    NULL, "ds" /* Intel dts */, "acpi", "mmx",
-    "fxsr", "sse", "sse2", "ss",
-    "ht" /* Intel htt */, "tm", "ia64", "pbe",
-};
-static const char *ext_feature_name[] = {
-    "pni|sse3" /* Intel,AMD sse3 */, "pclmulqdq|pclmuldq", "dtes64", "monitor",
-    "ds_cpl", "vmx", "smx", "est",
-    "tm2", "ssse3", "cid", NULL,
-    "fma", "cx16", "xtpr", "pdcm",
-    NULL, "pcid", "dca", "sse4.1|sse4_1",
-    "sse4.2|sse4_2", "x2apic", "movbe", "popcnt",
-    "tsc-deadline", "aes", "xsave", "osxsave",
-    "avx", "f16c", "rdrand", "hypervisor",
-};
-/* Feature names that are already defined on feature_name[] but are set on
- * CPUID[8000_0001].EDX on AMD CPUs don't have their names on
- * ext2_feature_name[]. They are copied automatically to cpuid_ext2_features
- * if and only if CPU vendor is AMD.
- */
-static const char *ext2_feature_name[] = {
-    NULL /* fpu */, NULL /* vme */, NULL /* de */, NULL /* pse */,
-    NULL /* tsc */, NULL /* msr */, NULL /* pae */, NULL /* mce */,
-    NULL /* cx8 */ /* AMD CMPXCHG8B */, NULL /* apic */, NULL, "syscall",
-    NULL /* mtrr */, NULL /* pge */, NULL /* mca */, NULL /* cmov */,
-    NULL /* pat */, NULL /* pse36 */, NULL, NULL /* Linux mp */,
-    "nx|xd", NULL, "mmxext", NULL /* mmx */,
-    NULL /* fxsr */, "fxsr_opt|ffxsr", "pdpe1gb" /* AMD Page1GB */, "rdtscp",
-    NULL, "lm|i64", "3dnowext", "3dnow",
-};
-static const char *ext3_feature_name[] = {
-    "lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD ExtApicSpace */,
-    "cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
-    "3dnowprefetch", "osvw", "ibs", "xop",
-    "skinit", "wdt", NULL, "lwp",
-    "fma4", "tce", NULL, "nodeid_msr",
-    NULL, "tbm", "topoext", "perfctr_core",
-    "perfctr_nb", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *ext4_feature_name[] = {
-    NULL, NULL, "xstore", "xstore-en",
-    NULL, NULL, "xcrypt", "xcrypt-en",
-    "ace2", "ace2-en", "phe", "phe-en",
-    "pmm", "pmm-en", NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
-    "kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *svm_feature_name[] = {
-    "npt", "lbrv", "svm_lock", "nrip_save",
-    "tsc_scale", "vmcb_clean",  "flushbyasid", "decodeassists",
-    NULL, NULL, "pause_filter", NULL,
-    "pfthreshold", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL,
-};
-
-static const char *cpuid_7_0_ebx_feature_name[] = {
-    "fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
-    "bmi2", "erms", "invpcid", "rtm", NULL, NULL, NULL, NULL,
-    NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-};
-
 typedef struct FeatureWordInfo {
-    const char **feat_names;
     uint32_t cpuid_eax;   /* Input EAX for CPUID */
     bool cpuid_needs_ecx; /* CPUID instruction uses ECX as input */
     uint32_t cpuid_ecx;   /* Input ECX value for CPUID */
@@ -160,35 +69,27 @@ typedef struct FeatureWordInfo {
 
 static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
     [FEAT_1_EDX] = {
-        .feat_names = feature_name,
         .cpuid_eax = 1, .cpuid_reg = R_EDX,
     },
     [FEAT_1_ECX] = {
-        .feat_names = ext_feature_name,
         .cpuid_eax = 1, .cpuid_reg = R_ECX,
     },
     [FEAT_8000_0001_EDX] = {
-        .feat_names = ext2_feature_name,
         .cpuid_eax = 0x80000001, .cpuid_reg = R_EDX,
     },
     [FEAT_8000_0001_ECX] = {
-        .feat_names = ext3_feature_name,
         .cpuid_eax = 0x80000001, .cpuid_reg = R_ECX,
     },
     [FEAT_C000_0001_EDX] = {
-        .feat_names = ext4_feature_name,
         .cpuid_eax = 0xC0000001, .cpuid_reg = R_EDX,
     },
     [FEAT_KVM] = {
-        .feat_names = kvm_feature_name,
         .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
     },
     [FEAT_SVM] = {
-        .feat_names = svm_feature_name,
         .cpuid_eax = 0x8000000A, .cpuid_reg = R_EDX,
     },
     [FEAT_7_0_EBX] = {
-        .feat_names = cpuid_7_0_ebx_feature_name,
         .cpuid_eax = 7,
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
         .cpuid_reg = R_EBX,
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (27 preceding siblings ...)
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 21/21] target-i386: remove unused *_feature_name arrays Igor Mammedov
@ 2013-10-14 12:09 ` Igor Mammedov
  2013-10-14 18:05   ` Andreas Färber
  2013-10-15 12:27   ` Vadim Rozenfeld
  2013-11-25 16:56 ` Igor Mammedov
  2013-12-15 21:48 ` Andreas Färber
  30 siblings, 2 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-10-14 12:09 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Anthony Liguori, Eduardo Habkost, qemu-devel, Vadim Rozenfeld,
	Paolo Bonzini, Andreas Färber

On Tue, 16 Jul 2013 00:25:53 +0200
Igor Mammedov <imammedo@redhat.com> wrote:

> It's reordered and rebased v8 plus CPUID feature bits conversion to properties
> and cleanups that are removing unused anymore *_feature_name arrays.
> 
> dynamic => static properties conversion is still making sense as cleanup of
> initfn(), consolidating all properties in one place and making uniform
> property setters signatures, so it was kept.
> 
> hyperv and dynamic => static properties conversion are covered by virt-test's
> qemu_cpu test group.
> 
> On top of that, CPUID feature bits conversion and cleanups it's allowed.
> 
> git for testing: https://github.com/imammedo/qemu/tree/x86-cpu-properties.v9
> 
> v8-v9:
> * reorder hyperv/check/force and cpu_x86_parse_featurestr() cleanups to be the first
> * when converting dynamic properties inline custom DEFINE_PROP_FOO directly in
>   cpu_x86_properties property array. (req: afaerber)
> * change "f-" CPUID feature bits prefix to "feat-" (req: afaerber)
> * replace F_* macros with a single X86CPU_FEAT() macro and simplify it setting
> default value to 0, intended for defaults to be set by initfn()
> * kvmclock: fix endless loop on compat kvmclock2 append
> * converted check_features_against_host() and x86_cpu_list() to use
>   static properties definition for feature name lookups, removing along the way
>   unused anymore *_feature_name arrays.
> 
> v7-v8:
> * split out dynamic properties convertion patch into per property patches
>   to simplify review
> * drop feature bits convertion
> 
> v6-v7:
> * convert globals check_cpuid, enforce_cpuid and  hyperv_* to fields of
>   CPUState
> * Make PropertyInfo-s static
> * maintain legacy kvmclock semantic in cpu_x86_parse_featurestr()
> * existing properties code are not moved around, just fixed signatures where
>   it's needed and used visitors.
> 
> v5-v6:
> * when converting feature names to property names, replace '_' with '-'
> * separate patches converting existing dynamic properties into one, were
>   squashed into one [1/9] and change tested with virt-test(next).
> * patches that were touching +-foo features are squashed into one [9/9],
>   to avoid behavior change between them(f-kvmclock property).
> * the rest of conversions were basicaly rebased on top of current qom-cpu-next
>   tree, with small corrections
> 
> Igor Mammedov (20):
>   target-i386: Move hyperv_* static globals to X86CPU
>   target-i386: convert 'hv_spinlocks' to static property
>   target-i386: convert 'hv_relaxed' to static property
>   target-i386: convert 'hv_vapic' to static property
>   target-i386: convert 'check' and 'enforce' to static properties
>   target-i386: cleanup 'foo' feature handling'
>   target-i386: cleanup 'foo=val' feature handling
>   target-i386: cpu: convert 'level' to static property
>   target-i386: cpu: convert 'xlevel' to static property
>   target-i386: cpu: convert 'family' to static property
>   target-i386: cpu: convert 'model' to static property
>   target-i386: cpu: convert 'stepping' to static property
>   target-i386: cpu: convert 'vendor' to static property
>   target-i386: cpu: convert 'model-id' to static property
>   target-i386: cpu: convert 'tsc-frequency' to static property
>   target-i386: set [+-]feature using static properties
>   qdev: introduce qdev_prop_find_bit()
>   target-i386: use static properties in check_features_against_host() to
>     print CPUID feature names
>   target-i386: use static properties to list CPUID features
>   target-i386: remove unused *_feature_name arrays
> 
>  hw/core/qdev-properties.c    |  15 +
>  include/hw/qdev-properties.h |  13 +
>  target-i386/Makefile.objs    |   2 +-
>  target-i386/cpu-qom.h        |   6 +
>  target-i386/cpu.c            | 705 +++++++++++++++++++++----------------------
>  target-i386/cpu.h            |   4 +
>  target-i386/hyperv.c         |  64 ----
>  target-i386/hyperv.h         |  45 ---
>  target-i386/kvm.c            |  36 ++-
>  9 files changed, 415 insertions(+), 475 deletions(-)
>  delete mode 100644 target-i386/hyperv.c
>  delete mode 100644 target-i386/hyperv.h
> 

ping?

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

* Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
  2013-10-14 12:09 ` [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
@ 2013-10-14 18:05   ` Andreas Färber
  2013-10-15 12:27   ` Vadim Rozenfeld
  1 sibling, 0 replies; 41+ messages in thread
From: Andreas Färber @ 2013-10-14 18:05 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Paolo Bonzini, Anthony Liguori, Vadim Rozenfeld, qemu-devel,
	Eduardo Habkost

Am 14.10.2013 14:09, schrieb Igor Mammedov:
> On Tue, 16 Jul 2013 00:25:53 +0200
> Igor Mammedov <imammedo@redhat.com> wrote:
> 
>> It's reordered and rebased v8 plus CPUID feature bits conversion to properties
>> and cleanups that are removing unused anymore *_feature_name arrays.
>>
>> dynamic => static properties conversion is still making sense as cleanup of
>> initfn(), consolidating all properties in one place and making uniform
>> property setters signatures, so it was kept.
>>
>> hyperv and dynamic => static properties conversion are covered by virt-test's
>> qemu_cpu test group.
>>
>> On top of that, CPUID feature bits conversion and cleanups it's allowed.
>>
>> git for testing: https://github.com/imammedo/qemu/tree/x86-cpu-properties.v9
>>
>> v8-v9:
>> * reorder hyperv/check/force and cpu_x86_parse_featurestr() cleanups to be the first
>> * when converting dynamic properties inline custom DEFINE_PROP_FOO directly in
>>   cpu_x86_properties property array. (req: afaerber)
>> * change "f-" CPUID feature bits prefix to "feat-" (req: afaerber)
>> * replace F_* macros with a single X86CPU_FEAT() macro and simplify it setting
>> default value to 0, intended for defaults to be set by initfn()
>> * kvmclock: fix endless loop on compat kvmclock2 append
>> * converted check_features_against_host() and x86_cpu_list() to use
>>   static properties definition for feature name lookups, removing along the way
>>   unused anymore *_feature_name arrays.
>>
>> v7-v8:
>> * split out dynamic properties convertion patch into per property patches
>>   to simplify review
>> * drop feature bits convertion
>>
>> v6-v7:
>> * convert globals check_cpuid, enforce_cpuid and  hyperv_* to fields of
>>   CPUState
>> * Make PropertyInfo-s static
>> * maintain legacy kvmclock semantic in cpu_x86_parse_featurestr()
>> * existing properties code are not moved around, just fixed signatures where
>>   it's needed and used visitors.
>>
>> v5-v6:
>> * when converting feature names to property names, replace '_' with '-'
>> * separate patches converting existing dynamic properties into one, were
>>   squashed into one [1/9] and change tested with virt-test(next).
>> * patches that were touching +-foo features are squashed into one [9/9],
>>   to avoid behavior change between them(f-kvmclock property).
>> * the rest of conversions were basicaly rebased on top of current qom-cpu-next
>>   tree, with small corrections
>>
>> Igor Mammedov (20):
>>   target-i386: Move hyperv_* static globals to X86CPU
>>   target-i386: convert 'hv_spinlocks' to static property
>>   target-i386: convert 'hv_relaxed' to static property
>>   target-i386: convert 'hv_vapic' to static property
>>   target-i386: convert 'check' and 'enforce' to static properties
>>   target-i386: cleanup 'foo' feature handling'
>>   target-i386: cleanup 'foo=val' feature handling
>>   target-i386: cpu: convert 'level' to static property
>>   target-i386: cpu: convert 'xlevel' to static property
>>   target-i386: cpu: convert 'family' to static property
>>   target-i386: cpu: convert 'model' to static property
>>   target-i386: cpu: convert 'stepping' to static property
>>   target-i386: cpu: convert 'vendor' to static property
>>   target-i386: cpu: convert 'model-id' to static property
>>   target-i386: cpu: convert 'tsc-frequency' to static property
>>   target-i386: set [+-]feature using static properties
>>   qdev: introduce qdev_prop_find_bit()
>>   target-i386: use static properties in check_features_against_host() to
>>     print CPUID feature names
>>   target-i386: use static properties to list CPUID features
>>   target-i386: remove unused *_feature_name arrays
>>
>>  hw/core/qdev-properties.c    |  15 +
>>  include/hw/qdev-properties.h |  13 +
>>  target-i386/Makefile.objs    |   2 +-
>>  target-i386/cpu-qom.h        |   6 +
>>  target-i386/cpu.c            | 705 +++++++++++++++++++++----------------------
>>  target-i386/cpu.h            |   4 +
>>  target-i386/hyperv.c         |  64 ----
>>  target-i386/hyperv.h         |  45 ---
>>  target-i386/kvm.c            |  36 ++-
>>  9 files changed, 415 insertions(+), 475 deletions(-)
>>  delete mode 100644 target-i386/hyperv.c
>>  delete mode 100644 target-i386/hyperv.h
>>
> 
> ping?

Sorry, I'm lagging on all reviews. Part of the series had been queued
long ago but I excluded it from my last pull to get it in in one go.

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] 41+ messages in thread

* Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
  2013-10-14 12:09 ` [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
  2013-10-14 18:05   ` Andreas Färber
@ 2013-10-15 12:27   ` Vadim Rozenfeld
  1 sibling, 0 replies; 41+ messages in thread
From: Vadim Rozenfeld @ 2013-10-15 12:27 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Paolo Bonzini, Anthony Liguori, Eduardo Habkost,
	Andreas Färber, qemu-devel



----- Original Message -----
From: "Igor Mammedov" <imammedo@redhat.com>
To: "Igor Mammedov" <imammedo@redhat.com>
Cc: "Anthony Liguori" <aliguori@us.ibm.com>, "Eduardo Habkost" <ehabkost@redhat.com>, qemu-devel@nongnu.org, "Vadim Rozenfeld" <vrozenfe@redhat.com>, "Paolo Bonzini" <pbonzini@redhat.com>, "Andreas Färber" <afaerber@suse.de>
Sent: Monday, October 14, 2013 3:09:11 PM
Subject: Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties

On Tue, 16 Jul 2013 00:25:53 +0200
Igor Mammedov <imammedo@redhat.com> wrote:

> It's reordered and rebased v8 plus CPUID feature bits conversion to properties
> and cleanups that are removing unused anymore *_feature_name arrays.
> 
> dynamic => static properties conversion is still making sense as cleanup of
> initfn(), consolidating all properties in one place and making uniform
> property setters signatures, so it was kept.
> 
> hyperv and dynamic => static properties conversion are covered by virt-test's
> qemu_cpu test group.
> 
> On top of that, CPUID feature bits conversion and cleanups it's allowed.
> 
> git for testing: https://github.com/imammedo/qemu/tree/x86-cpu-properties.v9
> 
> v8-v9:
> * reorder hyperv/check/force and cpu_x86_parse_featurestr() cleanups to be the first
> * when converting dynamic properties inline custom DEFINE_PROP_FOO directly in
>   cpu_x86_properties property array. (req: afaerber)
> * change "f-" CPUID feature bits prefix to "feat-" (req: afaerber)
> * replace F_* macros with a single X86CPU_FEAT() macro and simplify it setting
> default value to 0, intended for defaults to be set by initfn()
> * kvmclock: fix endless loop on compat kvmclock2 append
> * converted check_features_against_host() and x86_cpu_list() to use
>   static properties definition for feature name lookups, removing along the way
>   unused anymore *_feature_name arrays.
> 
> v7-v8:
> * split out dynamic properties convertion patch into per property patches
>   to simplify review
> * drop feature bits convertion
> 
> v6-v7:
> * convert globals check_cpuid, enforce_cpuid and  hyperv_* to fields of
>   CPUState
> * Make PropertyInfo-s static
> * maintain legacy kvmclock semantic in cpu_x86_parse_featurestr()
> * existing properties code are not moved around, just fixed signatures where
>   it's needed and used visitors.
> 
> v5-v6:
> * when converting feature names to property names, replace '_' with '-'
> * separate patches converting existing dynamic properties into one, were
>   squashed into one [1/9] and change tested with virt-test(next).
> * patches that were touching +-foo features are squashed into one [9/9],
>   to avoid behavior change between them(f-kvmclock property).
> * the rest of conversions were basicaly rebased on top of current qom-cpu-next
>   tree, with small corrections
> 
> Igor Mammedov (20):
>   target-i386: Move hyperv_* static globals to X86CPU
>   target-i386: convert 'hv_spinlocks' to static property
>   target-i386: convert 'hv_relaxed' to static property
>   target-i386: convert 'hv_vapic' to static property
>   target-i386: convert 'check' and 'enforce' to static properties
>   target-i386: cleanup 'foo' feature handling'
>   target-i386: cleanup 'foo=val' feature handling
>   target-i386: cpu: convert 'level' to static property
>   target-i386: cpu: convert 'xlevel' to static property
>   target-i386: cpu: convert 'family' to static property
>   target-i386: cpu: convert 'model' to static property
>   target-i386: cpu: convert 'stepping' to static property
>   target-i386: cpu: convert 'vendor' to static property
>   target-i386: cpu: convert 'model-id' to static property
>   target-i386: cpu: convert 'tsc-frequency' to static property
>   target-i386: set [+-]feature using static properties
>   qdev: introduce qdev_prop_find_bit()
>   target-i386: use static properties in check_features_against_host() to
>     print CPUID feature names
>   target-i386: use static properties to list CPUID features
>   target-i386: remove unused *_feature_name arrays
> 
>  hw/core/qdev-properties.c    |  15 +
>  include/hw/qdev-properties.h |  13 +
>  target-i386/Makefile.objs    |   2 +-
>  target-i386/cpu-qom.h        |   6 +
>  target-i386/cpu.c            | 705 +++++++++++++++++++++----------------------
>  target-i386/cpu.h            |   4 +
>  target-i386/hyperv.c         |  64 ----
>  target-i386/hyperv.h         |  45 ---
>  target-i386/kvm.c            |  36 ++-
>  9 files changed, 415 insertions(+), 475 deletions(-)
>  delete mode 100644 target-i386/hyperv.c
>  delete mode 100644 target-i386/hyperv.h
> 

ping?

Hi Igor,
Looks fine with me.
Best regards,
Vadim.

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

* Re: [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties
  2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties Igor Mammedov
@ 2013-10-15 16:22   ` Igor Mammedov
  0 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-10-15 16:22 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Anthony Liguori, drjones, Eduardo Habkost, qemu-devel,
	Vadim Rozenfeld, Paolo Bonzini, Andreas Färber

On Tue, 16 Jul 2013 00:26:14 +0200
Igor Mammedov <imammedo@redhat.com> wrote:

...
> +    X86CPU_FEAT("feat-kvmclock",        0, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvm-nopiodelay",  1, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvm-mmu",         2, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvmclock2",       3, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvm-asyncpf",     4, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvm-steal-tm",    5, FEAT_KVM),
> +    X86CPU_FEAT("feat-kvm-pv-eoi",      6, FEAT_KVM),
+    X86CPU_FEAT("feat-kvm-pv-unhalt",   7, FEAT_KVM),


a minor update to patch due to commit 
   f010bc64 "target-i386: add feature kvm_pv_unhalt"

updated patch could be pulled from x86-cpu-properties.v10.1 tree
https://github.com/imammedo/qemu/commit/dcd75a2c9b1a62ecf99dee06a71b7a23bab769c7

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

* Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (28 preceding siblings ...)
  2013-10-14 12:09 ` [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
@ 2013-11-25 16:56 ` Igor Mammedov
  2013-12-15 21:48 ` Andreas Färber
  30 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-11-25 16:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber

On Tue, 16 Jul 2013 00:25:53 +0200
Igor Mammedov <imammedo@redhat.com> wrote:

> It's reordered and rebased v8 plus CPUID feature bits conversion to properties
> and cleanups that are removing unused anymore *_feature_name arrays.
> 
> dynamic => static properties conversion is still making sense as cleanup of
> initfn(), consolidating all properties in one place and making uniform
> property setters signatures, so it was kept.
> 
> hyperv and dynamic => static properties conversion are covered by virt-test's
> qemu_cpu test group.
> 
> On top of that, CPUID feature bits conversion and cleanups it's allowed.

Hello Andreas,

1.7 development is pretty much closed now, I hope you'd be able to find time
to pull this early in 1.8 development cycle.

> 
> git for testing: https://github.com/imammedo/qemu/tree/x86-cpu-properties.v9
> 
> v8-v9:
> * reorder hyperv/check/force and cpu_x86_parse_featurestr() cleanups to be the first
> * when converting dynamic properties inline custom DEFINE_PROP_FOO directly in
>   cpu_x86_properties property array. (req: afaerber)
> * change "f-" CPUID feature bits prefix to "feat-" (req: afaerber)
> * replace F_* macros with a single X86CPU_FEAT() macro and simplify it setting
> default value to 0, intended for defaults to be set by initfn()
> * kvmclock: fix endless loop on compat kvmclock2 append
> * converted check_features_against_host() and x86_cpu_list() to use
>   static properties definition for feature name lookups, removing along the way
>   unused anymore *_feature_name arrays.
> 
> v7-v8:
> * split out dynamic properties convertion patch into per property patches
>   to simplify review
> * drop feature bits convertion
> 
> v6-v7:
> * convert globals check_cpuid, enforce_cpuid and  hyperv_* to fields of
>   CPUState
> * Make PropertyInfo-s static
> * maintain legacy kvmclock semantic in cpu_x86_parse_featurestr()
> * existing properties code are not moved around, just fixed signatures where
>   it's needed and used visitors.
> 
> v5-v6:
> * when converting feature names to property names, replace '_' with '-'
> * separate patches converting existing dynamic properties into one, were
>   squashed into one [1/9] and change tested with virt-test(next).
> * patches that were touching +-foo features are squashed into one [9/9],
>   to avoid behavior change between them(f-kvmclock property).
> * the rest of conversions were basicaly rebased on top of current qom-cpu-next
>   tree, with small corrections
> 
> Igor Mammedov (20):
>   target-i386: Move hyperv_* static globals to X86CPU
>   target-i386: convert 'hv_spinlocks' to static property
>   target-i386: convert 'hv_relaxed' to static property
>   target-i386: convert 'hv_vapic' to static property
>   target-i386: convert 'check' and 'enforce' to static properties
>   target-i386: cleanup 'foo' feature handling'
>   target-i386: cleanup 'foo=val' feature handling
>   target-i386: cpu: convert 'level' to static property
>   target-i386: cpu: convert 'xlevel' to static property
>   target-i386: cpu: convert 'family' to static property
>   target-i386: cpu: convert 'model' to static property
>   target-i386: cpu: convert 'stepping' to static property
>   target-i386: cpu: convert 'vendor' to static property
>   target-i386: cpu: convert 'model-id' to static property
>   target-i386: cpu: convert 'tsc-frequency' to static property
>   target-i386: set [+-]feature using static properties
>   qdev: introduce qdev_prop_find_bit()
>   target-i386: use static properties in check_features_against_host() to
>     print CPUID feature names
>   target-i386: use static properties to list CPUID features
>   target-i386: remove unused *_feature_name arrays
> 
>  hw/core/qdev-properties.c    |  15 +
>  include/hw/qdev-properties.h |  13 +
>  target-i386/Makefile.objs    |   2 +-
>  target-i386/cpu-qom.h        |   6 +
>  target-i386/cpu.c            | 705 +++++++++++++++++++++----------------------
>  target-i386/cpu.h            |   4 +
>  target-i386/hyperv.c         |  64 ----
>  target-i386/hyperv.h         |  45 ---
>  target-i386/kvm.c            |  36 ++-
>  9 files changed, 415 insertions(+), 475 deletions(-)
>  delete mode 100644 target-i386/hyperv.c
>  delete mode 100644 target-i386/hyperv.h
> 
> -- 
> 1.8.3.1
> 
>



-- 
Regards,
  Igor

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

* Re: [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property Igor Mammedov
@ 2013-11-27 17:55   ` Andreas Färber
  2013-11-27 18:05     ` Paolo Bonzini
                       ` (2 more replies)
  0 siblings, 3 replies; 41+ messages in thread
From: Andreas Färber @ 2013-11-27 17:55 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel
  Cc: Paolo Bonzini, Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld

Am 16.07.2013 00:25, schrieb Igor Mammedov:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v2:
>  - rebase on top of hyperv_spinlock_attempts in X86CPU
> ---
>  target-i386/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 14e9c7e..00c2882 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
>      error_propagate(errp, err);
>  }
>  
> +static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> +                                 const char *name, Error **errp)
> +{
> +    X86CPU *cpu = X86_CPU(obj);
> +    int64_t value = cpu->hyperv_spinlock_attempts;
> +
> +    visit_type_int(v, &value, name, errp);
> +}
> +
> +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> +                                 const char *name, Error **errp)
> +{
> +    const int64_t min = 0xFFF;
> +    const int64_t max = UINT_MAX;
> +    X86CPU *cpu = X86_CPU(obj);
> +    int64_t value;
> +
> +    visit_type_int(v, &value, name, errp);
> +    if (error_is_set(errp)) {
> +        return;
> +    }

errp may be NULL. And if an Error gets raised here but not set to *errp
for lack of pointer, value might be uninitialized:
object_property_parse(obj, "not-a-number", "hv-spinlocks", NULL);
So we cannot rely on error_is_set(errp) but must use a local variable to
enforce any return. Fixed on qom-cpu-next as follows:

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 435b3b9..0a5a4f0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1611,10 +1611,12 @@ static void x86_set_hv_spinlocks(Object *obj,
Visitor *v, void *opaque,
     const int64_t min = 0xFFF;
     const int64_t max = UINT_MAX;
     X86CPU *cpu = X86_CPU(obj);
+    Error *err = NULL;
     int64_t value;

-    visit_type_int(v, &value, name, errp);
-    if (error_is_set(errp)) {
+    visit_type_int(v, &value, name, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }


https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next

Regards,
Andreas


> +
> +    if (value < min || value > max) {
> +        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
> +                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
> +                  object_get_typename(obj), name ? name : "null",
> +                  value, min, max);
> +        return;
> +    }
> +    cpu->hyperv_spinlock_attempts = value;
> +}
> +
> +static PropertyInfo qdev_prop_spinlocks = {
> +    .name  = "int",
> +    .get   = x86_get_hv_spinlocks,
> +    .set   = x86_set_hv_spinlocks,
> +};
> +
> +static Property cpu_x86_properties[] = {
> +    { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
>  static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
>  {
>      x86_def_t *def;
> @@ -1586,6 +1629,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
>              } else if (!strcmp(featurestr, "hv-spinlocks")) {
>                  char *err;
>                  const int min = 0xFFF;
> +                char num[32];
>                  numvalue = strtoul(val, &err, 0);
>                  if (!*val || *err) {
>                      error_setg(errp, "bad numerical value %s", val);
> @@ -1597,7 +1641,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
>                              min);
>                      numvalue = min;
>                  }
> -                cpu->hyperv_spinlock_attempts = numvalue;
> +                snprintf(num, sizeof(num), "%" PRId32, numvalue);
> +                object_property_parse(OBJECT(cpu), num, featurestr, errp);
>              } else {
>                  error_setg(errp, "unrecognized feature %s", featurestr);
>                  goto out;
> @@ -2521,6 +2566,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>      xcc->parent_realize = dc->realize;
>      dc->realize = x86_cpu_realizefn;
>      dc->bus_type = TYPE_ICC_BUS;
> +    dc->props = cpu_x86_properties;
>  
>      xcc->parent_reset = cc->reset;
>      cc->reset = x86_cpu_reset;

-- 
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 related	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property
  2013-11-27 17:55   ` Andreas Färber
@ 2013-11-27 18:05     ` Paolo Bonzini
  2013-11-27 18:21     ` Igor Mammedov
  2013-11-27 21:21     ` Igor Mammedov
  2 siblings, 0 replies; 41+ messages in thread
From: Paolo Bonzini @ 2013-11-27 18:05 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Igor Mammedov, Anthony Liguori, Vadim Rozenfeld, qemu-devel,
	Eduardo Habkost

Il 27/11/2013 18:55, Andreas Färber ha scritto:
> Am 16.07.2013 00:25, schrieb Igor Mammedov:
>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>> ---
>> v2:
>>  - rebase on top of hyperv_spinlock_attempts in X86CPU
>> ---
>>  target-i386/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 47 insertions(+), 1 deletion(-)
>>
>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
>> index 14e9c7e..00c2882 100644
>> --- a/target-i386/cpu.c
>> +++ b/target-i386/cpu.c
>> @@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
>>      error_propagate(errp, err);
>>  }
>>  
>> +static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
>> +                                 const char *name, Error **errp)
>> +{
>> +    X86CPU *cpu = X86_CPU(obj);
>> +    int64_t value = cpu->hyperv_spinlock_attempts;
>> +
>> +    visit_type_int(v, &value, name, errp);
>> +}
>> +
>> +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
>> +                                 const char *name, Error **errp)
>> +{
>> +    const int64_t min = 0xFFF;
>> +    const int64_t max = UINT_MAX;
>> +    X86CPU *cpu = X86_CPU(obj);
>> +    int64_t value;
>> +
>> +    visit_type_int(v, &value, name, errp);
>> +    if (error_is_set(errp)) {
>> +        return;
>> +    }
> 
> errp may be NULL. And if an Error gets raised here but not set to *errp
> for lack of pointer, value might be uninitialized:
> object_property_parse(obj, "not-a-number", "hv-spinlocks", NULL);
> So we cannot rely on error_is_set(errp) but must use a local variable to
> enforce any return. Fixed on qom-cpu-next as follows:
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 435b3b9..0a5a4f0 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1611,10 +1611,12 @@ static void x86_set_hv_spinlocks(Object *obj,
> Visitor *v, void *opaque,
>      const int64_t min = 0xFFF;
>      const int64_t max = UINT_MAX;
>      X86CPU *cpu = X86_CPU(obj);
> +    Error *err = NULL;
>      int64_t value;
> 
> -    visit_type_int(v, &value, name, errp);
> -    if (error_is_set(errp)) {
> +    visit_type_int(v, &value, name, &err);
> +    if (err) {
> +        error_propagate(errp, err);
>          return;
>      }

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property
  2013-11-27 17:55   ` Andreas Färber
  2013-11-27 18:05     ` Paolo Bonzini
@ 2013-11-27 18:21     ` Igor Mammedov
  2013-11-27 21:21     ` Igor Mammedov
  2 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-11-27 18:21 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Paolo Bonzini, Anthony Liguori, Vadim Rozenfeld, qemu-devel,
	Eduardo Habkost

On Wed, 27 Nov 2013 18:55:57 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 16.07.2013 00:25, schrieb Igor Mammedov:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > v2:
> >  - rebase on top of hyperv_spinlock_attempts in X86CPU
> > ---
> >  target-i386/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 47 insertions(+), 1 deletion(-)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 14e9c7e..00c2882 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
> >      error_propagate(errp, err);
> >  }
> >  
> > +static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> > +                                 const char *name, Error **errp)
> > +{
> > +    X86CPU *cpu = X86_CPU(obj);
> > +    int64_t value = cpu->hyperv_spinlock_attempts;
> > +
> > +    visit_type_int(v, &value, name, errp);
> > +}
> > +
> > +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> > +                                 const char *name, Error **errp)
> > +{
> > +    const int64_t min = 0xFFF;
> > +    const int64_t max = UINT_MAX;
> > +    X86CPU *cpu = X86_CPU(obj);
> > +    int64_t value;
> > +
> > +    visit_type_int(v, &value, name, errp);
> > +    if (error_is_set(errp)) {
> > +        return;
> > +    }
> 
> errp may be NULL. And if an Error gets raised here but not set to *errp
> for lack of pointer, value might be uninitialized:
> object_property_parse(obj, "not-a-number", "hv-spinlocks", NULL);
> So we cannot rely on error_is_set(errp) but must use a local variable to
> enforce any return. Fixed on qom-cpu-next as follows:

There is ~29 easily found instances of invalid use in current master, we
probably should fix them all.


> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 435b3b9..0a5a4f0 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1611,10 +1611,12 @@ static void x86_set_hv_spinlocks(Object *obj,
> Visitor *v, void *opaque,
>      const int64_t min = 0xFFF;
>      const int64_t max = UINT_MAX;
>      X86CPU *cpu = X86_CPU(obj);
> +    Error *err = NULL;
>      int64_t value;
> 
> -    visit_type_int(v, &value, name, errp);
> -    if (error_is_set(errp)) {
> +    visit_type_int(v, &value, name, &err);
> +    if (err) {
> +        error_propagate(errp, err);
>          return;
>      }
> 
> 
> https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next
Reviewed-By: Igor Mammedov <imammedo@redhat.com>


> 
> Regards,
> Andreas
> 
> 
> > +
> > +    if (value < min || value > max) {
> > +        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
> > +                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
> > +                  object_get_typename(obj), name ? name : "null",
> > +                  value, min, max);
> > +        return;
> > +    }
> > +    cpu->hyperv_spinlock_attempts = value;
> > +}
> > +
> > +static PropertyInfo qdev_prop_spinlocks = {
> > +    .name  = "int",
> > +    .get   = x86_get_hv_spinlocks,
> > +    .set   = x86_set_hv_spinlocks,
> > +};
> > +
> > +static Property cpu_x86_properties[] = {
> > +    { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
> > +    DEFINE_PROP_END_OF_LIST(),
> > +};
> > +
> >  static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
> >  {
> >      x86_def_t *def;
> > @@ -1586,6 +1629,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
> >              } else if (!strcmp(featurestr, "hv-spinlocks")) {
> >                  char *err;
> >                  const int min = 0xFFF;
> > +                char num[32];
> >                  numvalue = strtoul(val, &err, 0);
> >                  if (!*val || *err) {
> >                      error_setg(errp, "bad numerical value %s", val);
> > @@ -1597,7 +1641,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
> >                              min);
> >                      numvalue = min;
> >                  }
> > -                cpu->hyperv_spinlock_attempts = numvalue;
> > +                snprintf(num, sizeof(num), "%" PRId32, numvalue);
> > +                object_property_parse(OBJECT(cpu), num, featurestr, errp);
> >              } else {
> >                  error_setg(errp, "unrecognized feature %s", featurestr);
> >                  goto out;
> > @@ -2521,6 +2566,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
> >      xcc->parent_realize = dc->realize;
> >      dc->realize = x86_cpu_realizefn;
> >      dc->bus_type = TYPE_ICC_BUS;
> > +    dc->props = cpu_x86_properties;
> >  
> >      xcc->parent_reset = cc->reset;
> >      cc->reset = x86_cpu_reset;
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg


-- 
Regards,
  Igor

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

* Re: [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property
  2013-11-27 17:55   ` Andreas Färber
  2013-11-27 18:05     ` Paolo Bonzini
  2013-11-27 18:21     ` Igor Mammedov
@ 2013-11-27 21:21     ` Igor Mammedov
  2 siblings, 0 replies; 41+ messages in thread
From: Igor Mammedov @ 2013-11-27 21:21 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Paolo Bonzini, Anthony Liguori, Vadim Rozenfeld, qemu-devel,
	Eduardo Habkost

On Wed, 27 Nov 2013 18:55:57 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 16.07.2013 00:25, schrieb Igor Mammedov:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > v2:
> >  - rebase on top of hyperv_spinlock_attempts in X86CPU
> > ---
> >  target-i386/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 47 insertions(+), 1 deletion(-)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 14e9c7e..00c2882 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
> >      error_propagate(errp, err);
> >  }
> >  
> > +static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> > +                                 const char *name, Error **errp)
> > +{
> > +    X86CPU *cpu = X86_CPU(obj);
> > +    int64_t value = cpu->hyperv_spinlock_attempts;
> > +
> > +    visit_type_int(v, &value, name, errp);
> > +}
> > +
> > +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> > +                                 const char *name, Error **errp)
> > +{
> > +    const int64_t min = 0xFFF;
> > +    const int64_t max = UINT_MAX;
> > +    X86CPU *cpu = X86_CPU(obj);
> > +    int64_t value;
> > +
> > +    visit_type_int(v, &value, name, errp);
> > +    if (error_is_set(errp)) {
> > +        return;
> > +    }
> 
> errp may be NULL. And if an Error gets raised here but not set to *errp
> for lack of pointer, value might be uninitialized:
> object_property_parse(obj, "not-a-number", "hv-spinlocks", NULL);
> So we cannot rely on error_is_set(errp) but must use a local variable to
> enforce any return. Fixed on qom-cpu-next as follows:
in this particular above couldn't happen since all callers provide
not NULL errp. But it'd be cleaner to be prepared for generic case.

But anyway any caller that supplies invalid value && NULL errp
are going to get object in incorrect state and suffer later from it.

> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 435b3b9..0a5a4f0 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1611,10 +1611,12 @@ static void x86_set_hv_spinlocks(Object *obj,
> Visitor *v, void *opaque,
>      const int64_t min = 0xFFF;
>      const int64_t max = UINT_MAX;
>      X86CPU *cpu = X86_CPU(obj);
> +    Error *err = NULL;
>      int64_t value;
> 
> -    visit_type_int(v, &value, name, errp);
> -    if (error_is_set(errp)) {
> +    visit_type_int(v, &value, name, &err);
> +    if (err) {
> +        error_propagate(errp, err);
>          return;
>      }
> 
> 
> https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next
> 
> Regards,
> Andreas
> 
> 
> > +
> > +    if (value < min || value > max) {
> > +        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
> > +                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
> > +                  object_get_typename(obj), name ? name : "null",
> > +                  value, min, max);
> > +        return;
> > +    }
> > +    cpu->hyperv_spinlock_attempts = value;
> > +}
> > +
> > +static PropertyInfo qdev_prop_spinlocks = {
> > +    .name  = "int",
> > +    .get   = x86_get_hv_spinlocks,
> > +    .set   = x86_set_hv_spinlocks,
> > +};
> > +
> > +static Property cpu_x86_properties[] = {
> > +    { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
> > +    DEFINE_PROP_END_OF_LIST(),
> > +};
> > +
> >  static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
> >  {
> >      x86_def_t *def;
> > @@ -1586,6 +1629,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
> >              } else if (!strcmp(featurestr, "hv-spinlocks")) {
> >                  char *err;
> >                  const int min = 0xFFF;
> > +                char num[32];
> >                  numvalue = strtoul(val, &err, 0);
> >                  if (!*val || *err) {
> >                      error_setg(errp, "bad numerical value %s", val);
> > @@ -1597,7 +1641,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
> >                              min);
> >                      numvalue = min;
> >                  }
> > -                cpu->hyperv_spinlock_attempts = numvalue;
> > +                snprintf(num, sizeof(num), "%" PRId32, numvalue);
> > +                object_property_parse(OBJECT(cpu), num, featurestr, errp);
> >              } else {
> >                  error_setg(errp, "unrecognized feature %s", featurestr);
> >                  goto out;
> > @@ -2521,6 +2566,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
> >      xcc->parent_realize = dc->realize;
> >      dc->realize = x86_cpu_realizefn;
> >      dc->bus_type = TYPE_ICC_BUS;
> > +    dc->props = cpu_x86_properties;
> >  
> >      xcc->parent_reset = cc->reset;
> >      cc->reset = x86_cpu_reset;
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
> 


-- 
Regards,
  Igor

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

* Re: [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties
  2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
                   ` (29 preceding siblings ...)
  2013-11-25 16:56 ` Igor Mammedov
@ 2013-12-15 21:48 ` Andreas Färber
  30 siblings, 0 replies; 41+ messages in thread
From: Andreas Färber @ 2013-12-15 21:48 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel
  Cc: Paolo Bonzini, Eduardo Habkost, Anthony Liguori, Vadim Rozenfeld

Am 16.07.2013 00:25, schrieb Igor Mammedov:
> Igor Mammedov (20):
>   target-i386: Move hyperv_* static globals to X86CPU

This one had been applied in modified form separately.

>   target-i386: convert 'hv_spinlocks' to static property
>   target-i386: convert 'hv_relaxed' to static property
>   target-i386: convert 'hv_vapic' to static property

I had queued these with a minor modification on qom-cpu-next:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next

Andreas

>   target-i386: convert 'check' and 'enforce' to static properties
>   target-i386: cleanup 'foo' feature handling'
>   target-i386: cleanup 'foo=val' feature handling
>   target-i386: cpu: convert 'level' to static property
>   target-i386: cpu: convert 'xlevel' to static property
>   target-i386: cpu: convert 'family' to static property
>   target-i386: cpu: convert 'model' to static property
>   target-i386: cpu: convert 'stepping' to static property
>   target-i386: cpu: convert 'vendor' to static property
>   target-i386: cpu: convert 'model-id' to static property
>   target-i386: cpu: convert 'tsc-frequency' to static property
>   target-i386: set [+-]feature using static properties
>   qdev: introduce qdev_prop_find_bit()
>   target-i386: use static properties in check_features_against_host() to
>     print CPUID feature names
>   target-i386: use static properties to list CPUID features
>   target-i386: remove unused *_feature_name arrays

-- 
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] 41+ messages in thread

* Re: [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling'
  2013-07-15 22:25 ` [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling' Igor Mammedov
@ 2013-12-16 16:51   ` Eric Blake
  2013-12-19 16:32     ` Andreas Färber
  0 siblings, 1 reply; 41+ messages in thread
From: Eric Blake @ 2013-12-16 16:51 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel
  Cc: Paolo Bonzini, Anthony Liguori, Eduardo Habkost,
	Andreas Färber, Vadim Rozenfeld

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

On 07/15/2013 04:25 PM, Igor Mammedov wrote:
> features check, enforce, hv_relaxed and hv_vapic are treated as boolean set to 'on'
> when passed from command line, so it's not neccessary to handle each of them

s/neccessary/necessary/

> separetly. Collapse them to one catch-all branch which will treat

s/separetly/separately/

> any feature in format 'foo' as boolean set to 'on'.
> 
> PS:
> Any unknown feature will be rejected by CPU property setter so there is no
> need to check for unknown feature in cpu_x86_parse_featurestr(), therefore
> it's replaced by above mentioned catch-all handler.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> ---

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

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

* Re: [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling'
  2013-12-16 16:51   ` Eric Blake
@ 2013-12-19 16:32     ` Andreas Färber
  0 siblings, 0 replies; 41+ messages in thread
From: Andreas Färber @ 2013-12-19 16:32 UTC (permalink / raw)
  To: Eric Blake, Igor Mammedov, qemu-devel
  Cc: Paolo Bonzini, Anthony Liguori, Eduardo Habkost, Vadim Rozenfeld

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 16.12.2013 17:51, schrieb Eric Blake:
> On 07/15/2013 04:25 PM, Igor Mammedov wrote:
>> features check, enforce, hv_relaxed and hv_vapic are treated as
>> boolean set to 'on' when passed from command line, so it's not
>> neccessary to handle each of them
> 
> s/neccessary/necessary/
> 
>> separetly. Collapse them to one catch-all branch which will
>> treat
> 
> s/separetly/separately/

This one I had already fixed, thanks for pointing out the other one.

Andreas

> 
>> any feature in format 'foo' as boolean set to 'on'.
>> 
>> PS: Any unknown feature will be rejected by CPU property setter
>> so there is no need to check for unknown feature in
>> cpu_x86_parse_featurestr(), therefore it's replaced by above
>> mentioned catch-all handler.
>> 
>> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by:
>> Eduardo Habkost <ehabkost@redhat.com> ---
> 


- -- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJSsx+VAAoJEPou0S0+fgE/RRwP/jy32I+CSASdk1WXiFWgWD0d
00V5JNxp2YRPGfHIOJJKSlrJnBa67DpwCq0XlbqJTf54J78DhpMQGNWUde8rlKJw
JR7d0SjmEt13zhOJJVZgmuNHznw5bo0VibfWRxnZ/7xmU+ZBXhgOGnsmtCr3sAfH
351wAx+5dkRWg1zo/wuM7gkQfkL8vMVzThlNaZJeNt3xHqoH97uGBhbC2Nl9u2kP
MKkqv26Fzons4GquG3eJvSXQOat2x7+uo1WTkNETWlJC+AWOzVGA0K2FSXLjQexY
2JmE4wV+6MYxAMJCqfs7QtvJOcRRFmO+Qz/DwOH62zVZL+gVfOUErzBD5ka16Bou
6kVrXuqf21lOiLLxed8WtTPjxVKcRUgBUyu9SgD7QP31DDI8f3/mGtH1r1nUaM3v
WXW2yzd8yKCaxxjONeUmVT5srtgRRRUWRFmyiByoBH4l7SoYP85ycbqXHuO/jBnY
Wd7Mciw1gcW29PofaUgJTFDJheLWw4xLo/z6ZysxFQrbaBFeo+u7pESigxrgYQ+c
BKDofJEYPAjKLrm/r365yRgnBU6iQ6Il5qKt9Dtk6f1XeuC42txV0HrDJu+Y/8f7
XH40uVfsadRye+WodZU9/E8MUn4bo34/JMm4CoT8CbVoWltoU2gCAAqrfF9LOflR
s+DEEdic7Tca4ZLPGAyg
=4UKD
-----END PGP SIGNATURE-----

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

end of thread, other threads:[~2013-12-19 16:32 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 22:25 [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 01/20] target-i386: Move hyperv_* static globals to X86CPU Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property Igor Mammedov
2013-11-27 17:55   ` Andreas Färber
2013-11-27 18:05     ` Paolo Bonzini
2013-11-27 18:21     ` Igor Mammedov
2013-11-27 21:21     ` Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 03/20] target-i386: convert 'hv_relaxed' " Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 04/20] target-i386: convert 'hv_vapic' " Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 05/20] target-i386: convert 'check' and 'enforce' to static properties Igor Mammedov
2013-07-15 22:25 ` [Qemu-devel] [PATCH 06/20] target-i386: cleanup 'foo' feature handling' Igor Mammedov
2013-12-16 16:51   ` Eric Blake
2013-12-19 16:32     ` Andreas Färber
2013-07-15 22:26 ` [Qemu-devel] [PATCH 07/20] target-i386: cleanup 'foo=val' feature handling Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 08/20] target-i386: cpu: convert 'level' to static property Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 09/20] target-i386: cpu: convert 'xlevel' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 10/20] target-i386: cpu: convert 'family' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 11/20] target-i386: cpu: convert 'model' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 12/20] target-i386: cpu: convert 'stepping' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 13/20] target-i386: cpu: convert 'vendor' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 14/20] target-i386: cpu: convert 'model-id' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/20] target-i386: cpu: convert 'tsc-frequency' " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 15/21] target-i386: cpu: substitute '_' with '-' for +-foo feature bits as well Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/21] target-i386: cpu: convert 'tsc-frequency' to static property Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 16/20] target-i386: set [+-]feature using static properties Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/20] qdev: introduce qdev_prop_find_bit() Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 17/21] target-i386: set [+-]feature using static properties Igor Mammedov
2013-10-15 16:22   ` Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/21] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 18/20] target-i386: use static properties in check_features_against_host() to print CPUID feature names Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/21] " Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 19/20] target-i386: use static properties to list CPUID features Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/20] target-i386: remove unused *_feature_name arrays Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 20/21] target-i386: use static properties to list CPUID features Igor Mammedov
2013-07-15 22:26 ` [Qemu-devel] [PATCH 21/21] target-i386: remove unused *_feature_name arrays Igor Mammedov
2013-10-14 12:09 ` [Qemu-devel] [PATCH qom-cpu 00/21 v9] target-i386: convert CPU features into properties Igor Mammedov
2013-10-14 18:05   ` Andreas Färber
2013-10-15 12:27   ` Vadim Rozenfeld
2013-11-25 16:56 ` Igor Mammedov
2013-12-15 21:48 ` 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.