qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init()
@ 2016-04-09 20:37 Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 1/4] osdep: Move default qemu_hw_version() value to a macro Eduardo Habkost
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Eduardo Habkost @ 2016-04-09 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andreas Färber, Michael S. Tsirkin, Marcel Apfelbaum,
	Igor Mammedov

The only reason cpudef_init() still exists is the
qemu_hw_version()-based model_id hack at x86_cpudef_setup().

Move the model_id hack to machine compat_props so we can make the
model_id field constant at the CPU model table, and then remove
cpudef_init() completely.

Eduardo Habkost (4):
  osdep: Move default qemu_hw_version() value to a macro
  pc: Set CPU model-id on compat_props for pc <= 2.4
  target-i386: Set constant model_id for qemu63/qemu32/athlon
  cpu: Eliminate cpudef_init(), cpudef_setup()

 arch_init.c                |  7 -------
 bsd-user/main.c            |  3 ---
 hw/i386/pc_piix.c          | 12 +++++++++++-
 include/hw/i386/pc.h       | 29 +++++++++++++++++++++++++++++
 include/qemu/osdep.h       |  9 +++++++++
 include/sysemu/arch_init.h |  1 -
 linux-user/main.c          |  3 ---
 target-i386/cpu.c          | 27 +++------------------------
 target-i386/cpu.h          |  2 --
 util/osdep.c               |  9 +--------
 vl.c                       |  7 -------
 11 files changed, 53 insertions(+), 56 deletions(-)

-- 
2.1.0

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

* [Qemu-devel] [PATCH for-2.7 1/4] osdep: Move default qemu_hw_version() value to a macro
  2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
