All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4)
@ 2018-01-23  8:07 Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
                   ` (25 more replies)
  0 siblings, 26 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm


v3:
  - use qtest_startf() instead of qtest_start()
  - rename tests/machine-none.c to tests/machine-none-test.c
  - introduce first CPU_RESOLVING_TYPE for all targets and
    only then use it parse_cpu_model() 
  - stop abusing  mc->default_cpu_type as resolving cpu type,
    move cpu_parse_cpu_model() in to exec.c and embed in
    CPU_RESOLVING_TYPE, so that callers won't have to know
    about unnecessary detail

v2:
  - implemented new approach only for x86/ARM (will be done for all targets
    if approach seems acceptable)
  - add test case for '-M none -cpu FOO' case
  - redefine TARGET_DEFAULT_CPU_TYPE into CPU_RESOLVING_TYPE
  - scrape off default cpu_model refactoring, so it would cause
    less conflicts with Laurent's series where he tries to rework
    defaults to use ELF hints of executed program

Series is finishing work on generalizing cpu_model parsing
and limiting parts that deal with inconsistent cpu_model
naming to "-cpu" CLI option in vl.c, bsd|linux-user/main.c
CLI and default cpu_model processing and FOO_cpu_class_by_name()
callbacks.

It introduces CPU_RESOLVING_TYPE which must be defined
by each target and is used by helper parse_cpu_model()
(former cpu_parse_cpu_model()) to get access to target
specific FOO_cpu_class_by_name() callback.

git tree for testing:
   https://github.com/imammedo/qemu.git cpu_init_removal_v3

CC: Laurent Vivier <laurent@vivier.eu>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: qemu-s390x@nongnu.org
CC: qemu-ppc@nongnu.org
CC: qemu-arm@nongnu.org

Igor Mammedov (25):
  nios2: 10m50_devboard: replace cpu_model with cpu_type
  tests: add machine 'none' with -cpu test
  arm: cpu: add CPU_RESOLVING_TYPE macro
  x86: cpu: add CPU_RESOLVING_TYPE macro
  alpha: cpu: add CPU_RESOLVING_TYPE macro
  cris: cpu: add CPU_RESOLVING_TYPE macro
  lm32: cpu: add CPU_RESOLVING_TYPE macro
  m68k: cpu: add CPU_RESOLVING_TYPE macro
  microblaze: cpu: add CPU_RESOLVING_TYPE macro
  mips: cpu: add CPU_RESOLVING_TYPE macro
  moxie: cpu: add CPU_RESOLVING_TYPE macro
  nios2: cpu: add CPU_RESOLVING_TYPE macro
  openrisc: cpu: add CPU_RESOLVING_TYPE macro
  ppc: cpu: add CPU_RESOLVING_TYPE macro
  s390x: cpu: add CPU_RESOLVING_TYPE macro
  sh4: cpu: add CPU_RESOLVING_TYPE macro
  sparc: cpu: add CPU_RESOLVING_TYPE macro
  tricore: cpu: add CPU_RESOLVING_TYPE macro
  unicore32: cpu: add CPU_RESOLVING_TYPE macro
  xtensa: cpu: add CPU_RESOLVING_TYPE macro
  hppa: cpu: add CPU_RESOLVING_TYPE macro
  tilegx: cpu: add CPU_RESOLVING_TYPE macro
  Use cpu_create(type) instead of cpu_init(cpu_model)
  cpu: get rid of unused cpu_init() defines
  cpu: get rid of cpu_generic_init()

 include/qom/cpu.h         | 16 +-------
 target/alpha/cpu.h        |  3 +-
 target/arm/cpu.h          |  3 +-
 target/cris/cpu.h         |  3 +-
 target/hppa/cpu.h         |  2 +-
 target/i386/cpu.h         |  3 +-
 target/lm32/cpu.h         |  3 +-
 target/m68k/cpu.h         |  3 +-
 target/microblaze/cpu.h   |  2 +-
 target/mips/cpu.h         |  3 +-
 target/moxie/cpu.h        |  3 +-
 target/nios2/cpu.h        |  2 +-
 target/openrisc/cpu.h     |  3 +-
 target/ppc/cpu.h          |  3 +-
 target/s390x/cpu.h        |  3 +-
 target/sh4/cpu.h          |  3 +-
 target/sparc/cpu.h        |  5 +--
 target/tilegx/cpu.h       |  2 +-
 target/tricore/cpu.h      |  3 +-
 target/unicore32/cpu.h    |  3 +-
 target/xtensa/cpu.h       |  3 +-
 bsd-user/main.c           |  4 +-
 exec.c                    | 23 +++++++++++
 hw/core/null-machine.c    |  6 +--
 hw/nios2/10m50_devboard.c |  2 +-
 linux-user/main.c         | 10 +++--
 qom/cpu.c                 | 48 +----------------------
 tests/Makefile.include    |  2 +
 tests/machine-none-test.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++
 vl.c                      | 10 ++---
 30 files changed, 162 insertions(+), 114 deletions(-)
 create mode 100644 tests/machine-none-test.c

-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-02-06 22:09   ` Eduardo Habkost
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test Igor Mammedov
                   ` (24 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Chris Wulff, Marek Vasut

use cpu_create() instead of being removed cpu_generic_init()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
---
 hw/nios2/10m50_devboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
index e4007f6..42053b2 100644
--- a/hw/nios2/10m50_devboard.c
+++ b/hw/nios2/10m50_devboard.c
@@ -75,7 +75,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
                                 phys_ram_alias);
 
     /* Create CPU -- FIXME */
-    cpu = NIOS2_CPU(cpu_generic_init(TYPE_NIOS2_CPU, "nios2"));
+    cpu = NIOS2_CPU(cpu_create(TYPE_NIOS2_CPU));
 
     /* Register: CPU interrupt controller (PIC) */
     cpu_irq = nios2_cpu_pic_init(cpu);
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-02-06 22:13   ` Eduardo Habkost
  2018-02-06 22:21   ` Eduardo Habkost
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
                   ` (23 subsequent siblings)
  25 siblings, 2 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm

Check that "$QEMU -M none -cpu FOO" starts QEMU without error

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - rename file to machine-none-test.c (Thomas Huth <thuth@redhat.com>)
  - use qtest_startf()/instead of qtest_start() (Thomas Huth <thuth@redhat.com>)
---
 tests/Makefile.include    |  2 ++
 tests/machine-none-test.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 tests/machine-none-test.c

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 8883274..ea0a803 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -380,6 +380,7 @@ check-qtest-s390x-y += tests/virtio-balloon-test$(EXESUF)
 check-qtest-s390x-y += tests/virtio-console-test$(EXESUF)
 check-qtest-s390x-y += tests/virtio-serial-test$(EXESUF)
 
+check-qtest-generic-y += tests/machine-none-test$(EXESUF)
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
 
@@ -782,6 +783,7 @@ tests/display-vga-test$(EXESUF): tests/display-vga-test.o
 tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o
 tests/qom-test$(EXESUF): tests/qom-test.o
 tests/test-hmp$(EXESUF): tests/test-hmp.o
