Skip to contentSkip to conversation

generalize parsing of cpu_model (part 4)

PATCH Superseded Igor Mammedov 6 participants 44 messages Jan 23, 2018 – Feb 7, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover generalize parsing of cpu_model (part 4)

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

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
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/25 nios2: 10m50_devboard: replace cpu_model with cpu_type

use cpu_create() instead of being removed cpu_generic_init()

---
CC: Chris Wulff <[email protected]>
CC: Marek Vasut <[email protected]>

---
 hw/nios2/10m50_devboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nios2/10m50_devboard.c +1 -1
index e4007f6..42053b2 100644
@@ -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);
Signature · 1 line
2.7.4
Reviewed-by on v3 1/25
#2 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 01/25] nios2: 10m50_devboard: replace cpu_model with cpu_type

Quoted 15 lines · Igor Mammedov

use cpu_create() instead of being removed cpu_generic_init()

---
CC: Chris Wulff <[email protected]>
CC: Marek Vasut <[email protected]>

---
 hw/nios2/10m50_devboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nios2/10m50_devboard.c +0 -0
index e4007f6..42053b2 100644

hw/nios2/10m50_devboard.c static void nios2_10m50_ghrd_init(MachineState *machine) · line 78

Quoted 5 lines
hw/nios2/10m50_devboard.c +1 -1
@@ -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.

Signature · 1 line
Eduardo
#3 lore raw

PATCH v3 2/25 tests: add machine 'none' with -cpu test

In reply to Igor Mammedov

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

---
v2:
- rename file to machine-none-test.c (Thomas Huth <[email protected]>)
- use qtest_startf()/instead of qtest_start() (Thomas Huth <[email protected]>)

---
 tests/Makefile.include    |  2 ++
 tests/machine-none-test.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 tests/machine-none-test.c
tests/Makefile.include +2 -0
index 8883274..ea0a803 100644
@@ -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
tests/machine-none-test.c new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test

Quoted 7 lines · Igor Mammedov

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

---
v2:
- rename file to machine-none-test.c (Thomas Huth <[email protected]>)
- use qtest_startf()/instead of qtest_start() (Thomas Huth <[email protected]>)

[...]

Quoted 3 lines
tests/machine-none-test.c new file +3 -0
+static struct arch2cpu cpus_map[] = {
+    /* tested targets list */
+};

[...]

tests/machine-none-test.c line 51

Quoted 11 lines
tests/machine-none-test.c new file +11 -0
+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.

Signature · 1 line
Eduardo
#5 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 02/25] tests: add machine 'none' with -cpu test

In reply to Igor Mammedov
Quoted 3 lines · Igor Mammedov

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

[...]

tests/machine-none-test.c line 27

Quoted 8 lines
tests/machine-none-test.c new file +8 -0
+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?

Signature · 1 line
Eduardo
#6 lore raw

PATCH v3 3/25 arm: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: [email protected]
CC: Peter Maydell <[email protected]>
CC: Andrew Jones <[email protected]>

---
 target/arm/cpu.h          | 1 +
 linux-user/main.c         | 2 --
 tests/machine-none-test.c | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)
target/arm/cpu.h +1 -0
index 9631670..f9fb141 100644
@@ -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
linux-user/main.c +0 -2
index 450eb3c..a35477e 100644
@@ -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)
tests/machine-none-test.c +2 -0
index 2eb13e8..1b213ff 100644
@@ -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)
Signature · 1 line
2.7.4
#7 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro

Quoted 48 lines · Igor Mammedov

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.

---
CC: [email protected]
CC: Peter Maydell <[email protected]>
CC: Andrew Jones <[email protected]>

---
 target/arm/cpu.h          | 1 +
 linux-user/main.c         | 2 --
 tests/machine-none-test.c | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)