@ 2016-04-09 20:37 ` Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4 Eduardo Habkost
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2016-04-09 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andreas Färber, Michael S. Tsirkin, Marcel Apfelbaum,
	Igor Mammedov

The macro will be used by code that will stop calling
qemu_hw_version() at runtime and just need a constant value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qemu/osdep.h | 9 +++++++++
 util/osdep.c         | 9 +--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 408783f..1ad2fcb 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -298,6 +298,15 @@ static inline void qemu_timersub(const struct timeval *val1,
 
 void qemu_set_cloexec(int fd);
 
+/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
+ * instead of QEMU_VERSION, so setting hw_version on MachineClass
+ * is no longer mandatory.
+ *
+ * Do NOT change this string, or it will break compatibility on all
+ * machine classes that don't set hw_version.
+ */
+#define QEMU_HW_VERSION "2.5+"
+
 /* QEMU "hardware version" setting. Used to replace code that exposed
  * QEMU_VERSION to guests in the past and need to keep compatibilty.
  * Do not use qemu_hw_version() in new code.
diff --git a/util/osdep.c b/util/osdep.c
index d56d071..9a7a439 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -44,14 +44,7 @@ extern int madvise(caddr_t, size_t, int);
 
 static bool fips_enabled = false;
 
-/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
- * instead of QEMU_VERSION, so setting hw_version on MachineClass
- * is no longer mandatory.
- *
- * Do NOT change this string, or it will break compatibility on all
- * machine classes that don't set hw_version.
- */
-static const char *hw_version = "2.5+";
+static const char *hw_version = QEMU_HW_VERSION;
 
 int socket_set_cork(int fd, int v)
 {
-- 
2.1.0

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

* [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4
  2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 1/4] osdep: Move default qemu_hw_version() value to a macro Eduardo Habkost
@ 2016-04-09 20:37 ` Eduardo Habkost
  2016-05-10 15:37   ` Michael S. Tsirkin
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 3/4] target-i386: Set constant model_id for qemu63/qemu32/athlon Eduardo Habkost
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Eduardo Habkost @ 2016-04-09 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andreas Färber, Michael S. Tsirkin, Marcel Apfelbaum,
	Igor Mammedov

Instead of relying on x86_cpudef_setup() calling
qemu_hw_version(), just make old machines set model-id explicitly
on compat_props for qemu64, qemu32, and athlon. This will allow
us to eliminate x86_cpudef_setup() later.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/pc_piix.c    | 12 +++++++++++-
 include/hw/i386/pc.h | 29 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7f50116..25e04e4 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -583,6 +583,7 @@ DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
 
 #define PC_COMPAT_1_3 \
         PC_COMPAT_1_4 \
+        PC_CPU_MODEL_IDS("1.3.0") \
         {\
             .driver   = "usb-tablet",\
             .property = "usb_version",\
@@ -615,6 +616,7 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
 
 #define PC_COMPAT_1_2 \
         PC_COMPAT_1_3 \
+        PC_CPU_MODEL_IDS("1.2.0") \
         {\
             .driver   = "nec-usb-xhci",\
             .property = "msi",\
@@ -654,6 +656,7 @@ DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
 
 #define PC_COMPAT_1_1 \
         PC_COMPAT_1_2 \
+        PC_CPU_MODEL_IDS("1.1.0") \
         {\
             .driver   = "virtio-scsi-pci",\
             .property = "hotplug",\
@@ -697,6 +700,7 @@ DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
 
 #define PC_COMPAT_1_0 \
         PC_COMPAT_1_1 \
+        PC_CPU_MODEL_IDS("1.0") \
         {\
             .driver   = TYPE_ISA_FDC,\
             .property = "check_media_rate",\
@@ -727,7 +731,8 @@ DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
 
 
 #define PC_COMPAT_0_15 \
-        PC_COMPAT_1_0
+        PC_COMPAT_1_0 \
+        PC_CPU_MODEL_IDS("0.15")
 
 static void pc_i440fx_0_15_machine_options(MachineClass *m)
 {
@@ -742,6 +747,7 @@ DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
 
 #define PC_COMPAT_0_14 \
         PC_COMPAT_0_15 \
+        PC_CPU_MODEL_IDS("0.14") \
         {\
             .driver   = "virtio-blk-pci",\
             .property = "event_idx",\
@@ -781,6 +787,7 @@ DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
 
 #define PC_COMPAT_0_13 \
         PC_COMPAT_0_14 \
+        PC_CPU_MODEL_IDS("0.13") \
         {\
             .driver   = TYPE_PCI_DEVICE,\
             .property = "command_serr_enable",\
@@ -818,6 +825,7 @@ DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
 
 #define PC_COMPAT_0_12 \
         PC_COMPAT_0_13 \
+        PC_CPU_MODEL_IDS("0.12") \
         {\
             .driver   = "virtio-serial-pci",\
             .property = "max_ports",\
@@ -853,6 +861,7 @@ DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
 
 #define PC_COMPAT_0_11 \
         PC_COMPAT_0_12 \
+        PC_CPU_MODEL_IDS("0.11") \
         {\
             .driver   = "virtio-blk-pci",\
             .property = "vectors",\
@@ -884,6 +893,7 @@ DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
 
 #define PC_COMPAT_0_10 \
     PC_COMPAT_0_11 \
+    PC_CPU_MODEL_IDS("0.10") \
     {\
         .driver   = "virtio-blk-pci",\
         .property = "class",\
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 96f0b66..5639979 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -359,9 +359,30 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_5 \
     HW_COMPAT_2_5
 
+/* Helper for setting model-id for CPU models that changed model-id
+ * depending on QEMU versions up to QEMU 2.4.
+ */
+#define PC_CPU_MODEL_IDS(v) \
+    {\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model-id",\
+        .value    = "QEMU Virtual CPU version " v,\
+    },\
+    {\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model-id",\
+        .value    = "QEMU Virtual CPU version " v,\
+    },\
+    {\
+        .driver   = "athlon-" TYPE_X86_CPU,\
+        .property = "model-id",\
+        .value    = "QEMU Virtual CPU version " v,\
+    },
+
 #define PC_COMPAT_2_4 \
     PC_COMPAT_2_5 \
     HW_COMPAT_2_4 \
+    PC_CPU_MODEL_IDS("2.4.0") \
     {\
         .driver   = "Haswell-" TYPE_X86_CPU,\
         .property = "abm",\
@@ -433,6 +454,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_3 \
     PC_COMPAT_2_4 \
     HW_COMPAT_2_3 \
+    PC_CPU_MODEL_IDS("2.3.0") \
     {\
         .driver   = TYPE_X86_CPU,\
         .property = "arat",\
@@ -514,6 +536,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_2 \
     PC_COMPAT_2_3 \
     HW_COMPAT_2_2 \
+    PC_CPU_MODEL_IDS("2.3.0") \
     {\
         .driver = "kvm64" "-" TYPE_X86_CPU,\
         .property = "vme",\
@@ -608,6 +631,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_1 \
     PC_COMPAT_2_2 \
     HW_COMPAT_2_1 \
+    PC_CPU_MODEL_IDS("2.1.0") \
     {\
         .driver = "coreduo" "-" TYPE_X86_CPU,\
         .property = "vmx",\
@@ -621,6 +645,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
     PC_COMPAT_2_1 \
+    PC_CPU_MODEL_IDS("2.0.0") \
     {\
         .driver   = "virtio-scsi-pci",\
         .property = "any_layout",\
@@ -681,6 +706,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_1_7 \
     PC_COMPAT_2_0 \
+    PC_CPU_MODEL_IDS("1.7.0") \
     {\
         .driver   = TYPE_USB_DEVICE,\
         .property = "msos-desc",\
@@ -699,6 +725,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_1_6 \
     PC_COMPAT_1_7 \
+    PC_CPU_MODEL_IDS("1.6.0") \
     {\
         .driver   = "e1000",\
         .property = "mitigation",\
@@ -723,6 +750,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_1_5 \
     PC_COMPAT_1_6 \
+    PC_CPU_MODEL_IDS("1.5.0") \
     {\
         .driver   = "Conroe-" TYPE_X86_CPU,\
         .property = "model",\
@@ -767,6 +795,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_1_4 \
     PC_COMPAT_1_5 \
+    PC_CPU_MODEL_IDS("1.4.0") \
     {\
         .driver   = "scsi-hd",\
         .property = "discard_granularity",\
-- 
2.1.0

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

* [Qemu-devel] [PATCH for-2.7 3/4] target-i386: Set constant model_id for qemu63/qemu32/athlon
  2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 1/4] osdep: Move default qemu_hw_version() value to a macro Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4 Eduardo Habkost
@ 2016-04-09 20:37 ` Eduardo Habkost
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 4/4] cpu: Eliminate cpudef_init(), cpudef_setup() Eduardo Habkost
  2016-05-11 19:21 ` [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
  4 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2016-04-09 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andreas Färber, Michael S. Tsirkin, Marcel Apfelbaum,
	Igor Mammedov

Newer PC machines don't set hw_version, and older machines set
model-id on compat_props explicitly, so we don't need the
x86_cpudef_setup() code that sets model_id using
qemu_hw_version() anymore.

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

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index ddae932..ccee5c9 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -702,6 +702,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM,
         .xlevel = 0x8000000A,
+        .model_id = "QEMU Virtual CPU version " QEMU_HW_VERSION,
     },
     {
         .name = "phenom",
@@ -798,6 +799,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3,
         .xlevel = 0x80000004,
+        .model_id = "QEMU Virtual CPU version " QEMU_HW_VERSION,
     },
     {
         .name = "kvm32",
@@ -894,6 +896,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_MMXEXT | CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT,
         .xlevel = 0x80000008,
+        .model_id = "QEMU Virtual CPU version " QEMU_HW_VERSION,
     },
     {
         .name = "n270",
@@ -2263,28 +2266,8 @@ void cpu_clear_apic_feature(CPUX86State *env)
 
 #endif /* !CONFIG_USER_ONLY */
 
-/* Initialize list of CPU models, filling some non-static fields if necessary
- */
 void x86_cpudef_setup(void)
 {
-    int i, j;
-    static const char *model_with_versions[] = { "qemu32", "qemu64", "athlon" };
-
-    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) {
-        X86CPUDefinition *def = &builtin_x86_defs[i];
-
-        /* Look for specific "cpudef" models that */
-        /* have the QEMU version in .model_id */
-        for (j = 0; j < ARRAY_SIZE(model_with_versions); j++) {
-            if (strcmp(model_with_versions[j], def->name) == 0) {
-                pstrcpy(def->model_id, sizeof(def->model_id),
-                        "QEMU Virtual CPU version ");
-                pstrcat(def->model_id, sizeof(def->model_id),
-                        qemu_hw_version());
-                break;
-            }
-        }
-    }
 }
 
 void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
-- 
2.1.0

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

* [Qemu-devel] [PATCH for-2.7 4/4] cpu: Eliminate cpudef_init(), cpudef_setup()
  2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
                   ` (2 preceding siblings ...)
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 3/4] target-i386: Set constant model_id for qemu63/qemu32/athlon Eduardo Habkost
@ 2016-04-09 20:37 ` Eduardo Habkost
  2016-05-11 19:21 ` [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
  4 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2016-04-09 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andreas Färber, Michael S. Tsirkin, Marcel Apfelbaum,
	Igor Mammedov

x86_cpudef_init() doesn't do anything anymore, cpudef_init(),
cpudef_setup(), and x86_cpudef_init() can be finally removed.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 arch_init.c                | 7 -------
 bsd-user/main.c            | 3 ---
 include/sysemu/arch_init.h | 1 -
 linux-user/main.c          | 3 ---
 target-i386/cpu.c          | 4 ----
 target-i386/cpu.h          | 2 --
 vl.c                       | 7 -------
 7 files changed, 27 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index e3bb1b3..74e7484 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -272,13 +272,6 @@ void do_smbios_option(QemuOpts *opts)
 #endif
 }
 