+tests/machine-none-test$(EXESUF): tests/machine-none-test.o
 tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-y)
 tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y)
 tests/nvme-test$(EXESUF): tests/nvme-test.o
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
new file mode 100644
index 0000000..2eb13e8
--- /dev/null
+++ b/tests/machine-none-test.c
@@ -0,0 +1,68 @@
+/*
+ * Machine 'none' tests.
+ *
+ * Copyright (c) 2018 Red Hat Inc.
+ *
+ * Authors:
+ *  Igor Mammedov <imammedo@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 "qemu/osdep.h"
+
+#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "libqtest.h"
+#include "qapi/qmp/types.h"
+
+struct arch2cpu {
+    const char *arch;
+    const char *cpu_model;
+};
+
+static struct arch2cpu cpus_map[] = {
+    /* tested targets list */
+};
+
+static const char *get_cpu_model_by_arch(const char *arch)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(cpus_map); i++) {
+        if (!strcmp(arch, cpus_map[i].arch)) {
+            return cpus_map[i].cpu_model;
+        }
+    }
+    return NULL;
+}
+
+static void test_machine_cpu_cli(void)
+{
+    QDict *response;
+    const char *arch = qtest_get_arch();
+    const char *cpu_model = get_cpu_model_by_arch(arch);
+
+    if (!cpu_model) {
+        fprintf(stderr, "WARNING: cpu name for target '%s' isn't defined,"
+                " add it to cpus_map\n", arch);
+        return; /* TODO: die here to force all targets have a test */
+    }
+    global_qtest = qtest_startf("-machine none -cpu %s", cpu_model);
+
+    response = qmp("{ 'execute': 'quit' }");
+    g_assert(qdict_haskey(response, "return"));
+    QDECREF(response);
+
+    qtest_quit(global_qtest);
+}
+
+int main(int argc, char **argv)
+{
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("machine/none/cpu_option", test_machine_cpu_cli);
+
+    return g_test_run();
+}
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  9:45   ` Andrew Jones
                     ` (2 more replies)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 04/25] x86: " Igor Mammedov
                   ` (22 subsequent siblings)
  25 siblings, 3 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Peter Maydell, Andrew Jones

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
thest would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: qemu-arm@nongnu.org
CC: Peter Maydell <peter.maydell@linaro.org>
CC: Andrew Jones <drjones@redhat.com>
---
 target/arm/cpu.h          | 1 +
 linux-user/main.c         | 2 --
 tests/machine-none-test.c | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 9631670..f9fb141 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2171,6 +2171,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_ARM_CPU
 
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
diff --git a/linux-user/main.c b/linux-user/main.c
index 450eb3c..a35477e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
 #else
         cpu_model = "qemu32";
 #endif
-#elif defined(TARGET_ARM)
-        cpu_model = "any";
 #elif defined(TARGET_UNICORE32)
         cpu_model = "any";
 #elif defined(TARGET_M68K)
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 2eb13e8..1b213ff 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -24,6 +24,8 @@ struct arch2cpu {
 
 static struct arch2cpu cpus_map[] = {
     /* tested targets list */
+    { "arm", "cortex-a15" },
+    { "aarch64", "cortex-a15" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 04/25] x86: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (2 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  9:52   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 05/25] alpha: " Igor Mammedov
                   ` (21 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/cpu.h         | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 30cc562..82c7381 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1568,6 +1568,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 
 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
 #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_X86_CPU
 
 #ifdef TARGET_X86_64
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 1b213ff..4b704fb 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -26,6 +26,8 @@ static struct arch2cpu cpus_map[] = {
     /* tested targets list */
     { "arm", "cortex-a15" },
     { "aarch64", "cortex-a15" },
+    { "x86_64", "qemu64,apic-id=0" },
+    { "i386", "qemu32,apic-id=0" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 05/25] alpha: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (3 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 04/25] x86: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 06/25] cris: " Igor Mammedov
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Richard Henderson

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Richard Henderson <rth@twiddle.net>
---
 target/alpha/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 0a9ad35..21ed5d6 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -472,6 +472,7 @@ void alpha_translate_init(void);
 
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
 
 void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 4b704fb..5d23ade 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -28,6 +28,7 @@ static struct arch2cpu cpus_map[] = {
     { "aarch64", "cortex-a15" },
     { "x86_64", "qemu64,apic-id=0" },
     { "i386", "qemu32,apic-id=0" },
+    { "alpha", "ev67" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 06/25] cris: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (4 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 05/25] alpha: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 07/25] lm32: " Igor Mammedov
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Edgar E. Iglesias

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
---
 target/cris/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index b64fa35..1a27653 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -271,6 +271,7 @@ enum {
 
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_CRIS_CPU
 
 #define cpu_signal_handler cpu_cris_signal_handler
 
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 5d23ade..68f7a30 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -29,6 +29,7 @@ static struct arch2cpu cpus_map[] = {
     { "x86_64", "qemu64,apic-id=0" },
     { "i386", "qemu32,apic-id=0" },
     { "alpha", "ev67" },
+    { "cris", "crisv32" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 07/25] lm32: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (5 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 06/25] cris: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 08/25] m68k: " Igor Mammedov
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Michael Walle

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Michael Walle <michael@walle.cc>
---
 target/lm32/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index 2279594..0656052 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -259,6 +259,7 @@ bool lm32_cpu_do_semihosting(CPUState *cs);
 
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_LM32_CPU
 
 #define cpu_list lm32_cpu_list
 #define cpu_signal_handler cpu_lm32_signal_handler
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 68f7a30..1159290 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -30,6 +30,7 @@ static struct arch2cpu cpus_map[] = {
     { "i386", "qemu32,apic-id=0" },
     { "alpha", "ev67" },
     { "cris", "crisv32" },
+    { "lm32", "lm32-full" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 08/25] m68k: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (6 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 07/25] lm32: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-24 12:58   ` Laurent Vivier
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 09/25] microblaze: " Igor Mammedov
                   ` (17 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 2985b03..8a4299a 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -405,6 +405,7 @@ void register_m68k_insns (CPUM68KState *env);
 
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_M68K_CPU
 
 #define cpu_signal_handler cpu_m68k_signal_handler
 #define cpu_list m68k_cpu_list
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 1159290..c9445b6 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -31,6 +31,7 @@ static struct arch2cpu cpus_map[] = {
     { "alpha", "ev67" },
     { "cris", "crisv32" },
     { "lm32", "lm32-full" },
+    { "m68k", "m5206" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 09/25] microblaze: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (7 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 08/25] m68k: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 10/25] mips: " Igor Mammedov
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Edgar E. Iglesias

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

PC:
 target cpu can't be instantiated with -M none -cpu
 Add FIXME note in test, so microblaze maintainers
 could fix it in future and add proper error checking
 in cpu_model resolver which accepts any junk now.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
---
 target/microblaze/cpu.h   | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index 52b6b6a..492f9f7 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -344,6 +344,7 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
+#define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
 
 #define cpu_signal_handler cpu_mb_signal_handler
 
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index c9445b6..984def6 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -32,6 +32,8 @@ static struct arch2cpu cpus_map[] = {
     { "cris", "crisv32" },
     { "lm32", "lm32-full" },
     { "m68k", "m5206" },
+    /* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any */
+    /* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu any */
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 10/25] mips: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (8 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 09/25] microblaze: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 11/25] moxie: " Igor Mammedov
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Aurelien Jarno, Yongbok Kim

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Yongbok Kim <yongbok.kim@mips.com>
---
 target/mips/cpu.h         | 1 +
 tests/machine-none-test.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 7f8ba5f..0fcbfb3 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -743,6 +743,7 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 
 #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
 #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
 
 bool cpu_supports_cps_smp(const char *cpu_type);
 bool cpu_supports_isa(const char *cpu_type, unsigned int isa);
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 984def6..9bc6a06 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -34,6 +34,10 @@ static struct arch2cpu cpus_map[] = {
     { "m68k", "m5206" },
     /* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any */
     /* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu any */
+    { "mips", "4Kc" },
+    { "mipsel", "4Kc" },
+    { "mips64", "20Kc" },
+    { "mips64el", "20Kc" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 11/25] moxie: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (9 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 10/25] mips: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 12/25] nios2: " Igor Mammedov
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Anthony Green

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Anthony Green <green@moxielogic.com>
---
 target/moxie/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index d37e6a5..3f94a5a 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -124,6 +124,7 @@ int cpu_moxie_signal_handler(int host_signum, void *pinfo,
 
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
 
 #define cpu_signal_handler cpu_moxie_signal_handler
 
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 9bc6a06..c15a857 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -38,6 +38,7 @@ static struct arch2cpu cpus_map[] = {
     { "mipsel", "4Kc" },
     { "mips64", "20Kc" },
     { "mips64el", "20Kc" },
+    { "moxie", "MoxieLite" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 12/25] nios2: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (10 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 11/25] moxie: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 13/25] openrisc: " Igor Mammedov
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Chris Wulff, Marek Vasut

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

TODO:
 make nios2_cpu_class_by_name() to do name check instead of
 accepting anything

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
---
 target/nios2/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 88823a6..2234bff 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -232,6 +232,7 @@ void nios2_check_interrupts(CPUNios2State *env);
 #endif
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
+#define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
 
 #define cpu_gen_code cpu_nios2_gen_code
 #define cpu_signal_handler cpu_nios2_signal_handler
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index c15a857..c6ad495 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -39,6 +39,7 @@ static struct arch2cpu cpus_map[] = {
     { "mips64", "20Kc" },
     { "mips64el", "20Kc" },
     { "moxie", "MoxieLite" },
+    { "nios2", "FIXME" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 13/25] openrisc: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (11 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 12/25] nios2: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 14/25] ppc: " Igor Mammedov
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Stafford Horne

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Stafford Horne <shorne@gmail.com>
---
 target/openrisc/cpu.h     | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index cc22dc8..9b32ea4 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -394,6 +394,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
 
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
 
 #include "exec/cpu-all.h"
 
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index c6ad495..160aa13 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -40,6 +40,7 @@ static struct arch2cpu cpus_map[] = {
     { "mips64el", "20Kc" },
     { "moxie", "MoxieLite" },
     { "nios2", "FIXME" },
+    { "or1k", "or1200" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 14/25] ppc: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (12 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 13/25] openrisc: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23 11:14   ` David Gibson
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 15/25] s390x: " Igor Mammedov
                   ` (11 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	David Gibson, Alexander Graf

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Laurent Vivier <laurent@vivier.eu>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Alexander Graf <agraf@suse.de>
CC: qemu-ppc@nongnu.org
---
 target/ppc/cpu.h          | 1 +
 tests/machine-none-test.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 603a38c..d5f2f3d 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1380,6 +1380,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 
 #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
 #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
 
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 160aa13..052b8c0 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -41,6 +41,9 @@ static struct arch2cpu cpus_map[] = {
     { "moxie", "MoxieLite" },
     { "nios2", "FIXME" },
     { "or1k", "or1200" },
+    { "ppc", "604" },
+    { "ppc64", "power8e_v2.1" },
+    { "ppcemb", "440epb" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 15/25] s390x: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (13 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 14/25] ppc: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 16/25] sh4: " Igor Mammedov
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Richard Henderson, Alexander Graf

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Richard Henderson <rth@twiddle.net>
CC: Alexander Graf <agraf@suse.de>
CC: qemu-s390x@nongnu.org
---
 target/s390x/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 1a8b6b9..b2121cb 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -731,6 +731,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_S390_CPU
 
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 052b8c0..b3a346d 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -44,6 +44,7 @@ static struct arch2cpu cpus_map[] = {
     { "ppc", "604" },
     { "ppc64", "power8e_v2.1" },
     { "ppcemb", "440epb" },
+    { "s390x", "qemu" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 16/25] sh4: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (14 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 15/25] s390x: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 17/25] sparc: " Igor Mammedov
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Aurelien Jarno

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Aurelien Jarno <aurelien@aurel32.net>
---
 target/sh4/cpu.h          | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index a2c26e0..709e0ca 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -278,6 +278,7 @@ void cpu_load_tlb(CPUSH4State * env);
 
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU
 
 #define cpu_signal_handler cpu_sh4_signal_handler
 #define cpu_list sh4_cpu_list
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index b3a346d..134036a 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -45,6 +45,8 @@ static struct arch2cpu cpus_map[] = {
     { "ppc64", "power8e_v2.1" },
     { "ppcemb", "440epb" },
     { "s390x", "qemu" },
+    { "sh4", "sh7750r" },
+    { "sh4eb", "sh7751r" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 17/25] sparc: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (15 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 16/25] sh4: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 18/25] tricore: " Igor Mammedov
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Mark Cave-Ayland, Artyom Tarasenko

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

PS:
sparc cpu model names might have spaces, add quotes around
cpu model name when creating CLI so QEMU could find cpu.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
---
 target/sparc/cpu.h        | 1 +
 tests/machine-none-test.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 9fde547..345b39a 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -660,6 +660,7 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 
 #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
 #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
 
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 134036a..0f80d7b 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -47,6 +47,8 @@ static struct arch2cpu cpus_map[] = {
     { "s390x", "qemu" },
     { "sh4", "sh7750r" },
     { "sh4eb", "sh7751r" },
+    { "sparc", "LEON2" },
+    { "sparc64", "Fujitsu Sparc64" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
@@ -72,7 +74,7 @@ static void test_machine_cpu_cli(void)
                 " add it to cpus_map\n", arch);
         return; /* TODO: die here to force all targets have a test */
     }
-    global_qtest = qtest_startf("-machine none -cpu %s", cpu_model);
+    global_qtest = qtest_startf("-machine none -cpu '%s'", cpu_model);
 
     response = qmp("{ 'execute': 'quit' }");
     g_assert(qdict_haskey(response, "return"));
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 18/25] tricore: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (16 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 17/25] sparc: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23 14:05   ` Bastian Koppelmann
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 19/25] unicore32: " Igor Mammedov
                   ` (7 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Bastian Koppelmann

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 target/tricore/cpu.h      | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index f41d2ce..a2ef632 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -415,6 +415,7 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
 
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
 
 /* helpers.c */
 int cpu_tricore_handle_mmu_fault(CPUState *cpu, target_ulong address,
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 0f80d7b..0430b06 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -49,6 +49,7 @@ static struct arch2cpu cpus_map[] = {
     { "sh4eb", "sh7751r" },
     { "sparc", "LEON2" },
     { "sparc64", "Fujitsu Sparc64" },
+    { "tricore", "tc1796" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 19/25] unicore32: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (17 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 18/25] tricore: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 20/25] xtensa: " Igor Mammedov
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Guan Xuetao

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Laurent Vivier <laurent@vivier.eu>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 target/unicore32/cpu.h    | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 3dc6fbc..9644b07 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -169,6 +169,7 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
 
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_UNICORE32_CPU
 
 static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc,
                                         target_ulong *cs_base, uint32_t *flags)
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 0430b06..a8a499e 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -50,6 +50,7 @@ static struct arch2cpu cpus_map[] = {
     { "sparc", "LEON2" },
     { "sparc64", "Fujitsu Sparc64" },
     { "tricore", "tc1796" },
+    { "unicore32", "UniCore-II" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 20/25] xtensa: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (18 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 19/25] unicore32: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 21/25] hppa: " Igor Mammedov
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Max Filippov

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Max Filippov <jcmvbkbc@gmail.com>
---
 target/xtensa/cpu.h       | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index d9404aa..23dbd45 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -500,6 +500,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 
 #define XTENSA_CPU_TYPE_SUFFIX "-" TYPE_XTENSA_CPU
 #define XTENSA_CPU_TYPE_NAME(model) model XTENSA_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_XTENSA_CPU
 
 #ifdef TARGET_WORDS_BIGENDIAN
 #define XTENSA_DEFAULT_CPU_MODEL "fsf"
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index a8a499e..a1e9980 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -51,6 +51,8 @@ static struct arch2cpu cpus_map[] = {
     { "sparc64", "Fujitsu Sparc64" },
     { "tricore", "tc1796" },
     { "unicore32", "UniCore-II" },
+    { "xtensa", "dc233c" },
+    { "xtensaeb", "fsf" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 21/25] hppa: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (19 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 20/25] xtensa: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 22/25] tilegx: " Igor Mammedov
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Richard Henderson

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Richard Henderson <rth@twiddle.net>
---
 target/hppa/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 8d14077..b92ae3f 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -113,6 +113,7 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
 void hppa_translate_init(void);
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_HPPA_CPU, cpu_model)
+#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
 
 void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 22/25] tilegx: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (20 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 21/25] hppa: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model) Igor Mammedov
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Eduardo Habkost <ehabkost@redhat.com>
---
 target/tilegx/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h
index 71cea04..a73215e 100644
--- a/target/tilegx/cpu.h
+++ b/target/tilegx/cpu.h
@@ -165,6 +165,7 @@ void tilegx_tcg_init(void);
 int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
+#define CPU_RESOLVING_TYPE TYPE_TILEGX_CPU
 
 #define cpu_signal_handler cpu_tilegx_signal_handler
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model)
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (21 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 22/25] tilegx: " Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-02-05 17:08   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines Igor Mammedov
                   ` (2 subsequent siblings)
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm

With all targets defining CPU_RESOLVING_TYPE, refactor
cpu_parse_cpu_model(type, cpu_model) to parse_cpu_model(cpu_model)
so that callers won't have to know internal resolving cpu
type. Place it in exec.c so it could be called from both
target independed vl.c and *-user/main.c.

That allows us to stop abusing cpu type from
  MachineClass::default_cpu_type
as resolver class in vl.c which were confusing part of
cpu_parse_cpu_model().

Also with new parse_cpu_model(), the last users of cpu_init()
in null-machine.c and bsd/linux-user targets could be switched
to cpu_create() API and cpu_init() API will be removed by
follow up patch.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/qom/cpu.h      | 16 ++--------------
 bsd-user/main.c        |  4 +++-
 exec.c                 | 23 +++++++++++++++++++++++
 hw/core/null-machine.c |  6 +++---
 linux-user/main.c      |  8 ++++++--
 qom/cpu.c              | 31 -------------------------------
 vl.c                   | 10 +++-------
 7 files changed, 40 insertions(+), 58 deletions(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 93bd546..0185589 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
 CPUState *cpu_create(const char *typename);
 
 /**
- * cpu_parse_cpu_model:
- * @typename: The CPU base type or CPU type.
+ * parse_cpu_model:
  * @cpu_model: The model string including optional parameters.
  *
  * processes optional parameters and registers them as global properties
@@ -670,18 +669,7 @@ CPUState *cpu_create(const char *typename);
  * Returns: type of CPU to create or prints error and terminates process
  *          if an error occurred.
  */
-const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model);
-
-/**
- * cpu_generic_init:
- * @typename: The CPU base type.
- * @cpu_model: The model string including optional parameters.
- *
- * Instantiates a CPU, processes optional parameters and realizes the CPU.
- *
- * Returns: A #CPUState or %NULL if an error occurred.
- */
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model);
+const char *parse_cpu_model(const char *cpu_model);
 
 /**
  * cpu_has_work:
diff --git a/bsd-user/main.c b/bsd-user/main.c
index efef5ff..cbc683a 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -723,6 +723,7 @@ int main(int argc, char **argv)
 {
     const char *filename;
     const char *cpu_model;
+    const char *cpu_type;
     const char *log_file = NULL;
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
@@ -900,7 +901,8 @@ int main(int argc, char **argv)
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+    cpu_type = parse_cpu_model(cpu_model);
+    cpu = create(cpu_type);
     env = cpu->env_ptr;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
     cpu_reset(cpu);
diff --git a/exec.c b/exec.c
index 629a508..8aee230 100644
--- a/exec.c
+++ b/exec.c
@@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
 #endif
 }
 
+const char *parse_cpu_model(const char *cpu_model)
+{
+    ObjectClass *oc;
+    CPUClass *cc;
+    gchar **model_pieces;
+    const char *cpu_type;
+
+    model_pieces = g_strsplit(cpu_model, ",", 2);
+
+    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
+    if (oc == NULL) {
+        error_report("unable to find CPU model '%s'", model_pieces[0]);
+        g_strfreev(model_pieces);
+        exit(EXIT_FAILURE);
+    }
+
+    cpu_type = object_class_get_name(oc);
+    cc = CPU_CLASS(oc);
+    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
+    g_strfreev(model_pieces);
+    return cpu_type;
+}
+
 #if defined(CONFIG_USER_ONLY)
 static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
 {
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index 864832d..cde4d3e 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -24,9 +24,9 @@ static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
 
-    /* Initialize CPU (if a model has been specified) */
-    if (mch->cpu_model) {
-        cpu = cpu_init(mch->cpu_model);
+    /* Initialize CPU (if user asked for it) */
+    if (mch->cpu_type) {
+        cpu = cpu_create(mch->cpu_type);
         if (!cpu) {
             error_report("Unable to initialize CPU");
             exit(1);
diff --git a/linux-user/main.c b/linux-user/main.c
index a35477e..0afb3f4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -44,6 +44,7 @@ static const char *argv0;
 static int gdbstub_port;
 static envlist_t *envlist;
 static const char *cpu_model;
+static const char *cpu_type;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
 int have_guest_base;
@@ -3847,7 +3848,7 @@ void init_task_state(TaskState *ts)
 CPUArchState *cpu_copy(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
-    CPUState *new_cpu = cpu_init(cpu_model);
+    CPUState *new_cpu = cpu_create(cpu_type);
     CPUArchState *new_env = new_cpu->env_ptr;
     CPUBreakpoint *bp;
     CPUWatchpoint *wp;
@@ -4357,10 +4358,13 @@ int main(int argc, char **argv, char **envp)
         cpu_model = "any";
 #endif
     }
+    cpu_type = parse_cpu_model(cpu_model);
+
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+
+    cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
     cpu_reset(cpu);
 
diff --git a/qom/cpu.c b/qom/cpu.c
index e42d9a7..aab8437 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -67,37 +67,6 @@ CPUState *cpu_create(const char *typename)
     return cpu;
 }
 
-const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
-{
-    ObjectClass *oc;
-    CPUClass *cc;
-    gchar **model_pieces;
-    const char *cpu_type;
-
-    model_pieces = g_strsplit(cpu_model, ",", 2);
-
-    oc = cpu_class_by_name(typename, model_pieces[0]);
-    if (oc == NULL) {
-        error_report("unable to find CPU model '%s'", model_pieces[0]);
-        g_strfreev(model_pieces);
-        exit(EXIT_FAILURE);
-    }
-
-    cpu_type = object_class_get_name(oc);
-    cc = CPU_CLASS(oc);
-    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
-    g_strfreev(model_pieces);
-    return cpu_type;
-}
-
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
-{
-    /* TODO: all callers of cpu_generic_init() need to be converted to
-     * call cpu_parse_features() only once, before calling cpu_generic_init().
-     */
-    return cpu_create(cpu_parse_cpu_model(typename, cpu_model));
-}
-
 bool cpu_paging_enabled(const CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
diff --git a/vl.c b/vl.c
index e725ecb..e45e831 100644
--- a/vl.c
+++ b/vl.c
@@ -4609,15 +4609,11 @@ int main(int argc, char **argv, char **envp)
     current_machine->maxram_size = maxram_size;
     current_machine->ram_slots = ram_slots;
     current_machine->boot_order = boot_order;
-    current_machine->cpu_model = cpu_model;
 
     /* parse features once if machine provides default cpu_type */
-    if (machine_class->default_cpu_type) {
-        current_machine->cpu_type = machine_class->default_cpu_type;
-        if (cpu_model) {
-            current_machine->cpu_type =
-                cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
-        }
+    current_machine->cpu_type = machine_class->default_cpu_type;
+    if (cpu_model) {
+        current_machine->cpu_type = parse_cpu_model(cpu_model);
     }
     parse_numa_opts(current_machine);
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (22 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model) Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-01-23 11:15   ` David Gibson
  2018-02-06 22:26   ` Eduardo Habkost
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init() Igor Mammedov
  2018-02-06 22:32 ` [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Eduardo Habkost
  25 siblings, 2 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Richard Henderson, Peter Maydell, Edgar E. Iglesias,
	Michael Walle, Aurelien Jarno, Yongbok Kim, Anthony Green,
	Chris Wulff, Marek Vasut, Stafford Horne, David Gibson,
	Alexander Graf, Mark Cave-Ayland, Artyom Tarasenko,
	Bastian Koppelmann, Guan Xuetao, Max Filippov

cpu_init(cpu_model) were replaced by cpu_create(cpu_type) so
no users are left, remove it.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Richard Henderson <rth@twiddle.net> (maintainer:Alpha)
CC: Peter Maydell <peter.maydell@linaro.org>
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Michael Walle <michael@walle.cc>
CC: Laurent Vivier <laurent@vivier.eu>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Yongbok Kim <yongbok.kim@mips.com>
CC: Anthony Green <green@moxielogic.com>
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
CC: Stafford Horne <shorne@gmail.com>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Alexander Graf <agraf@suse.de>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: qemu-arm@nongnu.org
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org
---
 target/alpha/cpu.h      | 2 --
 target/arm/cpu.h        | 2 --
 target/cris/cpu.h       | 2 --
 target/hppa/cpu.h       | 1 -
 target/i386/cpu.h       | 2 --
 target/lm32/cpu.h       | 2 --
 target/m68k/cpu.h       | 2 --
 target/microblaze/cpu.h | 1 -
 target/mips/cpu.h       | 2 --
 target/moxie/cpu.h      | 2 --
 target/nios2/cpu.h      | 1 -
 target/openrisc/cpu.h   | 2 --
 target/ppc/cpu.h        | 2 --
 target/s390x/cpu.h      | 2 --
 target/sh4/cpu.h        | 2 --
 target/sparc/cpu.h      | 4 ----
 target/tilegx/cpu.h     | 1 -
 target/tricore/cpu.h    | 2 --
 target/unicore32/cpu.h  | 2 --
 target/xtensa/cpu.h     | 2 --
 20 files changed, 38 deletions(-)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 21ed5d6..b3bec21 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -468,8 +468,6 @@ enum {
 
 void alpha_translate_init(void);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_ALPHA_CPU, cpu_model)
-
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index f9fb141..b37d266 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2167,8 +2167,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
     return unmasked || pstate_unmasked;
 }
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_ARM_CPU, cpu_model)
-
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_ARM_CPU
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index 1a27653..db80cb1 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -267,8 +267,6 @@ enum {
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_CRIS_CPU, cpu_model)
-
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_CRIS_CPU
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index b92ae3f..628d7de 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -112,7 +112,6 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
 
 void hppa_translate_init(void);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_HPPA_CPU, cpu_model)
 #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
 
 void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 82c7381..1ed60b0 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1564,8 +1564,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 
 #define PHYS_ADDR_MASK MAKE_64BIT_MASK(0, TCG_PHYS_ADDR_BITS)
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_X86_CPU, cpu_model)
-
 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
 #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_X86_CPU
diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index 0656052..53939e5 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -255,8 +255,6 @@ void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,
 void lm32_watchpoint_remove(CPULM32State *env, int index);
 bool lm32_cpu_do_semihosting(CPUState *cs);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_LM32_CPU, cpu_model)
-
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_LM32_CPU
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 8a4299a..7d64804 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -401,8 +401,6 @@ void register_m68k_insns (CPUM68KState *env);
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
-
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_M68K_CPU
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index 492f9f7..a0ea421 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -343,7 +343,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
 #define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
 
 #define cpu_signal_handler cpu_mb_signal_handler
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 0fcbfb3..cfe1735 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -739,8 +739,6 @@ enum {
 
 int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model)
-
 #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
 #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index 3f94a5a..5f8d10b 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -120,8 +120,6 @@ void moxie_translate_init(void);
 int cpu_moxie_signal_handler(int host_signum, void *pinfo,
                              void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MOXIE_CPU, cpu_model)
-
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 2234bff..8897e9a 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -231,7 +231,6 @@ void nios2_check_interrupts(CPUNios2State *env);
 # define TARGET_VIRT_ADDR_SPACE_BITS 32
 #endif
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
 #define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
 
 #define cpu_gen_code cpu_nios2_gen_code
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index 9b32ea4..6f843fa 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -390,8 +390,6 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
                                int *prot, target_ulong address, int rw);
 #endif
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model)
-
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index d5f2f3d..32c51fb 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1376,8 +1376,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
 int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
 int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)