target/arm/cpu.h +1 -0
index 9631670..f9fb141 100644
@@ -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
linux-user/main.c +0 -2
index 450eb3c..a35477e 100644
@@ -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)
tests/machine-none-test.c +0 -0
index 2eb13e8..1b213ff 100644

tests/machine-none-test.c struct arch2cpu { · line 28

Quoted 5 lines
tests/machine-none-test.c +2 -0
@@ -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

Quoted 7 lines
tests/machine-none-test.c +0 -0
 };
 
 static const char *get_cpu_model_by_arch(const char *arch)
Signature · 1 line
2.7.4
#8 lore raw

PATCH v4 3/25 arm: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
v2:
- use cortex-a57 for aarch64 test (Andrew Jones <[email protected]>)

CC Peter Maydell <[email protected]>
CC Andrew Jones <[email protected]>
---
 target/arm/cpu.h          | 1 +
 linux-user/main.c         | 2 --
 tests/machine-none-test.c | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)
target/arm/cpu.h +1 -0
index 9631670..f9fb141 100644
@@ -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
linux-user/main.c +0 -2
index 450eb3c..a35477e 100644
@@ -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)
tests/machine-none-test.c +2 -0
index 2eb13e8..06139f5 100644
@@ -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)
Signature · 1 line
2.7.4
#9 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 03/25] arm: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov
Quoted 9 lines · Igor Mammedov

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.

---

[...]

linux-user/main.c int main(int argc, char **argv, char **envp) · line 4329

Quoted 6 lines
linux-user/main.c +0 -2
@@ -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.

Quoted 3 lines
linux-user/main.c +0 -0
 #elif defined(TARGET_UNICORE32)
         cpu_model = "any";
 #elif defined(TARGET_M68K)

[...]

Signature · 1 line
Eduardo
#10 lore raw

PATCH v3 4/25 x86: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Eduardo Habkost <[email protected]>

---
 target/i386/cpu.h         | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)
target/i386/cpu.h +1 -0
index 30cc562..82c7381 100644
@@ -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")
tests/machine-none-test.c +2 -0
index 1b213ff..4b704fb 100644
@@ -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)
Signature · 1 line
2.7.4
#11 lore raw

PATCH v4 4/25 x86: cpu: add CPU_RESOLVING_TYPE macro

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.

---
v2:
- fix conflict due to cortex-a57 change in aarch64 entry in previous patch

CC Eduardo Habkost <[email protected]>
---
 target/i386/cpu.h         | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)
target/i386/cpu.h +1 -0
index 30cc562..82c7381 100644
@@ -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")
tests/machine-none-test.c +2 -0
index 06139f5..f4e00f5 100644
@@ -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)
Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 5/25 alpha: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Richard Henderson <[email protected]>

---
 target/alpha/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/alpha/cpu.h +1 -0
index 0a9ad35..21ed5d6 100644
@@ -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
tests/machine-none-test.c +1 -0
index 4b704fb..5d23ade 100644
@@ -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)
Signature · 1 line
2.7.4
#13 lore raw

PATCH v3 6/25 cris: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: "Edgar E. Iglesias" <[email protected]>

---
 target/cris/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/cris/cpu.h +1 -0
index b64fa35..1a27653 100644
@@ -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
 
tests/machine-none-test.c +1 -0
index 5d23ade..68f7a30 100644
@@ -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)
Signature · 1 line
2.7.4
#14 lore raw

PATCH v3 7/25 lm32: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Michael Walle <[email protected]>

---
 target/lm32/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/lm32/cpu.h +1 -0
index 2279594..0656052 100644
@@ -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
tests/machine-none-test.c +1 -0
index 68f7a30..1159290 100644
@@ -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)
Signature · 1 line
2.7.4
#15 lore raw

PATCH v3 8/25 m68k: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Laurent Vivier <[email protected]>

---
 target/m68k/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/m68k/cpu.h +1 -0