-void cpudef_init(void)
-{
-#if defined(cpudef_setup)
-    cpudef_setup(); /* parse cpu definitions in target config file */
-#endif
-}
-
 int kvm_available(void)
 {
 #ifdef CONFIG_KVM
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 27854c1..83f2d24 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -752,9 +752,6 @@ int main(int argc, char **argv)
     }
 
     cpu_model = NULL;
-#if defined(cpudef_setup)
-    cpudef_setup(); /* parse cpu definitions in target config file (TBD) */
-#endif
 
     optind = 1;
     for(;;) {
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index c38892f..d690dfa 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -30,7 +30,6 @@ extern const uint32_t arch_type;
 void select_soundhw(const char *optarg);
 void do_acpitable_option(const QemuOpts *opts);
 void do_smbios_option(QemuOpts *opts);
-void cpudef_init(void);
 void audio_init(void);
 int kvm_available(void);
 int xen_available(void);
diff --git a/linux-user/main.c b/linux-user/main.c
index 5f3ec97..52e87bf 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4152,9 +4152,6 @@ int main(int argc, char **argv, char **envp)
     }
 
     cpu_model = NULL;
-#if defined(cpudef_setup)
-    cpudef_setup(); /* parse cpu definitions in target config file (TBD) */
-#endif
 
     srand(time(NULL));
 
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index ccee5c9..a115ec6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2266,10 +2266,6 @@ void cpu_clear_apic_feature(CPUX86State *env)
 
 #endif /* !CONFIG_USER_ONLY */
 