-
 #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
 #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index b2121cb..b3bfcf5 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -727,8 +727,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 
 
 /* helper.c */
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_model)
-
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_S390_CPU
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index 709e0ca..c6418ef 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -274,8 +274,6 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr);
 
 void cpu_load_tlb(CPUSH4State * env);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_SUPERH_CPU, cpu_model)
-
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 345b39a..28f254d 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -654,10 +654,6 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
 #endif
 int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#ifndef NO_CPU_IO_DEFS
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_SPARC_CPU, cpu_model)
-#endif
-
 #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
 #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h
index a73215e..238f8d3 100644
--- a/target/tilegx/cpu.h
+++ b/target/tilegx/cpu.h
@@ -164,7 +164,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env)
 void tilegx_tcg_init(void);
 int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
 #define CPU_RESOLVING_TYPE TYPE_TILEGX_CPU
 
 #define cpu_signal_handler cpu_tilegx_signal_handler
diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index a2ef632..13d629d 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -411,8 +411,6 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
     *flags = 0;
 }
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_TRICORE_CPU, cpu_model)
-
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 9644b07..5ff8b98 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -165,8 +165,6 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
 
 #include "exec/cpu-all.h"
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model)
-
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_UNICORE32_CPU
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 23dbd45..6481c3b 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -509,8 +509,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 #endif
 #define XTENSA_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_XTENSA_CPU, cpu_model)
-
 void xtensa_translate_init(void);
 void xtensa_breakpoint_handler(CPUState *cs);
 void xtensa_finalize_config(XtensaConfig *config);
-- 
2.7.4

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

* [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init()
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (23 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines Igor Mammedov
@ 2018-01-23  8:08 ` Igor Mammedov
  2018-02-05 17:09   ` Igor Mammedov
  2018-02-06 22:32 ` [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Eduardo Habkost
  25 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  8:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, qemu-s390x, qemu-ppc, qemu-arm,
	Richard Henderson, Emilio G. Cota, Paolo Bonzini,
	Alex Bennée, Philippe Mathieu-Daudé

There aren't any users of the helper left, remove it.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Richard Henderson <richard.henderson@linaro.org>
CC: "Emilio G. Cota" <cota@braap.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: "Alex Bennée" <alex.bennee@linaro.org>
CC: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
---
 qom/cpu.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/qom/cpu.c b/qom/cpu.c
index aab8437..cf6880d 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -304,22 +304,9 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
 static void cpu_common_parse_features(const char *typename, char *features,
                                       Error **errp)
 {
-    char *featurestr; /* Single "key=value" string being parsed */
     char *val;
-    static bool cpu_globals_initialized;
-
-    /* TODO: all callers of ->parse_features() need to be changed to
-     * call it only once, so we can remove this check (or change it
-     * to assert(!cpu_globals_initialized).
-     * Current callers of ->parse_features() are:
-     * - cpu_generic_init()
-     */
-    if (cpu_globals_initialized) {
-        return;
-    }
-    cpu_globals_initialized = true;
-
-    featurestr = features ? strtok(features, ",") : NULL;
+    /* Single "key=value" string being parsed */
+    char *featurestr = features ? strtok(features, ",") : NULL;
 
     while (featurestr) {
         val = strchr(featurestr, '=');
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
@ 2018-01-23  9:45   ` Andrew Jones
  2018-01-23  9:51   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
  2018-02-06 22:18   ` [Qemu-devel] [PATCH v3 " Eduardo Habkost
  2 siblings, 0 replies; 44+ messages in thread
From: Andrew Jones @ 2018-01-23  9:45 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Peter Maydell, Eduardo Habkost, Laurent Vivier,
	qemu-s390x, qemu-arm, qemu-ppc

On Tue, Jan 23, 2018 at 09:08:02AM +0100, Igor Mammedov wrote:
> it will be used for providing to cpu name resolving class for
> parsing cpu model for system and user emulation code.
> 
> Along with change add target to null-machine test, so
> that when switch to CPU_RESOLVING_TYPE happens,
> thest would ensure that null-mchine usecase still works.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: qemu-arm@nongnu.org
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: Andrew Jones <drjones@redhat.com>
> ---
>  target/arm/cpu.h          | 1 +
>  linux-user/main.c         | 2 --
>  tests/machine-none-test.c | 2 ++
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 9631670..f9fb141 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -2171,6 +2171,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
>  
>  #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
>  #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
> +#define CPU_RESOLVING_TYPE TYPE_ARM_CPU
>  
>  #define cpu_signal_handler cpu_arm_signal_handler
>  #define cpu_list arm_cpu_list
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 450eb3c..a35477e 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
>  #else
>          cpu_model = "qemu32";
>  #endif
> -#elif defined(TARGET_ARM)
> -        cpu_model = "any";
>  #elif defined(TARGET_UNICORE32)
>          cpu_model = "any";
>  #elif defined(TARGET_M68K)
> diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
> index 2eb13e8..1b213ff 100644
> --- a/tests/machine-none-test.c
> +++ b/tests/machine-none-test.c
> @@ -24,6 +24,8 @@ struct arch2cpu {
>  
>  static struct arch2cpu cpus_map[] = {
>      /* tested targets list */
> +    { "arm", "cortex-a15" },
> +    { "aarch64", "cortex-a15" },

I understand that this doesn't matter for your purposes, but can we change
the aarch64 mapping to point to an aarch64 processor, e.g. cortex-a57,
instead?

Thanks,
drew

>  };
>  
>  static const char *get_cpu_model_by_arch(const char *arch)
> -- 
> 2.7.4
> 
> 

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

* [Qemu-devel] [PATCH v4 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
  2018-01-23  9:45   ` Andrew Jones
@ 2018-01-23  9:51   ` Igor Mammedov
  2018-02-06 22:18   ` [Qemu-devel] [PATCH v3 " Eduardo Habkost
  2 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  9:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-arm, Peter Maydell, Andrew Jones

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
thest would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - use cortex-a57 for aarch64 test (Andrew Jones <drjones@redhat.com>)

CC: qemu-arm@nongnu.org
CC: Peter Maydell <peter.maydell@linaro.org>
CC: Andrew Jones <drjones@redhat.com>
---
 target/arm/cpu.h          | 1 +
 linux-user/main.c         | 2 --
 tests/machine-none-test.c | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 9631670..f9fb141 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2171,6 +2171,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_ARM_CPU
 
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
diff --git a/linux-user/main.c b/linux-user/main.c
index 450eb3c..a35477e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
 #else
         cpu_model = "qemu32";
 #endif
-#elif defined(TARGET_ARM)
-        cpu_model = "any";
 #elif defined(TARGET_UNICORE32)
         cpu_model = "any";
 #elif defined(TARGET_M68K)
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 2eb13e8..06139f5 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -24,6 +24,8 @@ struct arch2cpu {
 
 static struct arch2cpu cpus_map[] = {
     /* tested targets list */
+    { "arm", "cortex-a15" },
+    { "aarch64", "cortex-a57" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* [Qemu-devel] [PATCH v4 04/25] x86: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 04/25] x86: " Igor Mammedov
@ 2018-01-23  9:52   ` Igor Mammedov
  0 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-01-23  9:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Eduardo Habkost

it will be used for providing to cpu name resolving class for
parsing cpu model for system and user emulation code.

Along with change add target to null-machine test, so
that when switch to CPU_RESOLVING_TYPE happens,
test would ensure that null-mchine usecase still works.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - fix conflict due to cortex-a57 change in aarch64 entry
    in previous patch

CC: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/cpu.h         | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 30cc562..82c7381 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1568,6 +1568,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 
 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
 #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
+#define CPU_RESOLVING_TYPE TYPE_X86_CPU
 
 #ifdef TARGET_X86_64
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 06139f5..f4e00f5 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -26,6 +26,8 @@ static struct arch2cpu cpus_map[] = {
     /* tested targets list */
     { "arm", "cortex-a15" },
     { "aarch64", "cortex-a57" },
+    { "x86_64", "qemu64,apic-id=0" },
+    { "i386", "qemu32,apic-id=0" },
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v3 14/25] ppc: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 14/25] ppc: " Igor Mammedov
@ 2018-01-23 11:14   ` David Gibson
  0 siblings, 0 replies; 44+ messages in thread
From: David Gibson @ 2018-01-23 11:14 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Laurent Vivier, Eduardo Habkost, qemu-s390x,
	qemu-ppc, qemu-arm, Alexander Graf

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

On Tue, Jan 23, 2018 at 09:08:13AM +0100, Igor Mammedov wrote:
> it will be used for providing to cpu name resolving class for
> parsing cpu model for system and user emulation code.
> 
> Along with change add target to null-machine test, so
> that when switch to CPU_RESOLVING_TYPE happens,
> test would ensure that null-mchine usecase still works.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> CC: Laurent Vivier <laurent@vivier.eu>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Alexander Graf <agraf@suse.de>
> CC: qemu-ppc@nongnu.org
> ---
>  target/ppc/cpu.h          | 1 +
>  tests/machine-none-test.c | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 603a38c..d5f2f3d 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1380,6 +1380,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
>  
>  #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
>  #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> +#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
>  
>  #define cpu_signal_handler cpu_ppc_signal_handler
>  #define cpu_list ppc_cpu_list
> diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
> index 160aa13..052b8c0 100644
> --- a/tests/machine-none-test.c
> +++ b/tests/machine-none-test.c
> @@ -41,6 +41,9 @@ static struct arch2cpu cpus_map[] = {
>      { "moxie", "MoxieLite" },
>      { "nios2", "FIXME" },
>      { "or1k", "or1200" },
> +    { "ppc", "604" },
> +    { "ppc64", "power8e_v2.1" },
> +    { "ppcemb", "440epb" },
>  };
>  
>  static const char *get_cpu_model_by_arch(const char *arch)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines Igor Mammedov
@ 2018-01-23 11:15   ` David Gibson
  2018-02-06 22:26   ` Eduardo Habkost
  1 sibling, 0 replies; 44+ messages in thread
From: David Gibson @ 2018-01-23 11:15 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Laurent Vivier, Eduardo Habkost, qemu-s390x,
	qemu-ppc, qemu-arm, Richard Henderson, Peter Maydell,
	Edgar E. Iglesias, Michael Walle, Aurelien Jarno, Yongbok Kim,
	Anthony Green, Chris Wulff, Marek Vasut, Stafford Horne,
	Alexander Graf, Mark Cave-Ayland, Artyom Tarasenko,
	Bastian Koppelmann, Guan Xuetao, Max Filippov

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

On Tue, Jan 23, 2018 at 09:08:23AM +0100, Igor Mammedov wrote:
> cpu_init(cpu_model) were replaced by cpu_create(cpu_type) so
> no users are left, remove it.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

ppc parts

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> CC: Richard Henderson <rth@twiddle.net> (maintainer:Alpha)
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Laurent Vivier <laurent@vivier.eu>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Yongbok Kim <yongbok.kim@mips.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: Stafford Horne <shorne@gmail.com>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Alexander Graf <agraf@suse.de>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-arm@nongnu.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> ---
>  target/alpha/cpu.h      | 2 --
>  target/arm/cpu.h        | 2 --
>  target/cris/cpu.h       | 2 --
>  target/hppa/cpu.h       | 1 -
>  target/i386/cpu.h       | 2 --
>  target/lm32/cpu.h       | 2 --
>  target/m68k/cpu.h       | 2 --
>  target/microblaze/cpu.h | 1 -
>  target/mips/cpu.h       | 2 --
>  target/moxie/cpu.h      | 2 --
>  target/nios2/cpu.h      | 1 -
>  target/openrisc/cpu.h   | 2 --
>  target/ppc/cpu.h        | 2 --
>  target/s390x/cpu.h      | 2 --
>  target/sh4/cpu.h        | 2 --
>  target/sparc/cpu.h      | 4 ----
>  target/tilegx/cpu.h     | 1 -
>  target/tricore/cpu.h    | 2 --
>  target/unicore32/cpu.h  | 2 --
>  target/xtensa/cpu.h     | 2 --
>  20 files changed, 38 deletions(-)
> 
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index 21ed5d6..b3bec21 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -468,8 +468,6 @@ enum {
>  
>  void alpha_translate_init(void);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_ALPHA_CPU, cpu_model)
> -
>  #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
>  #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index f9fb141..b37d266 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -2167,8 +2167,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
>      return unmasked || pstate_unmasked;
>  }
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_ARM_CPU, cpu_model)
> -
>  #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
>  #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
>  #define CPU_RESOLVING_TYPE TYPE_ARM_CPU
> diff --git a/target/cris/cpu.h b/target/cris/cpu.h
> index 1a27653..db80cb1 100644
> --- a/target/cris/cpu.h
> +++ b/target/cris/cpu.h
> @@ -267,8 +267,6 @@ enum {
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_CRIS_CPU, cpu_model)
> -
>  #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
>  #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
>  #define CPU_RESOLVING_TYPE TYPE_CRIS_CPU
> diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
> index b92ae3f..628d7de 100644
> --- a/target/hppa/cpu.h
> +++ b/target/hppa/cpu.h
> @@ -112,7 +112,6 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
>  
>  void hppa_translate_init(void);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_HPPA_CPU, cpu_model)
>  #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
>  
>  void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 82c7381..1ed60b0 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1564,8 +1564,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
>  
>  #define PHYS_ADDR_MASK MAKE_64BIT_MASK(0, TCG_PHYS_ADDR_BITS)
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_X86_CPU, cpu_model)
> -
>  #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
>  #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
>  #define CPU_RESOLVING_TYPE TYPE_X86_CPU
> diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
> index 0656052..53939e5 100644
> --- a/target/lm32/cpu.h
> +++ b/target/lm32/cpu.h
> @@ -255,8 +255,6 @@ void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,
>  void lm32_watchpoint_remove(CPULM32State *env, int index);
>  bool lm32_cpu_do_semihosting(CPUState *cs);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_LM32_CPU, cpu_model)
> -
>  #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
>  #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_LM32_CPU
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 8a4299a..7d64804 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -401,8 +401,6 @@ void register_m68k_insns (CPUM68KState *env);
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
> -
>  #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
>  #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_M68K_CPU
> diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> index 492f9f7..a0ea421 100644
> --- a/target/microblaze/cpu.h
> +++ b/target/microblaze/cpu.h
> @@ -343,7 +343,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
>  #define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
>  
>  #define cpu_signal_handler cpu_mb_signal_handler
> diff --git a/target/mips/cpu.h b/target/mips/cpu.h
> index 0fcbfb3..cfe1735 100644
> --- a/target/mips/cpu.h
> +++ b/target/mips/cpu.h
> @@ -739,8 +739,6 @@ enum {
>  
>  int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model)
> -
>  #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
>  #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
> diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
> index 3f94a5a..5f8d10b 100644
> --- a/target/moxie/cpu.h
> +++ b/target/moxie/cpu.h
> @@ -120,8 +120,6 @@ void moxie_translate_init(void);
>  int cpu_moxie_signal_handler(int host_signum, void *pinfo,
>                               void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MOXIE_CPU, cpu_model)
> -
>  #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
>  #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 2234bff..8897e9a 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -231,7 +231,6 @@ void nios2_check_interrupts(CPUNios2State *env);
>  # define TARGET_VIRT_ADDR_SPACE_BITS 32
>  #endif
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
>  #define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
>  
>  #define cpu_gen_code cpu_nios2_gen_code
> diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
> index 9b32ea4..6f843fa 100644
> --- a/target/openrisc/cpu.h
> +++ b/target/openrisc/cpu.h
> @@ -390,8 +390,6 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
>                                 int *prot, target_ulong address, int rw);
>  #endif
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model)
> -
>  #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
>  #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index d5f2f3d..32c51fb 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1376,8 +1376,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
>  int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
>  int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)
> -
>  #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
>  #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index b2121cb..b3bfcf5 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -727,8 +727,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
>  
>  
>  /* helper.c */
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_model)
> -
>  #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
>  #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
>  #define CPU_RESOLVING_TYPE TYPE_S390_CPU
> diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
> index 709e0ca..c6418ef 100644
> --- a/target/sh4/cpu.h
> +++ b/target/sh4/cpu.h
> @@ -274,8 +274,6 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr);
>  
>  void cpu_load_tlb(CPUSH4State * env);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_SUPERH_CPU, cpu_model)
> -
>  #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
>  #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU
> diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
> index 345b39a..28f254d 100644
> --- a/target/sparc/cpu.h
> +++ b/target/sparc/cpu.h
> @@ -654,10 +654,6 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
>  #endif
>  int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#ifndef NO_CPU_IO_DEFS
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_SPARC_CPU, cpu_model)
> -#endif
> -
>  #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
>  #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
> diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h
> index a73215e..238f8d3 100644
> --- a/target/tilegx/cpu.h
> +++ b/target/tilegx/cpu.h
> @@ -164,7 +164,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env)
>  void tilegx_tcg_init(void);
>  int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
>  #define CPU_RESOLVING_TYPE TYPE_TILEGX_CPU
>  
>  #define cpu_signal_handler cpu_tilegx_signal_handler
> diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
> index a2ef632..13d629d 100644
> --- a/target/tricore/cpu.h
> +++ b/target/tricore/cpu.h
> @@ -411,8 +411,6 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
>      *flags = 0;
>  }
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_TRICORE_CPU, cpu_model)
> -
>  #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
>  #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
> diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
> index 9644b07..5ff8b98 100644
> --- a/target/unicore32/cpu.h
> +++ b/target/unicore32/cpu.h
> @@ -165,8 +165,6 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
>  
>  #include "exec/cpu-all.h"
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model)
> -
>  #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
>  #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
>  #define CPU_RESOLVING_TYPE TYPE_UNICORE32_CPU
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index 23dbd45..6481c3b 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -509,8 +509,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>  #endif
>  #define XTENSA_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_XTENSA_CPU, cpu_model)
> -
>  void xtensa_translate_init(void);
>  void xtensa_breakpoint_handler(CPUState *cs);
>  void xtensa_finalize_config(XtensaConfig *config);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [Qemu-devel] [PATCH v3 18/25] tricore: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 18/25] tricore: " Igor Mammedov
@ 2018-01-23 14:05   ` Bastian Koppelmann
  0 siblings, 0 replies; 44+ messages in thread
From: Bastian Koppelmann @ 2018-01-23 14:05 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel
  Cc: Eduardo Habkost, Laurent Vivier, qemu-s390x, qemu-arm, qemu-ppc

On 01/23/2018 09:08 AM, Igor Mammedov wrote:
> it will be used for providing to cpu name resolving class for
> parsing cpu model for system and user emulation code.
> 
> Along with change add target to null-machine test, so
> that when switch to CPU_RESOLVING_TYPE happens,
> test would ensure that null-mchine usecase still works.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>

Cheers,
Bastian

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

* Re: [Qemu-devel] [PATCH v3 08/25] m68k: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 08/25] m68k: " Igor Mammedov
@ 2018-01-24 12:58   ` Laurent Vivier
  0 siblings, 0 replies; 44+ messages in thread