index 2985b03..8a4299a 100644
@@ -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
tests/machine-none-test.c +1 -0
index 1159290..c9445b6 100644
@@ -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)
Signature · 1 line
2.7.4
Reviewed-by on v3 8/25
#16 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 08/25] m68k: cpu: add CPU_RESOLVING_TYPE macro

Le 23/01/2018 à 09:08, Igor Mammedov a écrit :

Quoted 33 lines

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.

---
CC: Laurent Vivier <[email protected]>

---
 target/m68k/cpu.h         | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/m68k/cpu.h +1 -0
index 2985b03..8a4299a 100644
@@ -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
tests/machine-none-test.c +0 -0
index 1159290..c9445b6 100644

tests/machine-none-test.c static struct arch2cpu cpus_map[] = { · line 37

Quoted 7 lines
tests/machine-none-test.c +1 -0
@@ -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)
#17 lore raw

PATCH v3 9/25 microblaze: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: "Edgar E. Iglesias" <[email protected]>

---
 target/microblaze/cpu.h   | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)
target/microblaze/cpu.h +1 -0
index 52b6b6a..492f9f7 100644
@@ -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
 
tests/machine-none-test.c +2 -0
index c9445b6..984def6 100644
@@ -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)
Signature · 1 line
2.7.4
#18 lore raw

PATCH v3 10/25 mips: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Aurelien Jarno <[email protected]>
CC: Yongbok Kim <[email protected]>

---
 target/mips/cpu.h         | 1 +
 tests/machine-none-test.c | 4 ++++
 2 files changed, 5 insertions(+)
target/mips/cpu.h +1 -0
index 7f8ba5f..0fcbfb3 100644
@@ -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);
tests/machine-none-test.c +4 -0
index 984def6..9bc6a06 100644
@@ -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)
Signature · 1 line
2.7.4
#19 lore raw

PATCH v3 11/25 moxie: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Anthony Green <[email protected]>

---
 target/moxie/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/moxie/cpu.h +1 -0
index d37e6a5..3f94a5a 100644
@@ -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
 
tests/machine-none-test.c +1 -0
index 9bc6a06..c15a857 100644
@@ -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)
Signature · 1 line
2.7.4
#20 lore raw

PATCH v3 12/25 nios2: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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

---
CC: Chris Wulff <[email protected]>
CC: Marek Vasut <[email protected]>

---
 target/nios2/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/nios2/cpu.h +1 -0
index 88823a6..2234bff 100644
@@ -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
tests/machine-none-test.c +1 -0
index c15a857..c6ad495 100644
@@ -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)
Signature · 1 line
2.7.4
#21 lore raw

PATCH v3 13/25 openrisc: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Stafford Horne <[email protected]>

---
 target/openrisc/cpu.h     | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/openrisc/cpu.h +1 -0
index cc22dc8..9b32ea4 100644
@@ -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"
 
tests/machine-none-test.c +1 -0
index c6ad495..160aa13 100644
@@ -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)
Signature · 1 line
2.7.4
#22 lore raw

PATCH v3 14/25 ppc: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Laurent Vivier <[email protected]>
CC: David Gibson <[email protected]>
CC: Alexander Graf <[email protected]>
CC: [email protected]

---
 target/ppc/cpu.h          | 1 +
 tests/machine-none-test.c | 3 +++
 2 files changed, 4 insertions(+)
target/ppc/cpu.h +1 -0
index 603a38c..d5f2f3d 100644
@@ -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
tests/machine-none-test.c +3 -0
index 160aa13..052b8c0 100644
@@ -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)
Signature · 1 line
2.7.4
Acked-by on v3 14/25
#23 lore raw

Re: [Qemu-arm] [PATCH v3 14/25] ppc: cpu: add CPU_RESOLVING_TYPE macro

Quoted 8 lines · Igor Mammedov

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.

Quoted 36 lines

---
CC: Laurent Vivier <[email protected]>
CC: David Gibson <[email protected]>
CC: Alexander Graf <[email protected]>
CC: [email protected]