-void x86_cpudef_setup(void)
-{
-}
-
 void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 732eb6d..213b92a 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1034,7 +1034,6 @@ X86CPU *cpu_x86_init(const char *cpu_model);
 X86CPU *cpu_x86_create(const char *cpu_model, Error **errp);
 int cpu_x86_exec(CPUState *cpu);
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf);
-void x86_cpudef_setup(void);
 int cpu_x86_support_mca_broadcast(CPUX86State *env);
 
 int cpu_get_pic_interrupt(CPUX86State *s);
@@ -1212,7 +1211,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define cpu_exec cpu_x86_exec
 #define cpu_signal_handler cpu_x86_signal_handler
 #define cpu_list x86_cpu_list
-#define cpudef_setup x86_cpudef_setup
 
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _ksmap
diff --git a/vl.c b/vl.c
index 9df534f..27f316f 100644
--- a/vl.c
+++ b/vl.c
@@ -4080,13 +4080,6 @@ int main(int argc, char **argv, char **envp)
         qemu_set_hw_version(machine_class->hw_version);
     }
 
-    /* Init CPU def lists, based on config
-     * - Must be called after all the qemu_read_config_file() calls
-     * - Must be called before list_cpus()
-     * - Must be called before machine->init()
-     */
-    cpudef_init();
-
     if (cpu_model && is_help_option(cpu_model)) {
         list_cpus(stdout, &fprintf, cpu_model);
         exit(0);
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4 Eduardo Habkost
@ 2016-05-10 15:37   ` Michael S. Tsirkin
  0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2016-05-10 15:37 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Andreas Färber, Marcel Apfelbaum, Igor Mammedov

On Sat, Apr 09, 2016 at 05:37:45PM -0300, Eduardo Habkost wrote:
> Instead of relying on x86_cpudef_setup() calling
> qemu_hw_version(), just make old machines set model-id explicitly
> on compat_props for qemu64, qemu32, and athlon. This will allow
> us to eliminate x86_cpudef_setup() later.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

Feel free to merge directly.

> ---
>  hw/i386/pc_piix.c    | 12 +++++++++++-
>  include/hw/i386/pc.h | 29 +++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 7f50116..25e04e4 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -583,6 +583,7 @@ DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
>  
>  #define PC_COMPAT_1_3 \
>          PC_COMPAT_1_4 \
> +        PC_CPU_MODEL_IDS("1.3.0") \
>          {\
>              .driver   = "usb-tablet",\
>              .property = "usb_version",\
> @@ -615,6 +616,7 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
>  
>  #define PC_COMPAT_1_2 \
>          PC_COMPAT_1_3 \
> +        PC_CPU_MODEL_IDS("1.2.0") \
>          {\
>              .driver   = "nec-usb-xhci",\
>              .property = "msi",\
> @@ -654,6 +656,7 @@ DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
>  
>  #define PC_COMPAT_1_1 \
>          PC_COMPAT_1_2 \
> +        PC_CPU_MODEL_IDS("1.1.0") \
>          {\
>              .driver   = "virtio-scsi-pci",\
>              .property = "hotplug",\
> @@ -697,6 +700,7 @@ DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
>  
>  #define PC_COMPAT_1_0 \
>          PC_COMPAT_1_1 \
> +        PC_CPU_MODEL_IDS("1.0") \
>          {\
>              .driver   = TYPE_ISA_FDC,\
>              .property = "check_media_rate",\
> @@ -727,7 +731,8 @@ DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
>  
>  
>  #define PC_COMPAT_0_15 \
> -        PC_COMPAT_1_0
> +        PC_COMPAT_1_0 \
> +        PC_CPU_MODEL_IDS("0.15")
>  
>  static void pc_i440fx_0_15_machine_options(MachineClass *m)
>  {
> @@ -742,6 +747,7 @@ DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
>  
>  #define PC_COMPAT_0_14 \
>          PC_COMPAT_0_15 \
> +        PC_CPU_MODEL_IDS("0.14") \
>          {\
>              .driver   = "virtio-blk-pci",\
>              .property = "event_idx",\
> @@ -781,6 +787,7 @@ DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
>  
>  #define PC_COMPAT_0_13 \
>          PC_COMPAT_0_14 \
> +        PC_CPU_MODEL_IDS("0.13") \
>          {\
>              .driver   = TYPE_PCI_DEVICE,\
>              .property = "command_serr_enable",\
> @@ -818,6 +825,7 @@ DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
>  
>  #define PC_COMPAT_0_12 \
>          PC_COMPAT_0_13 \
> +        PC_CPU_MODEL_IDS("0.12") \
>          {\
>              .driver   = "virtio-serial-pci",\
>              .property = "max_ports",\
> @@ -853,6 +861,7 @@ DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
>  
>  #define PC_COMPAT_0_11 \
>          PC_COMPAT_0_12 \
> +        PC_CPU_MODEL_IDS("0.11") \
>          {\
>              .driver   = "virtio-blk-pci",\
>              .property = "vectors",\
> @@ -884,6 +893,7 @@ DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
>  
>  #define PC_COMPAT_0_10 \
>      PC_COMPAT_0_11 \
> +    PC_CPU_MODEL_IDS("0.10") \
>      {\
>          .driver   = "virtio-blk-pci",\
>          .property = "class",\
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 96f0b66..5639979 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -359,9 +359,30 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  #define PC_COMPAT_2_5 \
>      HW_COMPAT_2_5
>  
> +/* Helper for setting model-id for CPU models that changed model-id
> + * depending on QEMU versions up to QEMU 2.4.
> + */
> +#define PC_CPU_MODEL_IDS(v) \
> +    {\
> +        .driver   = "qemu32-" TYPE_X86_CPU,\
> +        .property = "model-id",\
> +        .value    = "QEMU Virtual CPU version " v,\
> +    },\
> +    {\
> +        .driver   = "qemu64-" TYPE_X86_CPU,\
> +        .property = "model-id",\
> +        .value    = "QEMU Virtual CPU version " v,\
> +    },\
> +    {\
> +        .driver   = "athlon-" TYPE_X86_CPU,\
> +        .property = "model-id",\
> +        .value    = "QEMU Virtual CPU version " v,\
> +    },
> +
>  #define PC_COMPAT_2_4 \
>      PC_COMPAT_2_5 \
>      HW_COMPAT_2_4 \
> +    PC_CPU_MODEL_IDS("2.4.0") \
>      {\
>          .driver   = "Haswell-" TYPE_X86_CPU,\
>          .property = "abm",\
> @@ -433,6 +454,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  #define PC_COMPAT_2_3 \
>      PC_COMPAT_2_4 \
>      HW_COMPAT_2_3 \
> +    PC_CPU_MODEL_IDS("2.3.0") \
>      {\
>          .driver   = TYPE_X86_CPU,\
>          .property = "arat",\
> @@ -514,6 +536,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  #define PC_COMPAT_2_2 \
>      PC_COMPAT_2_3 \
>      HW_COMPAT_2_2 \
> +    PC_CPU_MODEL_IDS("2.3.0") \
>      {\
>          .driver = "kvm64" "-" TYPE_X86_CPU,\
>          .property = "vme",\
> @@ -608,6 +631,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  #define PC_COMPAT_2_1 \
>      PC_COMPAT_2_2 \
>      HW_COMPAT_2_1 \
> +    PC_CPU_MODEL_IDS("2.1.0") \
>      {\
>          .driver = "coreduo" "-" TYPE_X86_CPU,\
>          .property = "vmx",\
> @@ -621,6 +645,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  
>  #define PC_COMPAT_2_0 \
>      PC_COMPAT_2_1 \
> +    PC_CPU_MODEL_IDS("2.0.0") \
>      {\
>          .driver   = "virtio-scsi-pci",\
>          .property = "any_layout",\
> @@ -681,6 +706,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  
>  #define PC_COMPAT_1_7 \
>      PC_COMPAT_2_0 \
> +    PC_CPU_MODEL_IDS("1.7.0") \
>      {\
>          .driver   = TYPE_USB_DEVICE,\
>          .property = "msos-desc",\
> @@ -699,6 +725,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  
>  #define PC_COMPAT_1_6 \
>      PC_COMPAT_1_7 \
> +    PC_CPU_MODEL_IDS("1.6.0") \
>      {\
>          .driver   = "e1000",\
>          .property = "mitigation",\
> @@ -723,6 +750,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  
>  #define PC_COMPAT_1_5 \
>      PC_COMPAT_1_6 \
> +    PC_CPU_MODEL_IDS("1.5.0") \
>      {\
>          .driver   = "Conroe-" TYPE_X86_CPU,\
>          .property = "model",\
> @@ -767,6 +795,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>  
>  #define PC_COMPAT_1_4 \
>      PC_COMPAT_1_5 \
> +    PC_CPU_MODEL_IDS("1.4.0") \
>      {\
>          .driver   = "scsi-hd",\
>          .property = "discard_granularity",\
> -- 
> 2.1.0

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

* Re: [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init()
  2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
                   ` (3 preceding siblings ...)
  2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 4/4] cpu: Eliminate cpudef_init(), cpudef_setup() Eduardo Habkost