From: Laurent Vivier @ 2018-01-24 12:58 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: qemu-s390x, qemu-arm, qemu-ppc, Eduardo Habkost

Le 23/01/2018 à 09:08, Igor Mammedov a écrit :
> it will be used for providing to cpu name resolving class for
> parsing cpu model for system and user emulation code.
> 
> Along with change add target to null-machine test, so
> that when switch to CPU_RESOLVING_TYPE happens,
> test would ensure that null-mchine usecase still works.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Laurent Vivier <laurent@vivier.eu>
> ---
>  target/m68k/cpu.h         | 1 +
>  tests/machine-none-test.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 2985b03..8a4299a 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -405,6 +405,7 @@ void register_m68k_insns (CPUM68KState *env);
>  
>  #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
>  #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
> +#define CPU_RESOLVING_TYPE TYPE_M68K_CPU
>  
>  #define cpu_signal_handler cpu_m68k_signal_handler
>  #define cpu_list m68k_cpu_list
> diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
> index 1159290..c9445b6 100644
> --- a/tests/machine-none-test.c
> +++ b/tests/machine-none-test.c
> @@ -31,6 +31,7 @@ static struct arch2cpu cpus_map[] = {
>      { "alpha", "ev67" },
>      { "cris", "crisv32" },
>      { "lm32", "lm32-full" },
> +    { "m68k", "m5206" },
>  };
>  
>  static const char *get_cpu_model_by_arch(const char *arch)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

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

* [Qemu-devel] [PATCH v4 23/25] Use cpu_create(type) instead of cpu_init(cpu_model)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model) Igor Mammedov
@ 2018-02-05 17:08   ` Igor Mammedov
  2018-02-06 22:25     ` Eduardo Habkost
  0 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-02-05 17:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Emilio G. Cota, Paolo Bonzini,
	Eduardo Habkost, Alex Bennée, Philippe Mathieu-Daudé

With all targets defining CPU_RESOLVING_TYPE, refactor
cpu_parse_cpu_model(type, cpu_model) to parse_cpu_model(cpu_model)
so that callers won't have to know internal resolving cpu
type. Place it in exec.c so it could be called from both
target independed vl.c and *-user/main.c.

That allows us to stop abusing cpu type from
  MachineClass::default_cpu_type
as resolver class in vl.c which were confusing part of
cpu_parse_cpu_model().

Also with new parse_cpu_model(), the last users of cpu_init()
in null-machine.c and bsd/linux-user targets could be switched
to cpu_create() API and cpu_init() API will be removed by
follow up patch.

With no longer users left remove MachineState::cpu_model field,
new code should use MachineState::cpu_type instead and
leave cpu_model parsing to generic code in vl.c.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v4:
  - actually remove no longer used MachineState::cpu_model field
    that I've lost somewhere during respins

  - squash in [PATCH v3 25/25] cpu: get rid of cpu_generic_init()
    as after rework/rebase cpu_generic_init() is being removed by
    this patch and only check removal was left in 25/25, which
    should be removed together with cpu_generic_init() in this patch

CC: Richard Henderson <richard.henderson@linaro.org>
CC: "Emilio G. Cota" <cota@braap.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: "Alex Bennée" <alex.bennee@linaro.org>
CC: "Philippe Mathieu-Daudé" <f4bug@amsat.org>