---
 target/ppc/cpu.h          | 1 +
 tests/machine-none-test.c | 3 +++
 2 files changed, 4 insertions(+)
target/ppc/cpu.h +1 -0
index 603a38c..d5f2f3d 100644
@@ -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
tests/machine-none-test.c +3 -0
index 160aa13..052b8c0 100644
@@ -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)
Signature · 4 lines
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
#24 lore raw

PATCH v3 15/25 s390x: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Richard Henderson <[email protected]>
CC: Alexander Graf <[email protected]>
CC: [email protected]

---
 target/s390x/cpu.h        | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/s390x/cpu.h +1 -0
index 1a8b6b9..b2121cb 100644
@@ -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
tests/machine-none-test.c +1 -0
index 052b8c0..b3a346d 100644
@@ -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)
Signature · 1 line
2.7.4
#25 lore raw

PATCH v3 16/25 sh4: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Aurelien Jarno <[email protected]>

---
 target/sh4/cpu.h          | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)
target/sh4/cpu.h +1 -0
index a2c26e0..709e0ca 100644
@@ -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
tests/machine-none-test.c +2 -0
index b3a346d..134036a 100644
@@ -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)
Signature · 1 line
2.7.4
#26 lore raw

PATCH v3 17/25 sparc: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Mark Cave-Ayland <[email protected]>
CC: Artyom Tarasenko <[email protected]>

---
 target/sparc/cpu.h        | 1 +
 tests/machine-none-test.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
target/sparc/cpu.h +1 -0
index 9fde547..345b39a 100644
@@ -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
tests/machine-none-test.c +3 -1
index 134036a..0f80d7b 100644
@@ -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"));
Signature · 1 line
2.7.4
#27 lore raw

PATCH v3 18/25 tricore: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Bastian Koppelmann <[email protected]>

---
 target/tricore/cpu.h      | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/tricore/cpu.h +1 -0
index f41d2ce..a2ef632 100644
@@ -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,
tests/machine-none-test.c +1 -0
index 0f80d7b..0430b06 100644
@@ -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)
Signature · 1 line
2.7.4
Acked-by on v3 18/25
#28 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v3 18/25] tricore: cpu: add CPU_RESOLVING_TYPE macro

Quoted 8 lines · Igor Mammedov

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.

Cheers,
Bastian

#29 lore raw

PATCH v3 19/25 unicore32: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Laurent Vivier <[email protected]>
CC: Guan Xuetao <[email protected]>

---
 target/unicore32/cpu.h    | 1 +
 tests/machine-none-test.c | 1 +
 2 files changed, 2 insertions(+)
target/unicore32/cpu.h +1 -0
index 3dc6fbc..9644b07 100644
@@ -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)
tests/machine-none-test.c +1 -0
index 0430b06..a8a499e 100644
@@ -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)
Signature · 1 line
2.7.4
#30 lore raw

PATCH v3 20/25 xtensa: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Max Filippov <[email protected]>

---
 target/xtensa/cpu.h       | 1 +
 tests/machine-none-test.c | 2 ++
 2 files changed, 3 insertions(+)
target/xtensa/cpu.h +1 -0
index d9404aa..23dbd45 100644
@@ -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"
tests/machine-none-test.c +2 -0
index a8a499e..a1e9980 100644
@@ -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)
Signature · 1 line
2.7.4
#31 lore raw

PATCH v3 21/25 hppa: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Richard Henderson <[email protected]>

---
 target/hppa/cpu.h | 1 +
 1 file changed, 1 insertion(+)
target/hppa/cpu.h +1 -0
index 8d14077..b92ae3f 100644
@@ -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);
 
Signature · 1 line
2.7.4
#32 lore raw

PATCH v3 22/25 tilegx: cpu: add CPU_RESOLVING_TYPE macro

In reply to Igor Mammedov

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.

---
CC: Eduardo Habkost <[email protected]>