@ 2016-05-11 19:21 ` Eduardo Habkost
  4 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2016-05-11 19:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marcel Apfelbaum, Igor Mammedov, Andreas Färber,
	Michael S. Tsirkin

On Sat, Apr 09, 2016 at 05:37:43PM -0300, Eduardo Habkost wrote:
> The only reason cpudef_init() still exists is the
> qemu_hw_version()-based model_id hack at x86_cpudef_setup().
> 
> Move the model_id hack to machine compat_props so we can make the
> model_id field constant at the CPU model table, and then remove
> cpudef_init() completely.

I plan to include this in my next pull request (next Monday,
assuming v2.6.0 will be already tagged). Any objections?

-- 
Eduardo

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

end of thread, other threads:[~2016-05-11 19:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-09 20:37 [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost
2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 1/4] osdep: Move default qemu_hw_version() value to a macro Eduardo Habkost
2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 2/4] pc: Set CPU model-id on compat_props for pc <= 2.4 Eduardo Habkost
2016-05-10 15:37   ` Michael S. Tsirkin
2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 3/4] target-i386: Set constant model_id for qemu63/qemu32/athlon Eduardo Habkost
2016-04-09 20:37 ` [Qemu-devel] [PATCH for-2.7 4/4] cpu: Eliminate cpudef_init(), cpudef_setup() Eduardo Habkost
2016-05-11 19:21 ` [Qemu-devel] [PATCH for-2.7 0/4] cpu: Finally remove cpudef_init() Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).