fixup: Use cpu_create(type) instead of  cpu_init(cpu_model)

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/boards.h    |  1 -
 include/qom/cpu.h      | 16 ++--------------
 bsd-user/main.c        |  4 +++-
 exec.c                 | 23 +++++++++++++++++++++++
 hw/core/null-machine.c |  6 +++---
 linux-user/main.c      |  8 ++++++--
 qom/cpu.c              | 48 ++----------------------------------------------
 vl.c                   | 10 +++-------
 8 files changed, 42 insertions(+), 74 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index efb0a9e..16b473a 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -251,7 +251,6 @@ struct MachineState {
     char *kernel_filename;
     char *kernel_cmdline;
     char *initrd_filename;
-    const char *cpu_model;
     const char *cpu_type;
     AccelState *accelerator;
     CPUArchIdList *possible_cpus;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 93bd546..0185589 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
 CPUState *cpu_create(const char *typename);
 
 /**
- * cpu_parse_cpu_model:
- * @typename: The CPU base type or CPU type.
+ * parse_cpu_model:
  * @cpu_model: The model string including optional parameters.
  *
  * processes optional parameters and registers them as global properties
@@ -670,18 +669,7 @@ CPUState *cpu_create(const char *typename);
  * Returns: type of CPU to create or prints error and terminates process
  *          if an error occurred.
  */
-const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model);
-
-/**
- * cpu_generic_init:
- * @typename: The CPU base type.
- * @cpu_model: The model string including optional parameters.
- *
- * Instantiates a CPU, processes optional parameters and realizes the CPU.
- *
- * Returns: A #CPUState or %NULL if an error occurred.
- */
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model);
+const char *parse_cpu_model(const char *cpu_model);
 
 /**
  * cpu_has_work:
diff --git a/bsd-user/main.c b/bsd-user/main.c
index efef5ff..cbc683a 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -723,6 +723,7 @@ int main(int argc, char **argv)
 {
     const char *filename;
     const char *cpu_model;
+    const char *cpu_type;
     const char *log_file = NULL;
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
@@ -900,7 +901,8 @@ int main(int argc, char **argv)
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+    cpu_type = parse_cpu_model(cpu_model);
+    cpu = create(cpu_type);
     env = cpu->env_ptr;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
     cpu_reset(cpu);
diff --git a/exec.c b/exec.c
index 629a508..8aee230 100644
--- a/exec.c
+++ b/exec.c
@@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
 #endif
 }
 
+const char *parse_cpu_model(const char *cpu_model)
+{
+    ObjectClass *oc;
+    CPUClass *cc;
+    gchar **model_pieces;
+    const char *cpu_type;
+
+    model_pieces = g_strsplit(cpu_model, ",", 2);
+
+    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
+    if (oc == NULL) {
+        error_report("unable to find CPU model '%s'", model_pieces[0]);
+        g_strfreev(model_pieces);
+        exit(EXIT_FAILURE);
+    }
+
+    cpu_type = object_class_get_name(oc);
+    cc = CPU_CLASS(oc);
+    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
+    g_strfreev(model_pieces);
+    return cpu_type;
+}
+
 #if defined(CONFIG_USER_ONLY)
 static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
 {
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index 864832d..cde4d3e 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -24,9 +24,9 @@ static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
 
-    /* Initialize CPU (if a model has been specified) */
-    if (mch->cpu_model) {
-        cpu = cpu_init(mch->cpu_model);
+    /* Initialize CPU (if user asked for it) */
+    if (mch->cpu_type) {
+        cpu = cpu_create(mch->cpu_type);
         if (!cpu) {
             error_report("Unable to initialize CPU");
             exit(1);
diff --git a/linux-user/main.c b/linux-user/main.c
index a35477e..0afb3f4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -44,6 +44,7 @@ static const char *argv0;
 static int gdbstub_port;
 static envlist_t *envlist;
 static const char *cpu_model;
+static const char *cpu_type;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
 int have_guest_base;
@@ -3847,7 +3848,7 @@ void init_task_state(TaskState *ts)
 CPUArchState *cpu_copy(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
-    CPUState *new_cpu = cpu_init(cpu_model);
+    CPUState *new_cpu = cpu_create(cpu_type);
     CPUArchState *new_env = new_cpu->env_ptr;
     CPUBreakpoint *bp;
     CPUWatchpoint *wp;
@@ -4357,10 +4358,13 @@ int main(int argc, char **argv, char **envp)
         cpu_model = "any";
 #endif
     }
+    cpu_type = parse_cpu_model(cpu_model);
+
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+
+    cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
     cpu_reset(cpu);
 
diff --git a/qom/cpu.c b/qom/cpu.c
index e42d9a7..cf6880d 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -67,37 +67,6 @@ CPUState *cpu_create(const char *typename)
     return cpu;
 }
 
-const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
-{
-    ObjectClass *oc;
-    CPUClass *cc;
-    gchar **model_pieces;
-    const char *cpu_type;
-
-    model_pieces = g_strsplit(cpu_model, ",", 2);
-
-    oc = cpu_class_by_name(typename, model_pieces[0]);
-    if (oc == NULL) {
-        error_report("unable to find CPU model '%s'", model_pieces[0]);
-        g_strfreev(model_pieces);
-        exit(EXIT_FAILURE);
-    }
-
-    cpu_type = object_class_get_name(oc);
-    cc = CPU_CLASS(oc);
-    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
-    g_strfreev(model_pieces);
-    return cpu_type;
-}
-
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
-{
-    /* TODO: all callers of cpu_generic_init() need to be converted to
-     * call cpu_parse_features() only once, before calling cpu_generic_init().
-     */
-    return cpu_create(cpu_parse_cpu_model(typename, cpu_model));
-}
-
 bool cpu_paging_enabled(const CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -335,22 +304,9 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
 static void cpu_common_parse_features(const char *typename, char *features,
                                       Error **errp)
 {
-    char *featurestr; /* Single "key=value" string being parsed */
     char *val;
-    static bool cpu_globals_initialized;
-
-    /* TODO: all callers of ->parse_features() need to be changed to
-     * call it only once, so we can remove this check (or change it
-     * to assert(!cpu_globals_initialized).
-     * Current callers of ->parse_features() are:
-     * - cpu_generic_init()
-     */
-    if (cpu_globals_initialized) {
-        return;
-    }
-    cpu_globals_initialized = true;
-
-    featurestr = features ? strtok(features, ",") : NULL;
+    /* Single "key=value" string being parsed */
+    char *featurestr = features ? strtok(features, ",") : NULL;
 
     while (featurestr) {
         val = strchr(featurestr, '=');
diff --git a/vl.c b/vl.c
index e725ecb..e45e831 100644
--- a/vl.c
+++ b/vl.c
@@ -4609,15 +4609,11 @@ int main(int argc, char **argv, char **envp)
     current_machine->maxram_size = maxram_size;
     current_machine->ram_slots = ram_slots;
     current_machine->boot_order = boot_order;
-    current_machine->cpu_model = cpu_model;
 
     /* parse features once if machine provides default cpu_type */
-    if (machine_class->default_cpu_type) {
-        current_machine->cpu_type = machine_class->default_cpu_type;
-        if (cpu_model) {
-            current_machine->cpu_type =
-                cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
-        }
+    current_machine->cpu_type = machine_class->default_cpu_type;
+    if (cpu_model) {
+        current_machine->cpu_type = parse_cpu_model(cpu_model);
     }
     parse_numa_opts(current_machine);
 
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init()
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init() Igor Mammedov
@ 2018-02-05 17:09   ` Igor Mammedov
  0 siblings, 0 replies; 44+ messages in thread
From: Igor Mammedov @ 2018-02-05 17:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Richard Henderson, Laurent Vivier,
	Philippe Mathieu-Daudé,
	qemu-s390x, qemu-arm, qemu-ppc, Paolo Bonzini, Alex Bennée,
	Emilio G. Cota

On Tue, 23 Jan 2018 09:08:24 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> There aren't any users of the helper left, remove it.
after rebase this patch nor longer does what subj says
and it should be squashed into 23/25 where cpu_generic_init() is removed,
so pls ignore this patch I'll post v4 for 23/25 with this squashed in
and actual removal of not used MachineState::cpu_model
which I've lost on rebase.

> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Richard Henderson <richard.henderson@linaro.org>
> CC: "Emilio G. Cota" <cota@braap.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: "Alex Bennée" <alex.bennee@linaro.org>
> CC: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> ---
>  qom/cpu.c | 17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/qom/cpu.c b/qom/cpu.c
> index aab8437..cf6880d 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -304,22 +304,9 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
>  static void cpu_common_parse_features(const char *typename, char *features,
>                                        Error **errp)
>  {
> -    char *featurestr; /* Single "key=value" string being parsed */
>      char *val;
> -    static bool cpu_globals_initialized;
> -
> -    /* TODO: all callers of ->parse_features() need to be changed to
> -     * call it only once, so we can remove this check (or change it
> -     * to assert(!cpu_globals_initialized).
> -     * Current callers of ->parse_features() are:
> -     * - cpu_generic_init()
> -     */
> -    if (cpu_globals_initialized) {
> -        return;
> -    }
> -    cpu_globals_initialized = true;
> -
> -    featurestr = features ? strtok(features, ",") : NULL;
> +    /* Single "key=value" string being parsed */
> +    char *featurestr = features ? strtok(features, ",") : NULL;
>  
>      while (featurestr) {
>          val = strchr(featurestr, '=');

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

* Re: [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
@ 2018-02-06 22:09   ` Eduardo Habkost
  0 siblings, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:09 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Marek Vasut, Chris Wulff, Laurent Vivier, qemu-s390x,
	qemu-arm, qemu-ppc

On Tue, Jan 23, 2018 at 09:08:00AM +0100, Igor Mammedov wrote:
> use cpu_create() instead of being removed cpu_generic_init()
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> ---
>  hw/nios2/10m50_devboard.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
> index e4007f6..42053b2 100644
> --- a/hw/nios2/10m50_devboard.c
> +++ b/hw/nios2/10m50_devboard.c
> @@ -75,7 +75,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
>                                  phys_ram_alias);
>  
>      /* Create CPU -- FIXME */
> -    cpu = NIOS2_CPU(cpu_generic_init(TYPE_NIOS2_CPU, "nios2"));
> +    cpu = NIOS2_CPU(cpu_create(TYPE_NIOS2_CPU));

Matches what nios2_cpu_class_by_name() does.

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test Igor Mammedov
@ 2018-02-06 22:13   ` Eduardo Habkost
  2018-02-06 22:21   ` Eduardo Habkost
  1 sibling, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:13 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, qemu-s390x, qemu-arm, qemu-ppc, Laurent Vivier

On Tue, Jan 23, 2018 at 09:08:01AM +0100, Igor Mammedov wrote:
> Check that "$QEMU -M none -cpu FOO" starts QEMU without error
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v2:
>   - rename file to machine-none-test.c (Thomas Huth <thuth@redhat.com>)
>   - use qtest_startf()/instead of qtest_start() (Thomas Huth <thuth@redhat.com>)
[...]
> +static struct arch2cpu cpus_map[] = {
> +    /* tested targets list */
> +};
[...]
> +static void test_machine_cpu_cli(void)
> +{
> +    QDict *response;
> +    const char *arch = qtest_get_arch();
> +    const char *cpu_model = get_cpu_model_by_arch(arch);
> +
> +    if (!cpu_model) {
> +        fprintf(stderr, "WARNING: cpu name for target '%s' isn't defined,"
> +                " add it to cpus_map\n", arch);
> +        return; /* TODO: die here to force all targets have a test */
> +    }

I'm unsure if it's OK to purposefully have intermediate commits
that will generate warnings on "make check".  It could confuse
people doing bisects.

I would prefer to add this warning only after all targets are
converted.  Or maybe only add this test code after all targets
are converted.

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
  2018-01-23  9:45   ` Andrew Jones
  2018-01-23  9:51   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
@ 2018-02-06 22:18   ` Eduardo Habkost
  2 siblings, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:18 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Peter Maydell, Andrew Jones, Laurent Vivier,
	qemu-s390x, qemu-arm, qemu-ppc

On Tue, Jan 23, 2018 at 09:08:02AM +0100, Igor Mammedov wrote:
> it will be used for providing to cpu name resolving class for
> parsing cpu model for system and user emulation code.
> 
> Along with change add target to null-machine test, so
> that when switch to CPU_RESOLVING_TYPE happens,
> thest would ensure that null-mchine usecase still works.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
[...]
> @@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
>  #else
>          cpu_model = "qemu32";
>  #endif
> -#elif defined(TARGET_ARM)
> -        cpu_model = "any";

I don't see any explanation for this hunk in the commit message.


>  #elif defined(TARGET_UNICORE32)
>          cpu_model = "any";
>  #elif defined(TARGET_M68K)
[...]

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test Igor Mammedov
  2018-02-06 22:13   ` Eduardo Habkost
@ 2018-02-06 22:21   ` Eduardo Habkost
  1 sibling, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:21 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, qemu-s390x, qemu-arm, qemu-ppc, Laurent Vivier

On Tue, Jan 23, 2018 at 09:08:01AM +0100, Igor Mammedov wrote:
> Check that "$QEMU -M none -cpu FOO" starts QEMU without error
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[...]
> +struct arch2cpu {
> +    const char *arch;
> +    const char *cpu_model;
> +};
> +
> +static struct arch2cpu cpus_map[] = {
> +    /* tested targets list */
> +};

Why are we testing only a single CPU model on each target (and
requiring one entry for each architecture in this table), instead
of just running query-cpu-definitions and testing all CPU models?

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v4 23/25] Use cpu_create(type) instead of cpu_init(cpu_model)
  2018-02-05 17:08   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
@ 2018-02-06 22:25     ` Eduardo Habkost
  0 siblings, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:25 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Richard Henderson, Philippe Mathieu-Daudé,
	Emilio G. Cota, Paolo Bonzini, Alex Bennée

On Mon, Feb 05, 2018 at 06:08:29PM +0100, Igor Mammedov wrote:
> With all targets defining CPU_RESOLVING_TYPE, refactor
> cpu_parse_cpu_model(type, cpu_model) to parse_cpu_model(cpu_model)
> so that callers won't have to know internal resolving cpu
> type. Place it in exec.c so it could be called from both
> target independed vl.c and *-user/main.c.
> 
> That allows us to stop abusing cpu type from
>   MachineClass::default_cpu_type
> as resolver class in vl.c which were confusing part of
> cpu_parse_cpu_model().
> 
> Also with new parse_cpu_model(), the last users of cpu_init()
> in null-machine.c and bsd/linux-user targets could be switched
> to cpu_create() API and cpu_init() API will be removed by
> follow up patch.
> 
> With no longer users left remove MachineState::cpu_model field,
> new code should use MachineState::cpu_type instead and
> leave cpu_model parsing to generic code in vl.c.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v4:
>   - actually remove no longer used MachineState::cpu_model field
>     that I've lost somewhere during respins
> 
>   - squash in [PATCH v3 25/25] cpu: get rid of cpu_generic_init()
>     as after rework/rebase cpu_generic_init() is being removed by
>     this patch and only check removal was left in 25/25, which
>     should be removed together with cpu_generic_init() in this patch
> 
> CC: Richard Henderson <richard.henderson@linaro.org>
> CC: "Emilio G. Cota" <cota@braap.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: "Alex Bennée" <alex.bennee@linaro.org>
> CC: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> 
> fixup: Use cpu_create(type) instead of  cpu_init(cpu_model)
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/boards.h    |  1 -
>  include/qom/cpu.h      | 16 ++--------------
>  bsd-user/main.c        |  4 +++-
>  exec.c                 | 23 +++++++++++++++++++++++
>  hw/core/null-machine.c |  6 +++---
>  linux-user/main.c      |  8 ++++++--
>  qom/cpu.c              | 48 ++----------------------------------------------
>  vl.c                   | 10 +++-------
>  8 files changed, 42 insertions(+), 74 deletions(-)

Less 32 lines.  Nice.  :)


[...]
> @@ -335,22 +304,9 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
>  static void cpu_common_parse_features(const char *typename, char *features,
>                                        Error **errp)
>  {
> -    char *featurestr; /* Single "key=value" string being parsed */
>      char *val;
> -    static bool cpu_globals_initialized;
> -
> -    /* TODO: all callers of ->parse_features() need to be changed to
> -     * call it only once, so we can remove this check (or change it
> -     * to assert(!cpu_globals_initialized).
> -     * Current callers of ->parse_features() are:
> -     * - cpu_generic_init()
> -     */
> -    if (cpu_globals_initialized) {
> -        return;

Suggestion: replace this with assert(!cpu_globals_initialized)
just to make sure there are no bugs that make us register CPU
globals twice.

This shouldn't block the patch, though:

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> -    }
> -    cpu_globals_initialized = true;
> -
> -    featurestr = features ? strtok(features, ",") : NULL;
> +    /* Single "key=value" string being parsed */
> +    char *featurestr = features ? strtok(features, ",") : NULL;
>  
>      while (featurestr) {
>          val = strchr(featurestr, '=');
[...]

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines Igor Mammedov
  2018-01-23 11:15   ` David Gibson
@ 2018-02-06 22:26   ` Eduardo Habkost
  1 sibling, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:26 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Peter Maydell, Anthony Green, Mark Cave-Ayland,
	Max Filippov, Edgar E. Iglesias, Guan Xuetao, Yongbok Kim,
	Marek Vasut, Alexander Graf, Richard Henderson, Artyom Tarasenko,
	qemu-s390x, qemu-arm, Stafford Horne, David Gibson,
	Bastian Koppelmann, Chris Wulff, Laurent Vivier, Michael Walle,
	qemu-ppc, Aurelien Jarno

On Tue, Jan 23, 2018 at 09:08:23AM +0100, Igor Mammedov wrote:
> cpu_init(cpu_model) were replaced by cpu_create(cpu_type) so
> no users are left, remove it.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4)
  2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (24 preceding siblings ...)
  2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init() Igor Mammedov
@ 2018-02-06 22:32 ` Eduardo Habkost
  2018-02-07  8:52   ` Igor Mammedov
  25 siblings, 1 reply; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-06 22:32 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, qemu-s390x, qemu-arm, qemu-ppc, Laurent Vivier

I will try to summarize my comments here:

* I suggest squashing patches 2-22 together.  This way we
  shouldn't have any intermediate commits where "make check"
  generates warnings, and the series is shorter.
  * Or, even better: squash the CPU_RESOLVING_TYPE parts of 3-22
    into one patch, and the tests/machine-none-test.c parts of
    3-22 into patch 2.

* The linux-user/main.c hunk of patch 03/25 looks unnecessary.

* I suggest testing all CPU models in patch 02/25, but this
  shouldn't block the series.  Can be a follow-up patch.

All the rest looks good to me.

Thanks!


On Tue, Jan 23, 2018 at 09:07:59AM +0100, Igor Mammedov wrote:
> 
> v3:
>   - use qtest_startf() instead of qtest_start()
>   - rename tests/machine-none.c to tests/machine-none-test.c
>   - introduce first CPU_RESOLVING_TYPE for all targets and
>     only then use it parse_cpu_model() 
>   - stop abusing  mc->default_cpu_type as resolving cpu type,
>     move cpu_parse_cpu_model() in to exec.c and embed in
>     CPU_RESOLVING_TYPE, so that callers won't have to know
>     about unnecessary detail
> 
> v2:
>   - implemented new approach only for x86/ARM (will be done for all targets
>     if approach seems acceptable)
>   - add test case for '-M none -cpu FOO' case
>   - redefine TARGET_DEFAULT_CPU_TYPE into CPU_RESOLVING_TYPE
>   - scrape off default cpu_model refactoring, so it would cause
>     less conflicts with Laurent's series where he tries to rework
>     defaults to use ELF hints of executed program
> 
> Series is finishing work on generalizing cpu_model parsing
> and limiting parts that deal with inconsistent cpu_model
> naming to "-cpu" CLI option in vl.c, bsd|linux-user/main.c
> CLI and default cpu_model processing and FOO_cpu_class_by_name()
> callbacks.
> 
> It introduces CPU_RESOLVING_TYPE which must be defined
> by each target and is used by helper parse_cpu_model()
> (former cpu_parse_cpu_model()) to get access to target
> specific FOO_cpu_class_by_name() callback.
> 
> git tree for testing:
>    https://github.com/imammedo/qemu.git cpu_init_removal_v3
> 
> CC: Laurent Vivier <laurent@vivier.eu>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: qemu-s390x@nongnu.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-arm@nongnu.org
> 
> Igor Mammedov (25):
>   nios2: 10m50_devboard: replace cpu_model with cpu_type
>   tests: add machine 'none' with -cpu test
>   arm: cpu: add CPU_RESOLVING_TYPE macro
>   x86: cpu: add CPU_RESOLVING_TYPE macro
>   alpha: cpu: add CPU_RESOLVING_TYPE macro
>   cris: cpu: add CPU_RESOLVING_TYPE macro
>   lm32: cpu: add CPU_RESOLVING_TYPE macro
>   m68k: cpu: add CPU_RESOLVING_TYPE macro
>   microblaze: cpu: add CPU_RESOLVING_TYPE macro
>   mips: cpu: add CPU_RESOLVING_TYPE macro
>   moxie: cpu: add CPU_RESOLVING_TYPE macro
>   nios2: cpu: add CPU_RESOLVING_TYPE macro
>   openrisc: cpu: add CPU_RESOLVING_TYPE macro
>   ppc: cpu: add CPU_RESOLVING_TYPE macro
>   s390x: cpu: add CPU_RESOLVING_TYPE macro
>   sh4: cpu: add CPU_RESOLVING_TYPE macro
>   sparc: cpu: add CPU_RESOLVING_TYPE macro
>   tricore: cpu: add CPU_RESOLVING_TYPE macro
>   unicore32: cpu: add CPU_RESOLVING_TYPE macro
>   xtensa: cpu: add CPU_RESOLVING_TYPE macro
>   hppa: cpu: add CPU_RESOLVING_TYPE macro
>   tilegx: cpu: add CPU_RESOLVING_TYPE macro
>   Use cpu_create(type) instead of cpu_init(cpu_model)
>   cpu: get rid of unused cpu_init() defines
>   cpu: get rid of cpu_generic_init()
> 
>  include/qom/cpu.h         | 16 +-------
>  target/alpha/cpu.h        |  3 +-
>  target/arm/cpu.h          |  3 +-
>  target/cris/cpu.h         |  3 +-
>  target/hppa/cpu.h         |  2 +-
>  target/i386/cpu.h         |  3 +-
>  target/lm32/cpu.h         |  3 +-
>  target/m68k/cpu.h         |  3 +-
>  target/microblaze/cpu.h   |  2 +-
>  target/mips/cpu.h         |  3 +-
>  target/moxie/cpu.h        |  3 +-
>  target/nios2/cpu.h        |  2 +-
>  target/openrisc/cpu.h     |  3 +-
>  target/ppc/cpu.h          |  3 +-
>  target/s390x/cpu.h        |  3 +-
>  target/sh4/cpu.h          |  3 +-
>  target/sparc/cpu.h        |  5 +--
>  target/tilegx/cpu.h       |  2 +-
>  target/tricore/cpu.h      |  3 +-
>  target/unicore32/cpu.h    |  3 +-
>  target/xtensa/cpu.h       |  3 +-
>  bsd-user/main.c           |  4 +-
>  exec.c                    | 23 +++++++++++
>  hw/core/null-machine.c    |  6 +--
>  hw/nios2/10m50_devboard.c |  2 +-
>  linux-user/main.c         | 10 +++--
>  qom/cpu.c                 | 48 +----------------------
>  tests/Makefile.include    |  2 +
>  tests/machine-none-test.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++
>  vl.c                      | 10 ++---
>  30 files changed, 162 insertions(+), 114 deletions(-)
>  create mode 100644 tests/machine-none-test.c
> 
> -- 
> 2.7.4
> 
> 

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4)
  2018-02-06 22:32 ` [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Eduardo Habkost
@ 2018-02-07  8:52   ` Igor Mammedov
  2018-02-07 12:00     ` Eduardo Habkost
  0 siblings, 1 reply; 44+ messages in thread
From: Igor Mammedov @ 2018-02-07  8:52 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, qemu-s390x, qemu-arm, qemu-ppc, Laurent Vivier

On Tue, 6 Feb 2018 20:32:13 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> I will try to summarize my comments here:

Thanks for review

> * I suggest squashing patches 2-22 together.  This way we
>   shouldn't have any intermediate commits where "make check"
>   generates warnings, and the series is shorter.
>   * Or, even better: squash the CPU_RESOLVING_TYPE parts of 3-22
>     into one patch, and the tests/machine-none-test.c parts of
>     3-22 into patch 2.
CPU_RESOLVING_TYPE parts we split to simplify review
for target maintainers.
I'll respin squashing them into one commit.

> 
> * The linux-user/main.c hunk of patch 03/25 looks unnecessary.
Indeed, I think it was a leftover slipped in from previous revision
where I was touching default cpus handling in *-user targets,
with the later dropped from series it's not needed.

> * I suggest testing all CPU models in patch 02/25, but this
>   shouldn't block the series.  Can be a follow-up patch.
the goal of the test is that refactoring didn't regress
'none' machine after following change in 23/25:

@@ -24,9 +24,9 @@ static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
 
-    /* Initialize CPU (if a model has been specified) */
-    if (mch->cpu_model) {
-        cpu = cpu_init(mch->cpu_model);
+    /* Initialize CPU (if user asked for it) */
+    if (mch->cpu_type) {
+        cpu = cpu_create(mch->cpu_type);

for that it's sufficient to probe one cpu model.

We can do all cpus probing later if there will be need in it,
but that's not related to this series and would just waste
'make check' time if it won't be doing something meaningful
with probed cpu.

> All the rest looks good to me.
> 
> Thanks!
> 
> 
> On Tue, Jan 23, 2018 at 09:07:59AM +0100, Igor Mammedov wrote:
> > 
> > v3:
> >   - use qtest_startf() instead of qtest_start()
> >   - rename tests/machine-none.c to tests/machine-none-test.c
> >   - introduce first CPU_RESOLVING_TYPE for all targets and
> >     only then use it parse_cpu_model() 
> >   - stop abusing  mc->default_cpu_type as resolving cpu type,
> >     move cpu_parse_cpu_model() in to exec.c and embed in
> >     CPU_RESOLVING_TYPE, so that callers won't have to know
> >     about unnecessary detail
> > 
> > v2:
> >   - implemented new approach only for x86/ARM (will be done for all targets
> >     if approach seems acceptable)
> >   - add test case for '-M none -cpu FOO' case
> >   - redefine TARGET_DEFAULT_CPU_TYPE into CPU_RESOLVING_TYPE
> >   - scrape off default cpu_model refactoring, so it would cause
> >     less conflicts with Laurent's series where he tries to rework
> >     defaults to use ELF hints of executed program
> > 
> > Series is finishing work on generalizing cpu_model parsing
> > and limiting parts that deal with inconsistent cpu_model
> > naming to "-cpu" CLI option in vl.c, bsd|linux-user/main.c
> > CLI and default cpu_model processing and FOO_cpu_class_by_name()
> > callbacks.
> > 
> > It introduces CPU_RESOLVING_TYPE which must be defined
> > by each target and is used by helper parse_cpu_model()
> > (former cpu_parse_cpu_model()) to get access to target
> > specific FOO_cpu_class_by_name() callback.
> > 
> > git tree for testing:
> >    https://github.com/imammedo/qemu.git cpu_init_removal_v3
> > 
> > CC: Laurent Vivier <laurent@vivier.eu>
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: qemu-s390x@nongnu.org
> > CC: qemu-ppc@nongnu.org
> > CC: qemu-arm@nongnu.org
> > 
> > Igor Mammedov (25):
> >   nios2: 10m50_devboard: replace cpu_model with cpu_type
> >   tests: add machine 'none' with -cpu test
> >   arm: cpu: add CPU_RESOLVING_TYPE macro
> >   x86: cpu: add CPU_RESOLVING_TYPE macro
> >   alpha: cpu: add CPU_RESOLVING_TYPE macro
> >   cris: cpu: add CPU_RESOLVING_TYPE macro
> >   lm32: cpu: add CPU_RESOLVING_TYPE macro
> >   m68k: cpu: add CPU_RESOLVING_TYPE macro
> >   microblaze: cpu: add CPU_RESOLVING_TYPE macro
> >   mips: cpu: add CPU_RESOLVING_TYPE macro
> >   moxie: cpu: add CPU_RESOLVING_TYPE macro
> >   nios2: cpu: add CPU_RESOLVING_TYPE macro
> >   openrisc: cpu: add CPU_RESOLVING_TYPE macro
> >   ppc: cpu: add CPU_RESOLVING_TYPE macro
> >   s390x: cpu: add CPU_RESOLVING_TYPE macro
> >   sh4: cpu: add CPU_RESOLVING_TYPE macro
> >   sparc: cpu: add CPU_RESOLVING_TYPE macro
> >   tricore: cpu: add CPU_RESOLVING_TYPE macro
> >   unicore32: cpu: add CPU_RESOLVING_TYPE macro
> >   xtensa: cpu: add CPU_RESOLVING_TYPE macro
> >   hppa: cpu: add CPU_RESOLVING_TYPE macro
> >   tilegx: cpu: add CPU_RESOLVING_TYPE macro
> >   Use cpu_create(type) instead of cpu_init(cpu_model)
> >   cpu: get rid of unused cpu_init() defines
> >   cpu: get rid of cpu_generic_init()
> > 
> >  include/qom/cpu.h         | 16 +-------
> >  target/alpha/cpu.h        |  3 +-
> >  target/arm/cpu.h          |  3 +-
> >  target/cris/cpu.h         |  3 +-
> >  target/hppa/cpu.h         |  2 +-
> >  target/i386/cpu.h         |  3 +-
> >  target/lm32/cpu.h         |  3 +-
> >  target/m68k/cpu.h         |  3 +-
> >  target/microblaze/cpu.h   |  2 +-
> >  target/mips/cpu.h         |  3 +-
> >  target/moxie/cpu.h        |  3 +-
> >  target/nios2/cpu.h        |  2 +-
> >  target/openrisc/cpu.h     |  3 +-
> >  target/ppc/cpu.h          |  3 +-
> >  target/s390x/cpu.h        |  3 +-
> >  target/sh4/cpu.h          |  3 +-
> >  target/sparc/cpu.h        |  5 +--
> >  target/tilegx/cpu.h       |  2 +-
> >  target/tricore/cpu.h      |  3 +-
> >  target/unicore32/cpu.h    |  3 +-
> >  target/xtensa/cpu.h       |  3 +-
> >  bsd-user/main.c           |  4 +-
> >  exec.c                    | 23 +++++++++++
> >  hw/core/null-machine.c    |  6 +--
> >  hw/nios2/10m50_devboard.c |  2 +-
> >  linux-user/main.c         | 10 +++--
> >  qom/cpu.c                 | 48 +----------------------
> >  tests/Makefile.include    |  2 +
> >  tests/machine-none-test.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++
> >  vl.c                      | 10 ++---
> >  30 files changed, 162 insertions(+), 114 deletions(-)
> >  create mode 100644 tests/machine-none-test.c
> > 
> > -- 
> > 2.7.4
> > 
> >   
> 

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

* Re: [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4)
  2018-02-07  8:52   ` Igor Mammedov
@ 2018-02-07 12:00     ` Eduardo Habkost
  0 siblings, 0 replies; 44+ messages in thread
From: Eduardo Habkost @ 2018-02-07 12:00 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, qemu-s390x, qemu-arm, qemu-ppc, Laurent Vivier

On Wed, Feb 07, 2018 at 09:52:25AM +0100, Igor Mammedov wrote:
[...]
> > * I suggest testing all CPU models in patch 02/25, but this
> >   shouldn't block the series.  Can be a follow-up patch.
> the goal of the test is that refactoring didn't regress
> 'none' machine after following change in 23/25:
> 
> @@ -24,9 +24,9 @@ static void machine_none_init(MachineState *mch)
>  {
>      CPUState *cpu = NULL;
>  
> -    /* Initialize CPU (if a model has been specified) */
> -    if (mch->cpu_model) {
> -        cpu = cpu_init(mch->cpu_model);
> +    /* Initialize CPU (if user asked for it) */
> +    if (mch->cpu_type) {
> +        cpu = cpu_create(mch->cpu_type);
> 
> for that it's sufficient to probe one cpu model.
> 
> We can do all cpus probing later if there will be need in it,
> but that's not related to this series and would just waste
> 'make check' time if it won't be doing something meaningful
> with probed cpu.

Not making "make check" slow is a good argument, I agree.

Extensive testing like testing all CPU models or all devices
probably should be done in a separate (slower) test set.

-- 
Eduardo

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

end of thread, other threads:[~2018-02-07 12:00 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23  8:07 [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
2018-02-06 22:09   ` Eduardo Habkost
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test Igor Mammedov
2018-02-06 22:13   ` Eduardo Habkost
2018-02-06 22:21   ` Eduardo Habkost
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
2018-01-23  9:45   ` Andrew Jones
2018-01-23  9:51   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
2018-02-06 22:18   ` [Qemu-devel] [PATCH v3 " Eduardo Habkost
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 04/25] x86: " Igor Mammedov
2018-01-23  9:52   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 05/25] alpha: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 06/25] cris: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 07/25] lm32: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 08/25] m68k: " Igor Mammedov
2018-01-24 12:58   ` Laurent Vivier
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 09/25] microblaze: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 10/25] mips: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 11/25] moxie: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 12/25] nios2: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 13/25] openrisc: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 14/25] ppc: " Igor Mammedov
2018-01-23 11:14   ` David Gibson
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 15/25] s390x: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 16/25] sh4: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 17/25] sparc: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 18/25] tricore: " Igor Mammedov
2018-01-23 14:05   ` Bastian Koppelmann
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 19/25] unicore32: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 20/25] xtensa: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 21/25] hppa: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 22/25] tilegx: " Igor Mammedov
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 23/25] Use cpu_create(type) instead of cpu_init(cpu_model) Igor Mammedov
2018-02-05 17:08   ` [Qemu-devel] [PATCH v4 " Igor Mammedov
2018-02-06 22:25     ` Eduardo Habkost
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines Igor Mammedov
2018-01-23 11:15   ` David Gibson
2018-02-06 22:26   ` Eduardo Habkost
2018-01-23  8:08 ` [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init() Igor Mammedov
2018-02-05 17:09   ` Igor Mammedov
2018-02-06 22:32 ` [Qemu-devel] [PATCH v3 00/25] generalize parsing of cpu_model (part 4) Eduardo Habkost
2018-02-07  8:52   ` Igor Mammedov
2018-02-07 12:00     ` Eduardo Habkost

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.