---
 target/tilegx/cpu.h | 1 +
 1 file changed, 1 insertion(+)
target/tilegx/cpu.h +1 -0
index 71cea04..a73215e 100644
@@ -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
 
Signature · 1 line
2.7.4
#33 lore raw

PATCH v3 23/25 Use cpu_create(type) instead of cpu_init(cpu_model)

In reply to Igor Mammedov

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.

---
 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(-)
include/qom/cpu.h +2 -14
index 93bd546..0185589 100644
@@ -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:
bsd-user/main.c +3 -1
index efef5ff..cbc683a 100644
@@ -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);
exec.c +23 -0
index 629a508..8aee230 100644
@@ -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)
 {
hw/core/null-machine.c +3 -3
index 864832d..cde4d3e 100644
@@ -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);
linux-user/main.c +6 -2
index a35477e..0afb3f4 100644
@@ -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);
 
qom/cpu.c +0 -31
index e42d9a7..aab8437 100644
@@ -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);
vl.c +3 -7
index e725ecb..e45e831 100644
@@ -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);
 
Signature · 1 line
2.7.4
#34 lore raw

PATCH v4 23/25 Use cpu_create(type) instead of cpu_init(cpu_model)

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.

---
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 <[email protected]>
CC "Emilio G. Cota" <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Eduardo Habkost <[email protected]>
CC "Alex Bennée" <[email protected]>
CC "Philippe Mathieu-Daudé" <[email protected]>

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

---
 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(-)
include/hw/boards.h +0 -1
index efb0a9e..16b473a 100644
@@ -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;
include/qom/cpu.h +2 -14
index 93bd546..0185589 100644
@@ -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:
bsd-user/main.c +3 -1
index efef5ff..cbc683a 100644
@@ -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);
exec.c +23 -0
index 629a508..8aee230 100644
@@ -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)
 {
hw/core/null-machine.c +3 -3
index 864832d..cde4d3e 100644
@@ -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);
linux-user/main.c +6 -2
index a35477e..0afb3f4 100644
@@ -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);
 
qom/cpu.c +2 -46

61 lines not on this page · raw message

vl.c +3 -7
index e725ecb..e45e831 100644
@@ -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);
 
Signature · 1 line
2.7.4
Reviewed-by on v4 23/25
#35 lore raw

Re: [Qemu-devel] [PATCH v4 23/25] Use cpu_create(type) instead of cpu_init(cpu_model)

Quoted 41 lines · Igor Mammedov

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.

---
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 <[email protected]>
CC "Emilio G. Cota" <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Eduardo Habkost <[email protected]>
CC "Alex Bennée" <[email protected]>
CC "Philippe Mathieu-Daudé" <[email protected]>

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

Quoted 10 lines
---
 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. :)

[...]

Quoted 6 lines
qom/cpu.c +0 -1
@@ -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;

qom/cpu.c static ObjectClass *cpu_common_class_by_name(const char *cpu_model) · line 349

Quoted 10 lines
qom/cpu.c +0 -10
-    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:

Quoted 9 lines
qom/cpu.c +2 -4
-    }
-    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, '=');

[...]

Signature · 1 line
Eduardo
#36 lore raw

PATCH v3 24/25 cpu: get rid of unused cpu_init() defines

In reply to Igor Mammedov

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

---
CC: Richard Henderson <[email protected]> (maintainer:Alpha)
CC: Peter Maydell <[email protected]>
CC: "Edgar E. Iglesias" <[email protected]>
CC: Eduardo Habkost <[email protected]>
CC: Michael Walle <[email protected]>
CC: Laurent Vivier <[email protected]>
CC: Aurelien Jarno <[email protected]>
CC: Yongbok Kim <[email protected]>
CC: Anthony Green <[email protected]>
CC: Chris Wulff <[email protected]>
CC: Marek Vasut <[email protected]>
CC: Stafford Horne <[email protected]>
CC: David Gibson <[email protected]>
CC: Alexander Graf <[email protected]>
CC: Mark Cave-Ayland <[email protected]>
CC: Artyom Tarasenko <[email protected]>
CC: Bastian Koppelmann <[email protected]>
CC: Guan Xuetao <[email protected]>
CC: Max Filippov <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 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(-)
target/alpha/cpu.h +0 -2
index 21ed5d6..b3bec21 100644
@@ -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
target/arm/cpu.h +0 -2
index f9fb141..b37d266 100644
@@ -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
target/cris/cpu.h +0 -2
index 1a27653..db80cb1 100644
@@ -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
target/hppa/cpu.h +0 -1
index b92ae3f..628d7de 100644
@@ -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);
target/i386/cpu.h +0 -2
index 82c7381..1ed60b0 100644
@@ -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
target/lm32/cpu.h +0 -2
index 0656052..53939e5 100644
@@ -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
target/m68k/cpu.h +0 -2
index 8a4299a..7d64804 100644
@@ -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
target/microblaze/cpu.h +0 -1
index 492f9f7..a0ea421 100644
@@ -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
target/mips/cpu.h +0 -2
index 0fcbfb3..cfe1735 100644
@@ -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
target/moxie/cpu.h +0 -2
index 3f94a5a..5f8d10b 100644
@@ -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
target/nios2/cpu.h +0 -1
index 2234bff..8897e9a 100644
@@ -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
target/openrisc/cpu.h +0 -2
index 9b32ea4..6f843fa 100644
@@ -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
target/ppc/cpu.h +0 -2
index d5f2f3d..32c51fb 100644
@@ -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
target/s390x/cpu.h +0 -2
index b2121cb..b3bfcf5 100644
@@ -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
target/sh4/cpu.h +0 -2
index 709e0ca..c6418ef 100644
@@ -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
target/sparc/cpu.h +0 -4
index 345b39a..28f254d 100644
@@ -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
target/tilegx/cpu.h +0 -1
index a73215e..238f8d3 100644
@@ -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
target/tricore/cpu.h +0 -2
index a2ef632..13d629d 100644
@@ -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
target/unicore32/cpu.h +0 -2
index 9644b07..5ff8b98 100644
@@ -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
target/xtensa/cpu.h +0 -2
index 23dbd45..6481c3b 100644
@@ -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);
Signature · 1 line
2.7.4
Acked-by on v3 24/25
#37 lore raw

Re: [Qemu-arm] [PATCH v3 24/25] cpu: get rid of unused cpu_init() defines

Quoted 4 lines · Igor Mammedov

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

ppc parts

Quoted 304 lines

---
CC: Richard Henderson <[email protected]> (maintainer:Alpha)
CC: Peter Maydell <[email protected]>
CC: "Edgar E. Iglesias" <[email protected]>
CC: Eduardo Habkost <[email protected]>
CC: Michael Walle <[email protected]>
CC: Laurent Vivier <[email protected]>
CC: Aurelien Jarno <[email protected]>
CC: Yongbok Kim <[email protected]>
CC: Anthony Green <[email protected]>
CC: Chris Wulff <[email protected]>
CC: Marek Vasut <[email protected]>
CC: Stafford Horne <[email protected]>
CC: David Gibson <[email protected]>
CC: Alexander Graf <[email protected]>
CC: Mark Cave-Ayland <[email protected]>
CC: Artyom Tarasenko <[email protected]>
CC: Bastian Koppelmann <[email protected]>
CC: Guan Xuetao <[email protected]>
CC: Max Filippov <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 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(-)
target/alpha/cpu.h +0 -2
index 21ed5d6..b3bec21 100644
@@ -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
target/arm/cpu.h +0 -2
index f9fb141..b37d266 100644
@@ -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
target/cris/cpu.h +0 -2
index 1a27653..db80cb1 100644
@@ -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
target/hppa/cpu.h +0 -1
index b92ae3f..628d7de 100644
@@ -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);
target/i386/cpu.h +0 -2
index 82c7381..1ed60b0 100644
@@ -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
target/lm32/cpu.h +0 -2
index 0656052..53939e5 100644
@@ -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
target/m68k/cpu.h +0 -2
index 8a4299a..7d64804 100644
@@ -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
target/microblaze/cpu.h +0 -1
index 492f9f7..a0ea421 100644
@@ -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
target/mips/cpu.h +0 -2
index 0fcbfb3..cfe1735 100644
@@ -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
target/moxie/cpu.h +0 -2
index 3f94a5a..5f8d10b 100644
@@ -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
target/nios2/cpu.h +0 -1
index 2234bff..8897e9a 100644
@@ -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
target/openrisc/cpu.h +0 -2
index 9b32ea4..6f843fa 100644
@@ -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
target/ppc/cpu.h +0 -2
index d5f2f3d..32c51fb 100644
@@ -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
target/s390x/cpu.h +0 -2
index b2121cb..b3bfcf5 100644
@@ -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
target/sh4/cpu.h +0 -2
index 709e0ca..c6418ef 100644
@@ -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
target/sparc/cpu.h +0 -4
index 345b39a..28f254d 100644
@@ -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
target/tilegx/cpu.h +0 -1
index a73215e..238f8d3 100644
@@ -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
target/tricore/cpu.h +0 -2
index a2ef632..13d629d 100644
@@ -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
target/unicore32/cpu.h +0 -2
index 9644b07..5ff8b98 100644
@@ -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
target/xtensa/cpu.h +0 -2
index 23dbd45..6481c3b 100644
@@ -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);
Signature · 4 lines
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
#39 lore raw

PATCH v3 25/25 cpu: get rid of cpu_generic_init()

In reply to Igor Mammedov

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

---
CC: Richard Henderson <[email protected]>
CC: "Emilio G. Cota" <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: Eduardo Habkost <[email protected]>
CC: "Alex Bennée" <[email protected]>
CC: "Philippe Mathieu-Daudé" <[email protected]>

---
 qom/cpu.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
qom/cpu.c +2 -15
index aab8437..cf6880d 100644
@@ -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, '=');
Signature · 1 line
2.7.4
#40 lore raw

Re: [Qemu-devel] [PATCH v3 25/25] cpu: get rid of cpu_generic_init()

Quoted 1 line · On Tue, 23 Jan 2018 09:08:24 +0100 Igor Mammedov <[email protected]> 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.

Quoted 42 lines

---
CC: Richard Henderson <[email protected]>
CC: "Emilio G. Cota" <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: Eduardo Habkost <[email protected]>
CC: "Alex Bennée" <[email protected]>
CC: "Philippe Mathieu-Daudé" <[email protected]>

---
 qom/cpu.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
qom/cpu.c +2 -15
index aab8437..cf6880d 100644
@@ -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, '=');
#41 lore raw
In reply to Igor Mammedov

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!

Quoted 104 lines · Igor Mammedov

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

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
Signature · 1 line
2.7.4
Signature · 1 line
Eduardo
#42 lore raw
Quoted 1 line · On Tue, 6 Feb 2018 20:32:13 -0200 Eduardo Habkost <[email protected]> wrote:

I will try to summarize my comments here:

Thanks for review

Quoted 6 lines

* 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.

Quoted 2 lines

* 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.

Quoted 2 lines

* 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.

Quoted 111 lines

All the rest looks good to me.

Thanks!

Quoted 104 lines · Igor Mammedov

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

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
Signature · 1 line
2.7.4
#43 lore raw

On Wed, Feb 07, 2018 at 09:52:25AM +0100, Igor Mammedov wrote:
[...]

Quoted 18 lines
Quoted 2 lines

* 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:

(quoted diff) +3 -3
@@ -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.

Quoted 4 lines

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.

Signature · 1 line
Eduardo