All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
@ 2018-01-17 15:43 Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
                   ` (24 more replies)
  0 siblings, 25 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

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

It introduces TARGET_DEFAULT_CPU_TYPE which must be defined
by each target and is used setting default cpu type for
linux/bsd-user targets and as anchor point to pick cpu class
that provides target specific FOO_cpu_class_by_name()
callback for cpu_parse_cpu_model() in null-machine.c
which is compiled for all targets that have system
mode emulation.

After TARGET_DEFAULT_CPU_TYPE is provided by each target,
patches 20-21/24 switch null-machine.c and *-user.main.c
to use TARGET_DEFAULT_CPU_TYPE and using
   cpu_parse_cpu_model()/cpu_create()
instead of
   cpu_init()/cpu_generic_init()
so nor more users of later remains and boards/targets deal
only with cpu types (in similar/consistent manner).

Finishing patches 22-24/24 remove not used anymore
  cpu_init()/cpu_generic_init()
API so cpu_model won't be introduced back in boards code
in the future (23/24 removes cpu_generic_init user that
managed to slip in this merge window). 

CC: Laurent Vivier <laurent@vivier.eu>

Igor Mammedov (24):
  arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  alpha: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  cris: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  lm32: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  m68k: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  microblaze: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  mips: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  moxie: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  nios2: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  openrisc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  ppc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  s390x: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  sh4: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  sparc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  tricore: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  unicore32: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE
  hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  tilegx: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  machine: drop MachineState::cpu_model
  linux/bsd-user: drop cpu_init() and use cpu_create() instead
  cpu: get rid of unused cpu_init() defines
  nios2: 10m50_devboard: replace cpu_model with cpu_type
  cpu: get rid of cpu_generic_init()

 include/hw/boards.h       |  1 -
 include/qom/cpu.h         | 11 ----------
 target/alpha/cpu.h        |  3 +--
 target/arm/cpu.h          |  3 +--
 target/cris/cpu.h         |  3 +--
 target/hppa/cpu.h         |  2 +-
 target/i386/cpu.h         |  2 --
 target/lm32/cpu.h         |  3 +--
 target/m68k/cpu.h         |  3 +--
 target/microblaze/cpu.h   |  2 +-
 target/mips/cpu.h         |  8 ++++++--
 target/moxie/cpu.h        |  3 +--
 target/nios2/cpu.h        |  2 +-
 target/openrisc/cpu.h     |  3 +--
 target/ppc/cpu.h          |  8 ++++++--
 target/s390x/cpu.h        |  3 +--
 target/sh4/cpu.h          |  3 +--
 target/sparc/cpu.h        | 10 +++++----
 target/tilegx/cpu.h       |  2 +-
 target/tricore/cpu.h      |  3 +--
 target/unicore32/cpu.h    |  3 +--
 target/xtensa/cpu.h       |  4 +---
 bsd-user/main.c           | 26 ++++--------------------
 hw/core/null-machine.c    | 10 ++++++---
 hw/nios2/10m50_devboard.c |  2 +-
 hw/xtensa/sim.c           |  2 +-
 hw/xtensa/xtfpga.c        |  8 ++++----
 linux-user/main.c         | 52 +++++------------------------------------------
 qom/cpu.c                 | 25 ++---------------------
 vl.c                      |  8 +++++++-
 30 files changed, 65 insertions(+), 153 deletions(-)

-- 
2.7.4

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

* [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 02/24] alpha: " Igor Mammedov
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Riku Voipio, Peter Maydell, Andrew Jones, qemu-arm

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to replace a bunch of ifdefs *-user/main.c that
set default cpu_model with cpu type.

With the later in mind set it to 'any', which is current
default for ARM targets.

While at it, default cpu_model for ARM is set to 'any' under
TARGET_ARM, however there is catch all ifdef which also sets
cpu_model to 'any'. Drop unnecessary TARGET_ARM ifdef and use
catch all #else to set default value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: Andrew Jones <drjones@redhat.com>
CC: qemu-arm@nongnu.org
---
 target/arm/cpu.h  | 1 +
 linux-user/main.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 9631670..c87bb76 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2171,6 +2171,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
+#define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
 
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
diff --git a/linux-user/main.c b/linux-user/main.c
index 450eb3c..a35477e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
 #else
         cpu_model = "qemu32";
 #endif
-#elif defined(TARGET_ARM)
-        cpu_model = "any";
 #elif defined(TARGET_UNICORE32)
         cpu_model = "any";
 #elif defined(TARGET_M68K)
-- 
2.7.4

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

* [Qemu-devel] [PATCH 02/24] alpha: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 03/24] cris: " Igor Mammedov
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Richard Henderson

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

With the later in mind set it to 'ev67', which is
what alpha_cpu_class_by_name() returns if user provided
a garbage (including default "any" cpu_model that *-user
targets set in catch all) in case of Alpha.

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

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 0a9ad35..c8dd560 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -472,6 +472,7 @@ void alpha_translate_init(void);
 
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE ALPHA_CPU_TYPE_NAME("ev67")
 
 void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
-- 
2.7.4

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

* [Qemu-devel] [PATCH 03/24] cris: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 02/24] alpha: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 04/24] lm32: " Igor Mammedov
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Edgar E. Iglesias

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

With the later in mind set it to 'crisv32', which is
what cris_cpu_class_by_name() returns if user provided
"any" cpu_model including default that *-user targets
set in catch all in case of Cris.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
---
 target/cris/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index b64fa35..8feabb4 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -271,6 +271,7 @@ enum {
 
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
+#define TARGET_DEFAULT_CPU_TYPE CRIS_CPU_TYPE_NAME("crisv32")
 
 #define cpu_signal_handler cpu_cris_signal_handler
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 04/24] lm32: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (2 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 03/24] cris: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 05/24] m68k: " Igor Mammedov
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Michael Walle

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model).
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

LM32 however doesn't have working default in *-user targets
which defaults to catch all 'any'. So I arbitraraly picked
'lm32-basic' cpu model to serve as the default.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Michael Walle <michael@walle.cc>
---
 target/lm32/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index 2279594..65f58f5 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -259,6 +259,7 @@ bool lm32_cpu_do_semihosting(CPUState *cs);
 
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE LM32_CPU_TYPE_NAME("lm32-basic")
 
 #define cpu_list lm32_cpu_list
 #define cpu_signal_handler cpu_lm32_signal_handler
-- 
2.7.4

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

* [Qemu-devel] [PATCH 05/24] m68k: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (3 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 04/24] lm32: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 06/24] microblaze: " Igor Mammedov
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Riku Voipio

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

With the later in mind set it to 'any', which is current
default for M68K targets.

While at it, drop redundant ifdef in linux-user, as catch
all #else sets default to the same 'any' model.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/cpu.h | 1 +
 linux-user/main.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 2985b03..193e8f8 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -405,6 +405,7 @@ void register_m68k_insns (CPUM68KState *env);
 
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE M68K_CPU_TYPE_NAME("any")
 
 #define cpu_signal_handler cpu_m68k_signal_handler
 #define cpu_list m68k_cpu_list
diff --git a/linux-user/main.c b/linux-user/main.c
index a35477e..54e8aac 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4327,8 +4327,6 @@ int main(int argc, char **argv, char **envp)
 #endif
 #elif defined(TARGET_UNICORE32)
         cpu_model = "any";
-#elif defined(TARGET_M68K)
-        cpu_model = "any";
 #elif defined(TARGET_SPARC)
 #ifdef TARGET_SPARC64
         cpu_model = "TI UltraSparc II";
-- 
2.7.4

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

* [Qemu-devel] [PATCH 06/24] microblaze: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (4 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 05/24] m68k: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 07/24] mips: " Igor Mammedov
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Edgar E. Iglesias

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

For the later default is set to bogus 'any', and mb_cpu_class_by_name()
always returns TYPE_MICROBLAZE_CPU class regardless of cpu_model
value. So use this type for default.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
---
 target/microblaze/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index 52b6b6a..f244efa 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -344,6 +344,7 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
+#define TARGET_DEFAULT_CPU_TYPE TYPE_MICROBLAZE_CPU
 
 #define cpu_signal_handler cpu_mb_signal_handler
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 07/24] mips: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (5 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 06/24] microblaze: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 08/24] moxie: " Igor Mammedov
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Aurelien Jarno, Yongbok Kim

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Take defaults types from linux-user and use them as
TARGET_DEFAULT_CPU_TYPE, which should work for *-user targets.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Yongbok Kim <yongbok.kim@mips.com>
---
 target/mips/cpu.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 7f8ba5f..c5ee894 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -744,6 +744,12 @@ 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
 
+#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
+#define TARGET_DEFAULT_CPU_TYPE MIPS_CPU_TYPE_NAME("5KEf")
+#else
+#define TARGET_DEFAULT_CPU_TYPE MIPS_CPU_TYPE_NAME("24Kf")
+#endif
+
 bool cpu_supports_cps_smp(const char *cpu_type);
 bool cpu_supports_isa(const char *cpu_type, unsigned int isa);
 void cpu_set_exception_base(int vp_index, target_ulong address);
-- 
2.7.4

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

* [Qemu-devel] [PATCH 08/24] moxie: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (6 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 07/24] mips: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 09/24] nios2: " Igor Mammedov
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Anthony Green

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

With the later in mind set it to 'any', which is current
default for target.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Anthony Green <green@moxielogic.com>
---
 target/moxie/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index d37e6a5..9fabb93 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -124,6 +124,7 @@ int cpu_moxie_signal_handler(int host_signum, void *pinfo,
 
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE MOXIE_CPU_TYPE_NAME("any")
 
 #define cpu_signal_handler cpu_moxie_signal_handler
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 09/24] nios2: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (7 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 08/24] moxie: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 10/24] openrisc: " Igor Mammedov
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Chris Wulff, Marek Vasut

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

For the later default is set to bogus 'any', and
nios2_cpu_class_by_name() always returns TYPE_NIOS2_CPU class
regardless of cpu_model value. So use this type for default.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
---
 target/nios2/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 88823a6..2d03958 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -232,6 +232,7 @@ void nios2_check_interrupts(CPUNios2State *env);
 #endif
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
+#define TARGET_DEFAULT_CPU_TYPE TYPE_NIOS2_CPU
 
 #define cpu_gen_code cpu_nios2_gen_code
 #define cpu_signal_handler cpu_nios2_signal_handler
-- 
2.7.4

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

* [Qemu-devel] [PATCH 10/24] openrisc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (8 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 09/24] nios2: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Stafford Horne

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Take default type from linux-user and use it as
TARGET_DEFAULT_CPU_TYPE, which should work for *-user targets.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Stafford Horne <shorne@gmail.com>
---
 target/openrisc/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index cc22dc8..8d1a87e 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -394,6 +394,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
 
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE OPENRISC_CPU_TYPE_NAME("or1200")
 
 #include "exec/cpu-all.h"
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 11/24] ppc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (9 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 10/24] openrisc: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-18  0:30   ` David Gibson
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
                   ` (13 subsequent siblings)
  24 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Riku Voipio, David Gibson, Alexander Graf, qemu-ppc

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Use default values from linux-user for TARGET_DEFAULT_CPU_TYPE.
While at it fixup linux-user to use corresponding cpu models
instead of aliases.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Alexander Graf <agraf@suse.de>
CC: qemu-ppc@nongnu.org
---
 target/ppc/cpu.h  | 6 ++++++
 linux-user/main.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index a5e49f2..4af4aff 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1377,6 +1377,12 @@ 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
 
+#ifdef TARGET_PPC64
+#define TARGET_DEFAULT_CPU_TYPE POWERPC_CPU_TYPE_NAME("power8_v2.0")
+#else
+#define TARGET_DEFAULT_CPU_TYPE POWERPC_CPU_TYPE_NAME("750_v3.1")
+#endif
+
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list
 
diff --git a/linux-user/main.c b/linux-user/main.c
index 54e8aac..279cd97 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4343,9 +4343,9 @@ int main(int argc, char **argv, char **envp)
         cpu_model = "or1200";
 #elif defined(TARGET_PPC)
 # ifdef TARGET_PPC64
-        cpu_model = "POWER8";
+        cpu_model = "power8_v2.0";
 # else
-        cpu_model = "750";
+        cpu_model = "750_v3.1";
 # endif
 #elif defined TARGET_SH4
         cpu_model = "sh7785";
-- 
2.7.4

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

* [Qemu-devel] [PATCH 12/24] s390x: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (10 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 16:04   ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 13/24] sh4: " Igor Mammedov
                   ` (12 subsequent siblings)
  24 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Richard Henderson, Alexander Graf, qemu-s390x

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Use default value from linux-user for TARGET_DEFAULT_CPU_TYPE.

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

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 1a8b6b9..174624a 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -731,6 +731,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
+#define TARGET_DEFAULT_CPU_TYPE S390_CPU_TYPE_NAME("qemu")
 
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
-- 
2.7.4

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

* [Qemu-devel] [PATCH 13/24] sh4: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (11 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 14/24] sparc: " Igor Mammedov
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Aurelien Jarno

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Use default value from linux-user for TARGET_DEFAULT_CPU_TYPE.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Aurelien Jarno <aurelien@aurel32.net>
---
 target/sh4/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index a2c26e0..203d212 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -278,6 +278,7 @@ void cpu_load_tlb(CPUSH4State * env);
 
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE SUPERH_CPU_TYPE_NAME("sh7785")
 
 #define cpu_signal_handler cpu_sh4_signal_handler
 #define cpu_list sh4_cpu_list
-- 
2.7.4

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

* [Qemu-devel] [PATCH 14/24] sparc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (12 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 13/24] sh4: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Mark Cave-Ayland, Artyom Tarasenko

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Use default values from linux-user for TARGET_DEFAULT_CPU_TYPE.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
---
 target/sparc/cpu.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 9fde547..02c55ad 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -661,6 +661,12 @@ 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
 
+#ifdef TARGET_SPARC64
+#define TARGET_DEFAULT_CPU_TYPE SPARC_CPU_TYPE_NAME("TI-UltraSparc-II")
+#else
+#define TARGET_DEFAULT_CPU_TYPE SPARC_CPU_TYPE_NAME("Fujitsu-MB86904")
+#endif
+
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 15/24] tricore: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (13 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 14/24] sparc: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 16:34   ` Bastian Koppelmann
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 16/24] unicore32: " Igor Mammedov
                   ` (9 subsequent siblings)
  24 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Bastian Koppelmann

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

linux-user defaults to catch all 'any' which is bogus
and results into error. Pick arbitrary model "tc1796"
for TARGET_DEFAULT_CPU_TYPE to use and it would fix
missing default when *-user is switched to using types
instead of cpu_model.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 target/tricore/cpu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index f41d2ce..835d51a 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -415,6 +415,7 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
 
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE TRICORE_CPU_TYPE_NAME("tc1796")
 
 /* helpers.c */
 int cpu_tricore_handle_mmu_fault(CPUState *cpu, target_ulong address,
-- 
2.7.4

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

* [Qemu-devel] [PATCH 16/24] unicore32: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (14 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Riku Voipio, Guan Xuetao

it will be used for for 2 purposes, 1st is to
provide to cpu name resolving class for machine 'none'
  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
and later to drop a bunch of ifdefs *-user/main.c that
set default cpu_model.

Use default value from linux-user for TARGET_DEFAULT_CPU_TYPE.
While at it drop redundant ifdef and let catch all #else set
default to the same 'any' model.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 target/unicore32/cpu.h | 1 +
 linux-user/main.c      | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 3dc6fbc..fd3fa81 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -169,6 +169,7 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
 
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
+#define TARGET_DEFAULT_CPU_TYPE UNICORE32_CPU_TYPE_NAME("any")
 
 static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc,
                                         target_ulong *cs_base, uint32_t *flags)
diff --git a/linux-user/main.c b/linux-user/main.c
index 279cd97..1cd5033 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4325,8 +4325,6 @@ int main(int argc, char **argv, char **envp)
 #else
         cpu_model = "qemu32";
 #endif
-#elif defined(TARGET_UNICORE32)
-        cpu_model = "any";
 #elif defined(TARGET_SPARC)
 #ifdef TARGET_SPARC64
         cpu_model = "TI UltraSparc II";
-- 
2.7.4

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

* [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (15 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 16/24] unicore32: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 17:35   ` Max Filippov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Max Filippov

so naming would be in line with other targets and null-machine.c which
uses the later would compile.

Later it also would be used as default for *-user targets which is
currently bogus cpu model 'any', that errors out.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Max Filippov <jcmvbkbc@gmail.com>
---
 target/xtensa/cpu.h | 2 +-
 hw/xtensa/sim.c     | 2 +-
 hw/xtensa/xtfpga.c  | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index d9404aa..537e151 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -506,7 +506,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 #else
 #define XTENSA_DEFAULT_CPU_MODEL "dc232b"
 #endif
-#define XTENSA_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
+#define TARGET_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
 
 #define cpu_init(cpu_model) cpu_generic_init(TYPE_XTENSA_CPU, cpu_model)
 
diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index 2bb883b..58a79bd 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -128,7 +128,7 @@ static void xtensa_sim_machine_init(MachineClass *mc)
     mc->init = xtensa_sim_init;
     mc->max_cpus = 4;
     mc->no_serial = 1;
-    mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 DEFINE_MACHINE("sim", xtensa_sim_machine_init)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 1971ecf..c2b0aa4 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -449,7 +449,7 @@ static void xtensa_lx60_class_init(ObjectClass *oc, void *data)
     mc->desc = "lx60 EVB (" XTENSA_DEFAULT_CPU_MODEL ")";
     mc->init = xtensa_lx60_init;
     mc->max_cpus = 4;
-    mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 static const TypeInfo xtensa_lx60_type = {
@@ -465,7 +465,7 @@ static void xtensa_lx200_class_init(ObjectClass *oc, void *data)
     mc->desc = "lx200 EVB (" XTENSA_DEFAULT_CPU_MODEL ")";
     mc->init = xtensa_lx200_init;
     mc->max_cpus = 4;
-    mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 static const TypeInfo xtensa_lx200_type = {
@@ -481,7 +481,7 @@ static void xtensa_ml605_class_init(ObjectClass *oc, void *data)
     mc->desc = "ml605 EVB (" XTENSA_DEFAULT_CPU_MODEL ")";
     mc->init = xtensa_ml605_init;
     mc->max_cpus = 4;
-    mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 static const TypeInfo xtensa_ml605_type = {
@@ -497,7 +497,7 @@ static void xtensa_kc705_class_init(ObjectClass *oc, void *data)
     mc->desc = "kc705 EVB (" XTENSA_DEFAULT_CPU_MODEL ")";
     mc->init = xtensa_kc705_init;
     mc->max_cpus = 4;
-    mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 static const TypeInfo xtensa_kc705_type = {
-- 
2.7.4

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

* [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (16 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 19/24] tilegx: " Igor Mammedov
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Richard Henderson

It will be used to drop a bunch of ifdefs *-user/main.c that
set default cpu_model in favor of using type names directly.

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

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

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

* [Qemu-devel] [PATCH 19/24] tilegx: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (17 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Eduardo Habkost

It will be used to drop a bunch of ifdefs *-user/main.c that
set default cpu_model in favor of using type names directly.

For tilegx, *-user defaulted to bogus 'any', however
tilegx_cpu_class_by_name() is ignoring invalid values and always
returns TYPE_TILEGX_CPU, so use it for TARGET_DEFAULT_CPU_TYPE

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

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

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

* [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (18 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 19/24] tilegx: " Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-18  1:48   ` Eduardo Habkost
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead Igor Mammedov
                   ` (4 subsequent siblings)
  24 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Eduardo Habkost, Marcel Apfelbaum, Paolo Bonzini

The last user of it was machine type 'none', which used field
to create CPU id user requested it on CLI with -cpu option.

We could compare pointers of MachineState::cpu_type and
MachineClass::default_cpu_type to check for the same condition,
and drop cpu_model concept completly from machine/boards code
So that no one would try to reuse obsolete field and only
place to deal with cpu model would be vl.c and
foo_cpu_class_by_name() callbacks.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Marcel Apfelbaum <marcel@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
---
 include/hw/boards.h    |  1 -
 hw/core/null-machine.c | 10 +++++++---
 vl.c                   |  8 +++++++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 156b16f..decd0ec 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -246,7 +246,6 @@ struct MachineState {
     char *kernel_filename;
     char *kernel_cmdline;
     char *initrd_filename;
-    const char *cpu_model;
     const char *cpu_type;
     AccelState *accelerator;
     CPUArchIdList *possible_cpus;
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index 864832d..c2e466c 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -23,10 +23,13 @@
 static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
+    MachineClass *mc = MACHINE_GET_CLASS(mch);
 
-    /* Initialize CPU (if a model has been specified) */
-    if (mch->cpu_model) {
-        cpu = cpu_init(mch->cpu_model);
+    /* Initialize CPU if cpu_type pointer is user provided
+     * (i.e. != to pointer tot static default cpu type string)
+     */
+    if (mch->cpu_type != mc->default_cpu_type) {
+        cpu = cpu_create(mch->cpu_type);
         if (!cpu) {
             error_report("Unable to initialize CPU");
             exit(1);
@@ -54,6 +57,7 @@ static void machine_none_machine_init(MachineClass *mc)
     mc->init = machine_none_init;
     mc->max_cpus = 1;
     mc->default_ram_size = 0;
+    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
 }
 
 DEFINE_MACHINE("none", machine_none_machine_init)
diff --git a/vl.c b/vl.c
index 2586f25..8aa0131 100644
--- a/vl.c
+++ b/vl.c
@@ -4609,7 +4609,6 @@ 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_numa_opts(current_machine);
 
@@ -4619,6 +4618,13 @@ int main(int argc, char **argv, char **envp)
         if (cpu_model) {
             current_machine->cpu_type =
                 cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
+
+            /* machine 'none' depends on default cpu type pointer not being
+             * equal to resolved type name pointer to fugure out if type was
+             * user provided, make sure that if it becomes not true in future
+             * it won't beark silently */
+            g_assert(
+                current_machine->cpu_type != machine_class->default_cpu_type);
         }
     }
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (19 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 22/24] cpu: get rid of unused cpu_init() defines Igor Mammedov
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Riku Voipio

*-user were the last users of cpu_init() macro, which were
used to create a cpu instance using cpu_model name.

Now since all targets provide TARGET_DEFAULT_CPU_TYPE,
cpu_init() can be replaced with one call:
   cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model)
when '-cpu' CLI option is parsed and
   cpu = create_cpu(cpu_type)
whenever a cpu instance needs to be created.

Also drop ifdef-ed definitions of default cpu_model and use
target provided TARGET_DEFAULT_CPU_TYPE for it, this way
linux/bsd-user targets will become consistent in handling
defaults and won't go out off sync as it happened current
code.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
---
 bsd-user/main.c   | 26 ++++----------------------
 linux-user/main.c | 46 +++++-----------------------------------------
 2 files changed, 9 insertions(+), 63 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index efef5ff..d52ff22 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -722,7 +722,7 @@ void init_task_state(TaskState *ts)
 int main(int argc, char **argv)
 {
     const char *filename;
-    const char *cpu_model;
+    const char *cpu_type = TARGET_DEFAULT_CPU_TYPE;
     const char *log_file = NULL;
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
@@ -752,8 +752,6 @@ int main(int argc, char **argv)
         (void) envlist_setenv(envlist, *wrk);
     }
 
-    cpu_model = NULL;
-
     qemu_add_opts(&qemu_trace_opts);
 
     optind = 1;
@@ -811,7 +809,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "r")) {
             qemu_uname_release = argv[optind++];
         } else if (!strcmp(r, "cpu")) {
-            cpu_model = argv[optind++];
+            const char *cpu_model = argv[optind++];
             if (is_help_option(cpu_model)) {
 /* XXX: implement xxx_cpu_list for targets that still miss it */
 #if defined(cpu_list)
@@ -819,6 +817,7 @@ int main(int argc, char **argv)
 #endif
                 exit(1);
             }
+            cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model);
         } else if (!strcmp(r, "B")) {
            guest_base = strtol(argv[optind++], NULL, 0);
            have_guest_base = 1;
@@ -880,27 +879,10 @@ int main(int argc, char **argv)
     /* Scan interp_prefix dir for replacement files. */
     init_paths(interp_prefix);
 
-    if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#else
-        cpu_model = "any";
-#endif
-    }
     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;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
     cpu_reset(cpu);
diff --git a/linux-user/main.c b/linux-user/main.c
index 1cd5033..4624cc9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -43,7 +43,7 @@ static const char *filename;
 static const char *argv0;
 static int gdbstub_port;
 static envlist_t *envlist;
-static const char *cpu_model;
+static const char *cpu_type = TARGET_DEFAULT_CPU_TYPE;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
 int have_guest_base;
@@ -3847,7 +3847,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;
@@ -3982,7 +3982,7 @@ static void handle_arg_uname(const char *arg)
 
 static void handle_arg_cpu(const char *arg)
 {
-    cpu_model = strdup(arg);
+    const char *cpu_model = strdup(arg);
     if (cpu_model == NULL || is_help_option(cpu_model)) {
         /* XXX: implement xxx_cpu_list for targets that still miss it */
 #if defined(cpu_list)
@@ -3990,6 +3990,7 @@ static void handle_arg_cpu(const char *arg)
 #endif
         exit(EXIT_FAILURE);
     }
+    cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model);
 }
 
 static void handle_arg_guest_base(const char *arg)
@@ -4292,8 +4293,6 @@ int main(int argc, char **argv, char **envp)
         }
     }
 
-    cpu_model = NULL;
-
     srand(time(NULL));
 
     qemu_add_opts(&qemu_trace_opts);
@@ -4318,45 +4317,10 @@ int main(int argc, char **argv, char **envp)
 
     init_qemu_uname_release();
 
-    if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#elif defined(TARGET_MIPS)
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
-        cpu_model = "5KEf";
-#else
-        cpu_model = "24Kf";
-#endif
-#elif defined TARGET_OPENRISC
-        cpu_model = "or1200";
-#elif defined(TARGET_PPC)
-# ifdef TARGET_PPC64
-        cpu_model = "power8_v2.0";
-# else
-        cpu_model = "750_v3.1";
-# endif
-#elif defined TARGET_SH4
-        cpu_model = "sh7785";
-#elif defined TARGET_S390X
-        cpu_model = "qemu";
-#else
-        cpu_model = "any";
-#endif
-    }
     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);
 
-- 
2.7.4

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

* [Qemu-devel] [PATCH 22/24] cpu: get rid of unused cpu_init() defines
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (20 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-18  0:28   ` David Gibson
  2018-01-18  1:50   ` Eduardo Habkost
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
                   ` (2 subsequent siblings)
  24 siblings, 2 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Richard Henderson, Peter Maydell,
	Edgar E. Iglesias, Eduardo Habkost, Michael Walle,
	Aurelien Jarno, Yongbok Kim, Anthony Green, Chris Wulff,
	Marek Vasut, Stafford Horne, David Gibson, Alexander Graf,
	Mark Cave-Ayland, Artyom Tarasenko, Bastian Koppelmann,
	Guan Xuetao, Max Filippov, qemu-arm, qemu-ppc, qemu-s390x

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

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

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index c8dd560..1a1d9a0 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -468,8 +468,6 @@ enum {
 
 void alpha_translate_init(void);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_ALPHA_CPU, cpu_model)
-
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE ALPHA_CPU_TYPE_NAME("ev67")
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index c87bb76..3c1e1aa 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2167,8 +2167,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
     return unmasked || pstate_unmasked;
 }
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_ARM_CPU, cpu_model)
-
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
 #define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index 8feabb4..9845d89 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -267,8 +267,6 @@ enum {
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_CRIS_CPU, cpu_model)
-
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
 #define TARGET_DEFAULT_CPU_TYPE CRIS_CPU_TYPE_NAME("crisv32")
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 04625f7..7a6074e 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -112,7 +112,6 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
 
 void hppa_translate_init(void);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_HPPA_CPU, cpu_model)
 #define TARGET_DEFAULT_CPU_TYPE TYPE_HPPA_CPU
 
 void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index f64e5ed..0b4563b 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1557,8 +1557,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)
 
diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index 65f58f5..ec9efa7 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -255,8 +255,6 @@ void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,
 void lm32_watchpoint_remove(CPULM32State *env, int index);
 bool lm32_cpu_do_semihosting(CPUState *cs);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_LM32_CPU, cpu_model)
-
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE LM32_CPU_TYPE_NAME("lm32-basic")
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 193e8f8..da4171c 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -401,8 +401,6 @@ void register_m68k_insns (CPUM68KState *env);
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
-
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE M68K_CPU_TYPE_NAME("any")
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index f244efa..3ad1016 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -343,7 +343,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
 #define TARGET_DEFAULT_CPU_TYPE TYPE_MICROBLAZE_CPU
 
 #define cpu_signal_handler cpu_mb_signal_handler
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index c5ee894..7c66ec0 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -739,8 +739,6 @@ enum {
 
 int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model)
-
 #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
 #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
 
diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index 9fabb93..a3a1bba 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -120,8 +120,6 @@ void moxie_translate_init(void);
 int cpu_moxie_signal_handler(int host_signum, void *pinfo,
                              void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_MOXIE_CPU, cpu_model)
-
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE MOXIE_CPU_TYPE_NAME("any")
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 2d03958..71a48b1 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -231,7 +231,6 @@ void nios2_check_interrupts(CPUNios2State *env);
 # define TARGET_VIRT_ADDR_SPACE_BITS 32
 #endif
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
 #define TARGET_DEFAULT_CPU_TYPE TYPE_NIOS2_CPU
 
 #define cpu_gen_code cpu_nios2_gen_code
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index 8d1a87e..f2d2abb 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -390,8 +390,6 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
                                int *prot, target_ulong address, int rw);
 #endif
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model)
-
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE OPENRISC_CPU_TYPE_NAME("or1200")
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 4af4aff..3dc0359 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1372,8 +1372,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
 
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 174624a..3e647df 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -727,8 +727,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 
 
 /* helper.c */
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_model)
-
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
 #define TARGET_DEFAULT_CPU_TYPE S390_CPU_TYPE_NAME("qemu")
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index 203d212..ad58e24 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -274,8 +274,6 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr);
 
 void cpu_load_tlb(CPUSH4State * env);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_SUPERH_CPU, cpu_model)
-
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE SUPERH_CPU_TYPE_NAME("sh7785")
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 02c55ad..54b3dc7 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -654,10 +654,6 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
 #endif
 int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#ifndef NO_CPU_IO_DEFS
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_SPARC_CPU, cpu_model)
-#endif
-
 #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
 #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
 
diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h
index 67de53e..6c89b05 100644
--- a/target/tilegx/cpu.h
+++ b/target/tilegx/cpu.h
@@ -164,7 +164,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env)
 void tilegx_tcg_init(void);
 int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
 #define TARGET_DEFAULT_CPU_TYPE TYPE_TILEGX_CPU
 
 #define cpu_signal_handler cpu_tilegx_signal_handler
diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index 835d51a..8ed17e0 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -411,8 +411,6 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
     *flags = 0;
 }
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_TRICORE_CPU, cpu_model)
-
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE TRICORE_CPU_TYPE_NAME("tc1796")
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index fd3fa81..91b673a 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -165,8 +165,6 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
 
 #include "exec/cpu-all.h"
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model)
-
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
 #define TARGET_DEFAULT_CPU_TYPE UNICORE32_CPU_TYPE_NAME("any")
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 537e151..c21acf9 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -508,8 +508,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 #endif
 #define TARGET_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
 
-#define cpu_init(cpu_model) cpu_generic_init(TYPE_XTENSA_CPU, cpu_model)
-
 void xtensa_translate_init(void);
 void xtensa_breakpoint_handler(CPUState *cs);
 void xtensa_finalize_config(XtensaConfig *config);
-- 
2.7.4

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

* [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (21 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 22/24] cpu: get rid of unused cpu_init() defines Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init() Igor Mammedov
  2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Chris Wulff, Marek Vasut

use cpu_create() instead of being removed cpu_generic_init()

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

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

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

* [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init()
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (22 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
@ 2018-01-17 15:43 ` Igor Mammedov
  2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
  24 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 15:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Richard Henderson, Emilio G. Cota, Paolo Bonzini,
	Eduardo Habkost, Alex Bennée, Philippe Mathieu-Daudé

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

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

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 93bd546..5446040 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -673,17 +673,6 @@ CPUState *cpu_create(const char *typename);
 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);
-
-/**
  * cpu_has_work:
  * @cpu: The vCPU to check.
  *
diff --git a/qom/cpu.c b/qom/cpu.c
index e42d9a7..7ab7c36 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -90,14 +90,6 @@ const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
     return cpu_type;
 }
 
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
-{
-    /* TODO: all callers of cpu_generic_init() need to be converted to
-     * call cpu_parse_features() only once, before calling cpu_generic_init().
-     */
-    return cpu_create(cpu_parse_cpu_model(typename, cpu_model));
-}
-
 bool cpu_paging_enabled(const CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -335,22 +327,9 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
 static void cpu_common_parse_features(const char *typename, char *features,
                                       Error **errp)
 {
-    char *featurestr; /* Single "key=value" string being parsed */
     char *val;
-    static bool cpu_globals_initialized;
-
-    /* TODO: all callers of ->parse_features() need to be changed to
-     * call it only once, so we can remove this check (or change it
-     * to assert(!cpu_globals_initialized).
-     * Current callers of ->parse_features() are:
-     * - cpu_generic_init()
-     */
-    if (cpu_globals_initialized) {
-        return;
-    }
-    cpu_globals_initialized = true;
-
-    featurestr = features ? strtok(features, ",") : NULL;
+    /* Single "key=value" string being parsed */
+    char *featurestr = features ? strtok(features, ",") : NULL;
 
     while (featurestr) {
         val = strchr(featurestr, '=');
-- 
2.7.4

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH 12/24] s390x: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
@ 2018-01-17 16:04   ` David Hildenbrand
  2018-01-17 19:20     ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: David Hildenbrand @ 2018-01-17 16:04 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel
  Cc: Alexander Graf, qemu-s390x, Laurent Vivier, Richard Henderson

On 17.01.2018 16:43, Igor Mammedov wrote:
> it will be used for for 2 purposes, 1st is to
> provide to cpu name resolving class for machine 'none'
>   cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
> and later to drop a bunch of ifdefs *-user/main.c that
> set default cpu_model.
> 
> Use default value from linux-user for TARGET_DEFAULT_CPU_TYPE.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Richard Henderson <rth@twiddle.net>
> CC: Alexander Graf <agraf@suse.de>
> CC: qemu-s390x@nongnu.org
> ---
>  target/s390x/cpu.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 1a8b6b9..174624a 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -731,6 +731,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
>  
>  #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
>  #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
> +#define TARGET_DEFAULT_CPU_TYPE S390_CPU_TYPE_NAME("qemu")
>  
>  /* you can call this signal handler from your SIGBUS and SIGSEGV
>     signal handlers to inform the virtual CPU of exceptions. non zero
> 

At least from a !KVM perspective this is correct. And that is at least
relevant for linux-user. I doubt that this is relevant for KVM. The
"none" machine cannot be used either way and CPU models are sensed via qmp.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
                   ` (23 preceding siblings ...)
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init() Igor Mammedov
@ 2018-01-17 16:12 ` Peter Maydell
  2018-01-17 19:15   ` Igor Mammedov
  24 siblings, 1 reply; 53+ messages in thread
From: Peter Maydell @ 2018-01-17 16:12 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 17 January 2018 at 15:43, Igor Mammedov <imammedo@redhat.com> wrote:
> Series is finishing work on generalizing cpu_model parsing
> and limiting parts that deal with inconsistent cpu_model
> naming to "-cpu" CLI option processing in vl.c/*-user.main.c
> and FOO_cpu_class_by_name() callbacks.
>
> It introduces TARGET_DEFAULT_CPU_TYPE which must be defined
> by each target and is used setting default cpu type for
> linux/bsd-user targets and as anchor point to pick cpu class
> that provides target specific FOO_cpu_class_by_name()
> callback for cpu_parse_cpu_model() in null-machine.c
> which is compiled for all targets that have system
> mode emulation.

I like moving this from being an ifdef ladder into per-cpu
code, but I don't think the definition belongs in target/$ARCH.
It's part of the choice usermode makes about how to handle
binaries it's loading, so it should go in linux-user/$ARCH/target_cpu.h.
target/$ARCH should really be for things that are properties
of the architecture.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 15/24] tricore: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
@ 2018-01-17 16:34   ` Bastian Koppelmann
  0 siblings, 0 replies; 53+ messages in thread
From: Bastian Koppelmann @ 2018-01-17 16:34 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Laurent Vivier

On 01/17/2018 04:43 PM, Igor Mammedov wrote:
> it will be used for for 2 purposes, 1st is to
> provide to cpu name resolving class for machine 'none'
>   cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
> and later to drop a bunch of ifdefs *-user/main.c that
> set default cpu_model.
> 
> linux-user defaults to catch all 'any' which is bogus
> and results into error. Pick arbitrary model "tc1796"
> for TARGET_DEFAULT_CPU_TYPE to use and it would fix
> missing default when *-user is switched to using types
> instead of cpu_model.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
>  target/tricore/cpu.h | 1 +
>  1 file changed, 1 insertion(+)

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

Cheers,
Bastian

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

* Re: [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
@ 2018-01-17 17:35   ` Max Filippov
  0 siblings, 0 replies; 53+ messages in thread
From: Max Filippov @ 2018-01-17 17:35 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Laurent Vivier

On Wed, Jan 17, 2018 at 7:43 AM, Igor Mammedov <imammedo@redhat.com> wrote:
> so naming would be in line with other targets and null-machine.c which
> uses the later would compile.
>
> Later it also would be used as default for *-user targets which is
> currently bogus cpu model 'any', that errors out.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  target/xtensa/cpu.h | 2 +-
>  hw/xtensa/sim.c     | 2 +-
>  hw/xtensa/xtfpga.c  | 8 ++++----
>  3 files changed, 6 insertions(+), 6 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
@ 2018-01-17 19:15   ` Igor Mammedov
  2018-01-17 20:30     ` Peter Maydell
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 19:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Wed, 17 Jan 2018 16:12:09 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 17 January 2018 at 15:43, Igor Mammedov <imammedo@redhat.com> wrote:
> > Series is finishing work on generalizing cpu_model parsing
> > and limiting parts that deal with inconsistent cpu_model
> > naming to "-cpu" CLI option processing in vl.c/*-user.main.c
> > and FOO_cpu_class_by_name() callbacks.
> >
> > It introduces TARGET_DEFAULT_CPU_TYPE which must be defined
> > by each target and is used setting default cpu type for
> > linux/bsd-user targets and as anchor point to pick cpu class
> > that provides target specific FOO_cpu_class_by_name()
> > callback for cpu_parse_cpu_model() in null-machine.c
> > which is compiled for all targets that have system
> > mode emulation.  
> 
> I like moving this from being an ifdef ladder into per-cpu
> code, but I don't think the definition belongs in target/$ARCH.
> It's part of the choice usermode makes about how to handle
> binaries it's loading, so it should go in linux-user/$ARCH/target_cpu.h.
> target/$ARCH should really be for things that are properties
> of the architecture.
That's used not only by linux-user but also reused by null-machine.c
to get access to a target specific cpu_class_by_name() callback.
I admit that it's a convoluted API i.e. for cpu_parse_cpu_model()
to require a target specific CPU type to resolve cpu_model name,
but that's what we ended up with and have now.
It seemed logical to me to put YET_ANOTHER_CPU_TYPE to
target/$ARCH/cpu.h along with other target specific CPU type
macros'. 

Main goal of this series is not TARGET_DEFAULT_CPU_TYPE and
its abuse by null-machine.c, but rather getting rid of
cpu_model handling across whole tree (which is easy to misuse
due to existing APIs and its general availability) and limiting
cpu_model translation to option parsing+target specific
cpu_class_by_name() callbacks.

We can build on top of that linux-user specific extension
to pick CPU type based on ELF notes, the difference would
be that it will work with cpu types and not with cpu_model
as it were implemented in:
  [PATCH v3 0/4] linux-user: select CPU type according  ELF header values

> thanks
> -- PMM

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH 12/24] s390x: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 16:04   ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
@ 2018-01-17 19:20     ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-17 19:20 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: qemu-devel, Alexander Graf, qemu-s390x, Laurent Vivier,
	Richard Henderson

On Wed, 17 Jan 2018 17:04:31 +0100
David Hildenbrand <david@redhat.com> wrote:

> On 17.01.2018 16:43, Igor Mammedov wrote:
> > it will be used for for 2 purposes, 1st is to
> > provide to cpu name resolving class for machine 'none'
> >   cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
> > and later to drop a bunch of ifdefs *-user/main.c that
> > set default cpu_model.
> > 
> > Use default value from linux-user for TARGET_DEFAULT_CPU_TYPE.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > CC: Richard Henderson <rth@twiddle.net>
> > CC: Alexander Graf <agraf@suse.de>
> > CC: qemu-s390x@nongnu.org
> > ---
> >  target/s390x/cpu.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> > index 1a8b6b9..174624a 100644
> > --- a/target/s390x/cpu.h
> > +++ b/target/s390x/cpu.h
> > @@ -731,6 +731,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
> >  
> >  #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
> >  #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
> > +#define TARGET_DEFAULT_CPU_TYPE S390_CPU_TYPE_NAME("qemu")
> >  
> >  /* you can call this signal handler from your SIGBUS and SIGSEGV
> >     signal handlers to inform the virtual CPU of exceptions. non zero
> >   
> 
> At least from a !KVM perspective this is correct. And that is at least
> relevant for linux-user. I doubt that this is relevant for KVM. The
> "none" machine cannot be used either way and CPU models are sensed via qmp.
If you look at cpu_parse_cpu_model() impl., you'll see that
TARGET_DEFAULT_CPU_TYPE isn't used as actual CPU type but as a proxy
to get access to CPUClass::class_by_name() callback which is
implemented by every target. So accelerator doesn't have any effect
here.

> Reviewed-by: David Hildenbrand <david@redhat.com>
Thanks! 

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-17 19:15   ` Igor Mammedov
@ 2018-01-17 20:30     ` Peter Maydell
  2018-01-18 10:43       ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Peter Maydell @ 2018-01-17 20:30 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 17 January 2018 at 19:15, Igor Mammedov <imammedo@redhat.com> wrote:
> On Wed, 17 Jan 2018 16:12:09 +0000
> Peter Maydell <peter.maydell@linaro.org> wrote:
>> I like moving this from being an ifdef ladder into per-cpu
>> code, but I don't think the definition belongs in target/$ARCH.
>> It's part of the choice usermode makes about how to handle
>> binaries it's loading, so it should go in linux-user/$ARCH/target_cpu.h.
>> target/$ARCH should really be for things that are properties
>> of the architecture.
> That's used not only by linux-user but also reused by null-machine.c
> to get access to a target specific cpu_class_by_name() callback.

That usage must want a different name, though, surely?
For Arm the default CPU for linux-user is 'any' but that
is usermode only and won't work for system emulation so
null-machine.c will need to pick something else.

thanks
-- PMM

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

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

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

On Wed, Jan 17, 2018 at 04:43:34PM +0100, Igor Mammedov wrote:
> cpu_init(cpu_model) were replaced by cpu_create(cpu_type) so
> no users are left, remove it.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

ppc part

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

> ---
> CC: Richard Henderson <rth@twiddle.net> (maintainer:Alpha)
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Laurent Vivier <laurent@vivier.eu>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Yongbok Kim <yongbok.kim@mips.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: Stafford Horne <shorne@gmail.com>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Alexander Graf <agraf@suse.de>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-arm@nongnu.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> ---
>  target/alpha/cpu.h      | 2 --
>  target/arm/cpu.h        | 2 --
>  target/cris/cpu.h       | 2 --
>  target/hppa/cpu.h       | 1 -
>  target/i386/cpu.h       | 2 --
>  target/lm32/cpu.h       | 2 --
>  target/m68k/cpu.h       | 2 --
>  target/microblaze/cpu.h | 1 -
>  target/mips/cpu.h       | 2 --
>  target/moxie/cpu.h      | 2 --
>  target/nios2/cpu.h      | 1 -
>  target/openrisc/cpu.h   | 2 --
>  target/ppc/cpu.h        | 2 --
>  target/s390x/cpu.h      | 2 --
>  target/sh4/cpu.h        | 2 --
>  target/sparc/cpu.h      | 4 ----
>  target/tilegx/cpu.h     | 1 -
>  target/tricore/cpu.h    | 2 --
>  target/unicore32/cpu.h  | 2 --
>  target/xtensa/cpu.h     | 2 --
>  20 files changed, 38 deletions(-)
> 
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index c8dd560..1a1d9a0 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -468,8 +468,6 @@ enum {
>  
>  void alpha_translate_init(void);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_ALPHA_CPU, cpu_model)
> -
>  #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
>  #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE ALPHA_CPU_TYPE_NAME("ev67")
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index c87bb76..3c1e1aa 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -2167,8 +2167,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
>      return unmasked || pstate_unmasked;
>  }
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_ARM_CPU, cpu_model)
> -
>  #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
>  #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
>  #define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
> diff --git a/target/cris/cpu.h b/target/cris/cpu.h
> index 8feabb4..9845d89 100644
> --- a/target/cris/cpu.h
> +++ b/target/cris/cpu.h
> @@ -267,8 +267,6 @@ enum {
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_CRIS_CPU, cpu_model)
> -
>  #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
>  #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
>  #define TARGET_DEFAULT_CPU_TYPE CRIS_CPU_TYPE_NAME("crisv32")
> diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
> index 04625f7..7a6074e 100644
> --- a/target/hppa/cpu.h
> +++ b/target/hppa/cpu.h
> @@ -112,7 +112,6 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
>  
>  void hppa_translate_init(void);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_HPPA_CPU, cpu_model)
>  #define TARGET_DEFAULT_CPU_TYPE TYPE_HPPA_CPU
>  
>  void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf);
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index f64e5ed..0b4563b 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1557,8 +1557,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)
>  
> diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
> index 65f58f5..ec9efa7 100644
> --- a/target/lm32/cpu.h
> +++ b/target/lm32/cpu.h
> @@ -255,8 +255,6 @@ void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,
>  void lm32_watchpoint_remove(CPULM32State *env, int index);
>  bool lm32_cpu_do_semihosting(CPUState *cs);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_LM32_CPU, cpu_model)
> -
>  #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
>  #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE LM32_CPU_TYPE_NAME("lm32-basic")
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 193e8f8..da4171c 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -401,8 +401,6 @@ void register_m68k_insns (CPUM68KState *env);
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
> -
>  #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
>  #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE M68K_CPU_TYPE_NAME("any")
> diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> index f244efa..3ad1016 100644
> --- a/target/microblaze/cpu.h
> +++ b/target/microblaze/cpu.h
> @@ -343,7 +343,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
>  #define TARGET_PHYS_ADDR_SPACE_BITS 32
>  #define TARGET_VIRT_ADDR_SPACE_BITS 32
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MICROBLAZE_CPU, cpu_model)
>  #define TARGET_DEFAULT_CPU_TYPE TYPE_MICROBLAZE_CPU
>  
>  #define cpu_signal_handler cpu_mb_signal_handler
> diff --git a/target/mips/cpu.h b/target/mips/cpu.h
> index c5ee894..7c66ec0 100644
> --- a/target/mips/cpu.h
> +++ b/target/mips/cpu.h
> @@ -739,8 +739,6 @@ enum {
>  
>  int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model)
> -
>  #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
>  #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
>  
> diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
> index 9fabb93..a3a1bba 100644
> --- a/target/moxie/cpu.h
> +++ b/target/moxie/cpu.h
> @@ -120,8 +120,6 @@ void moxie_translate_init(void);
>  int cpu_moxie_signal_handler(int host_signum, void *pinfo,
>                               void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_MOXIE_CPU, cpu_model)
> -
>  #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
>  #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE MOXIE_CPU_TYPE_NAME("any")
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 2d03958..71a48b1 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -231,7 +231,6 @@ void nios2_check_interrupts(CPUNios2State *env);
>  # define TARGET_VIRT_ADDR_SPACE_BITS 32
>  #endif
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model)
>  #define TARGET_DEFAULT_CPU_TYPE TYPE_NIOS2_CPU
>  
>  #define cpu_gen_code cpu_nios2_gen_code
> diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
> index 8d1a87e..f2d2abb 100644
> --- a/target/openrisc/cpu.h
> +++ b/target/openrisc/cpu.h
> @@ -390,8 +390,6 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,
>                                 int *prot, target_ulong address, int rw);
>  #endif
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model)
> -
>  #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
>  #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE OPENRISC_CPU_TYPE_NAME("or1200")
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 4af4aff..3dc0359 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1372,8 +1372,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
>  
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 174624a..3e647df 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -727,8 +727,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
>  
>  
>  /* helper.c */
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_model)
> -
>  #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
>  #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
>  #define TARGET_DEFAULT_CPU_TYPE S390_CPU_TYPE_NAME("qemu")
> diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
> index 203d212..ad58e24 100644
> --- a/target/sh4/cpu.h
> +++ b/target/sh4/cpu.h
> @@ -274,8 +274,6 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr);
>  
>  void cpu_load_tlb(CPUSH4State * env);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_SUPERH_CPU, cpu_model)
> -
>  #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
>  #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE SUPERH_CPU_TYPE_NAME("sh7785")
> diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
> index 02c55ad..54b3dc7 100644
> --- a/target/sparc/cpu.h
> +++ b/target/sparc/cpu.h
> @@ -654,10 +654,6 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
>  #endif
>  int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#ifndef NO_CPU_IO_DEFS
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_SPARC_CPU, cpu_model)
> -#endif
> -
>  #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
>  #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
>  
> diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h
> index 67de53e..6c89b05 100644
> --- a/target/tilegx/cpu.h
> +++ b/target/tilegx/cpu.h
> @@ -164,7 +164,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env)
>  void tilegx_tcg_init(void);
>  int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
>  #define TARGET_DEFAULT_CPU_TYPE TYPE_TILEGX_CPU
>  
>  #define cpu_signal_handler cpu_tilegx_signal_handler
> diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
> index 835d51a..8ed17e0 100644
> --- a/target/tricore/cpu.h
> +++ b/target/tricore/cpu.h
> @@ -411,8 +411,6 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
>      *flags = 0;
>  }
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_TRICORE_CPU, cpu_model)
> -
>  #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
>  #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE TRICORE_CPU_TYPE_NAME("tc1796")
> diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
> index fd3fa81..91b673a 100644
> --- a/target/unicore32/cpu.h
> +++ b/target/unicore32/cpu.h
> @@ -165,8 +165,6 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
>  
>  #include "exec/cpu-all.h"
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model)
> -
>  #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
>  #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
>  #define TARGET_DEFAULT_CPU_TYPE UNICORE32_CPU_TYPE_NAME("any")
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index 537e151..c21acf9 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -508,8 +508,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>  #endif
>  #define TARGET_DEFAULT_CPU_TYPE XTENSA_CPU_TYPE_NAME(XTENSA_DEFAULT_CPU_MODEL)
>  
> -#define cpu_init(cpu_model) cpu_generic_init(TYPE_XTENSA_CPU, cpu_model)
> -
>  void xtensa_translate_init(void);
>  void xtensa_breakpoint_handler(CPUState *cs);
>  void xtensa_finalize_config(XtensaConfig *config);

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

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

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

* Re: [Qemu-devel] [PATCH 11/24] ppc: cpu: add TARGET_DEFAULT_CPU_TYPE macro
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
@ 2018-01-18  0:30   ` David Gibson
  0 siblings, 0 replies; 53+ messages in thread
From: David Gibson @ 2018-01-18  0:30 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, Laurent Vivier, Riku Voipio, Alexander Graf, qemu-ppc

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

On Wed, Jan 17, 2018 at 04:43:23PM +0100, Igor Mammedov wrote:
> it will be used for for 2 purposes, 1st is to
> provide to cpu name resolving class for machine 'none'
>   cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model)
> and later to drop a bunch of ifdefs *-user/main.c that
> set default cpu_model.
> 
> Use default values from linux-user for TARGET_DEFAULT_CPU_TYPE.
> While at it fixup linux-user to use corresponding cpu models
> instead of aliases.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

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

> ---
> CC: Riku Voipio <riku.voipio@iki.fi>
> CC: Laurent Vivier <laurent@vivier.eu>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Alexander Graf <agraf@suse.de>
> CC: qemu-ppc@nongnu.org
> ---
>  target/ppc/cpu.h  | 6 ++++++
>  linux-user/main.c | 4 ++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index a5e49f2..4af4aff 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1377,6 +1377,12 @@ 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
>  
> +#ifdef TARGET_PPC64
> +#define TARGET_DEFAULT_CPU_TYPE POWERPC_CPU_TYPE_NAME("power8_v2.0")
> +#else
> +#define TARGET_DEFAULT_CPU_TYPE POWERPC_CPU_TYPE_NAME("750_v3.1")
> +#endif
> +
>  #define cpu_signal_handler cpu_ppc_signal_handler
>  #define cpu_list ppc_cpu_list
>  
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 54e8aac..279cd97 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -4343,9 +4343,9 @@ int main(int argc, char **argv, char **envp)
>          cpu_model = "or1200";
>  #elif defined(TARGET_PPC)
>  # ifdef TARGET_PPC64
> -        cpu_model = "POWER8";
> +        cpu_model = "power8_v2.0";
>  # else
> -        cpu_model = "750";
> +        cpu_model = "750_v3.1";
>  # endif
>  #elif defined TARGET_SH4
>          cpu_model = "sh7785";

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

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

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
@ 2018-01-18  1:48   ` Eduardo Habkost
  2018-01-18 10:10     ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-01-18  1:48 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:
> The last user of it was machine type 'none', which used field
> to create CPU id user requested it on CLI with -cpu option.
> 
> We could compare pointers of MachineState::cpu_type and
> MachineClass::default_cpu_type to check for the same condition,
> and drop cpu_model concept completly from machine/boards code
> So that no one would try to reuse obsolete field and only
> place to deal with cpu model would be vl.c and
> foo_cpu_class_by_name() callbacks.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Marcel Apfelbaum <marcel@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/hw/boards.h    |  1 -
>  hw/core/null-machine.c | 10 +++++++---
>  vl.c                   |  8 +++++++-
>  3 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 156b16f..decd0ec 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -246,7 +246,6 @@ struct MachineState {
>      char *kernel_filename;
>      char *kernel_cmdline;
>      char *initrd_filename;
> -    const char *cpu_model;
>      const char *cpu_type;
>      AccelState *accelerator;
>      CPUArchIdList *possible_cpus;
> diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
> index 864832d..c2e466c 100644
> --- a/hw/core/null-machine.c
> +++ b/hw/core/null-machine.c
> @@ -23,10 +23,13 @@
>  static void machine_none_init(MachineState *mch)
>  {
>      CPUState *cpu = NULL;
> +    MachineClass *mc = MACHINE_GET_CLASS(mch);
>  
> -    /* Initialize CPU (if a model has been specified) */
> -    if (mch->cpu_model) {
> -        cpu = cpu_init(mch->cpu_model);
> +    /* Initialize CPU if cpu_type pointer is user provided
> +     * (i.e. != to pointer tot static default cpu type string)
> +     */
> +    if (mch->cpu_type != mc->default_cpu_type) {
> +        cpu = cpu_create(mch->cpu_type);

This is a big assumption about the code that sets mch->cpu_type.
A simple g_strdup(machine_class->default_cpu_type) would break
this silently (as it won't trigger the assert() below).


>          if (!cpu) {
>              error_report("Unable to initialize CPU");
>              exit(1);
> @@ -54,6 +57,7 @@ static void machine_none_machine_init(MachineClass *mc)
>      mc->init = machine_none_init;
>      mc->max_cpus = 1;
>      mc->default_ram_size = 0;
> +    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;

Why do you need this?  Isn't it simpler to just leave
default_cpu_type=NULL here?


>  }
>  
>  DEFINE_MACHINE("none", machine_none_machine_init)
> diff --git a/vl.c b/vl.c
> index 2586f25..8aa0131 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4609,7 +4609,6 @@ 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_numa_opts(current_machine);
>  
> @@ -4619,6 +4618,13 @@ int main(int argc, char **argv, char **envp)
>          if (cpu_model) {
>              current_machine->cpu_type =
>                  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
> +
> +            /* machine 'none' depends on default cpu type pointer not being
> +             * equal to resolved type name pointer to fugure out if type was
> +             * user provided, make sure that if it becomes not true in future
> +             * it won't beark silently */
> +            g_assert(
> +                current_machine->cpu_type != machine_class->default_cpu_type);
>          }
>      }
>  
> -- 
> 2.7.4
> 

-- 
Eduardo

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

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

On Wed, Jan 17, 2018 at 04:43:34PM +0100, Igor Mammedov wrote:
> cpu_init(cpu_model) were replaced by cpu_create(cpu_type) so
> no users are left, remove it.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Wonderful.

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

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-18  1:48   ` Eduardo Habkost
@ 2018-01-18 10:10     ` Igor Mammedov
  2018-01-18 19:18       ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 10:10 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Wed, 17 Jan 2018 23:48:46 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:
> > The last user of it was machine type 'none', which used field
> > to create CPU id user requested it on CLI with -cpu option.
> > 
> > We could compare pointers of MachineState::cpu_type and
> > MachineClass::default_cpu_type to check for the same condition,
> > and drop cpu_model concept completly from machine/boards code
> > So that no one would try to reuse obsolete field and only
> > place to deal with cpu model would be vl.c and
> > foo_cpu_class_by_name() callbacks.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: Marcel Apfelbaum <marcel@redhat.com>
> > CC: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> >  include/hw/boards.h    |  1 -
> >  hw/core/null-machine.c | 10 +++++++---
> >  vl.c                   |  8 +++++++-
> >  3 files changed, 14 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > index 156b16f..decd0ec 100644
> > --- a/include/hw/boards.h
> > +++ b/include/hw/boards.h
> > @@ -246,7 +246,6 @@ struct MachineState {
> >      char *kernel_filename;
> >      char *kernel_cmdline;
> >      char *initrd_filename;
> > -    const char *cpu_model;
> >      const char *cpu_type;
> >      AccelState *accelerator;
> >      CPUArchIdList *possible_cpus;
> > diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
> > index 864832d..c2e466c 100644
> > --- a/hw/core/null-machine.c
> > +++ b/hw/core/null-machine.c
> > @@ -23,10 +23,13 @@
> >  static void machine_none_init(MachineState *mch)
> >  {
> >      CPUState *cpu = NULL;
> > +    MachineClass *mc = MACHINE_GET_CLASS(mch);
> >  
> > -    /* Initialize CPU (if a model has been specified) */
> > -    if (mch->cpu_model) {
> > -        cpu = cpu_init(mch->cpu_model);
> > +    /* Initialize CPU if cpu_type pointer is user provided
> > +     * (i.e. != to pointer tot static default cpu type string)
> > +     */
> > +    if (mch->cpu_type != mc->default_cpu_type) {
> > +        cpu = cpu_create(mch->cpu_type);  
> 
> This is a big assumption about the code that sets mch->cpu_type.
> A simple g_strdup(machine_class->default_cpu_type) would break
> this silently (as it won't trigger the assert() below).
Yes, it's a bit of a hack to figure out is user has requested
cpu type explicitly. But so far there isn't need to do
   g_strdup(machine_class->default_cpu_type)
when copying default in vl.c and guarding against it
looks like overkill currently.

Cleaner way would be to make cpu_type property, add new property
API to set/check flags and use that here, there are other places
that would benefit from such API as well.
But it looks beyond scope of this series, so I used simple
hackish way to make it work with current code.

I can amend comment here:
    /* Initialize CPU if cpu_type pointer is user provided
     * (i.e. != to pointer to static default cpu type string)
     * MachineClass::default_cpu_type must be assigned to
     * MachineState::cpu_type directly for this to work.
     * TODO:
     *   - make cpu_type a property
     *   - add API to add/check user_set flag to property
     *   - use new API to check if property was user set
     */

> 
> 
> >          if (!cpu) {
> >              error_report("Unable to initialize CPU");
> >              exit(1);
> > @@ -54,6 +57,7 @@ static void machine_none_machine_init(MachineClass *mc)
> >      mc->init = machine_none_init;
> >      mc->max_cpus = 1;
> >      mc->default_ram_size = 0;
> > +    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;  
> 
> Why do you need this?  Isn't it simpler to just leave
> default_cpu_type=NULL here?
vl.c "-cpu" parsing depends on default_cpu_type being set
 ...
 if (machine_class->default_cpu_type) {
   ...
 }
when we get rid of requirement for proxy type in
 cpu_parse_cpu_model()
we can drop this ugliness in null-machine.

I'm doing it dirty way to prevent cpu_model resurgence
in boards code as it happened with nios2, even though
I've tried to monitor list for such patches.
 
> >  }
> >  
> >  DEFINE_MACHINE("none", machine_none_machine_init)
> > diff --git a/vl.c b/vl.c
> > index 2586f25..8aa0131 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -4609,7 +4609,6 @@ 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_numa_opts(current_machine);
> >  
> > @@ -4619,6 +4618,13 @@ int main(int argc, char **argv, char **envp)
> >          if (cpu_model) {
> >              current_machine->cpu_type =
> >                  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
> > +
> > +            /* machine 'none' depends on default cpu type pointer not being
> > +             * equal to resolved type name pointer to fugure out if type was
> > +             * user provided, make sure that if it becomes not true in future
> > +             * it won't beark silently */
> > +            g_assert(
> > +                current_machine->cpu_type != machine_class->default_cpu_type);
> >          }
> >      }
> >  
> > -- 
> > 2.7.4
> >   
> 

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-17 20:30     ` Peter Maydell
@ 2018-01-18 10:43       ` Igor Mammedov
  2018-01-18 10:50         ` Peter Maydell
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 10:43 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Wed, 17 Jan 2018 20:30:14 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 17 January 2018 at 19:15, Igor Mammedov <imammedo@redhat.com> wrote:
> > On Wed, 17 Jan 2018 16:12:09 +0000
> > Peter Maydell <peter.maydell@linaro.org> wrote:  
> >> I like moving this from being an ifdef ladder into per-cpu
> >> code, but I don't think the definition belongs in target/$ARCH.
> >> It's part of the choice usermode makes about how to handle
> >> binaries it's loading, so it should go in linux-user/$ARCH/target_cpu.h.
> >> target/$ARCH should really be for things that are properties
> >> of the architecture.  
> > That's used not only by linux-user but also reused by null-machine.c
> > to get access to a target specific cpu_class_by_name() callback.  
> 
> That usage must want a different name, though, surely?
> For Arm the default CPU for linux-user is 'any' but that
> is usermode only and won't work for system emulation so
> null-machine.c will need to pick something else.
not really in general as boards set their own default types
and secondly it applies only to null-machine.
Though in both cases it work the same just fine because
current API works like this (system emulation)
 vl.c:
        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); 
            ...
        }

which would result for null-machine (patch 20/24) in:

       cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model):
            oc = cpu_class_by_name(TARGET_DEFAULT_CPU_TYPE, cpu_model):
                 cc = CPU_CLASS(object_class_by_name(TARGET_DEFAULT_CPU_TYPE))
                 cc->class_by_name(cpu_model)
            
so it doesn't really matter for system emulation what exact
type is used as a proxy to reach callback, as each target
implements only one cb in base CPU class and any leaf class
will work fine to reach the same class_by_name() cb.
So type that is default for linux-user can be abused for
this purpose and could be used as linux-default at
the same time.

Ugly and hackish, yes.
But it isolates cpu_model handling to a few places and
series removes API that uses it, so we won't have to
watch out for patches that would bring cpu_model
back into boards code after that.

On top of that, we could work on making cpu_parse_cpu_model()
API not to require proxy cpu type and that would affect
only 3 remaining callers in vl.c,bsd/linux-user/main.c
But that another re-factoring beyond the scope of this series,
which is already big as it is.

> thanks
> -- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 10:43       ` Igor Mammedov
@ 2018-01-18 10:50         ` Peter Maydell
  2018-01-18 13:06           ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Peter Maydell @ 2018-01-18 10:50 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 18 January 2018 at 10:43, Igor Mammedov <imammedo@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> wrote:
>> That usage must want a different name, though, surely?
>> For Arm the default CPU for linux-user is 'any' but that
>> is usermode only and won't work for system emulation so
>> null-machine.c will need to pick something else.

> not really in general as boards set their own default types
> and secondly it applies only to null-machine.
> Though in both cases it work the same just fine because
> current API works like this (system emulation)
>  vl.c:
>         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);
>             ...
>         }
>
> which would result for null-machine (patch 20/24) in:
>
>        cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model):
>             oc = cpu_class_by_name(TARGET_DEFAULT_CPU_TYPE, cpu_model):
>                  cc = CPU_CLASS(object_class_by_name(TARGET_DEFAULT_CPU_TYPE))
>                  cc->class_by_name(cpu_model)

In system emulation we don't define the "any" cpu type
at all, so I would expect cpu_class_by_name() to always
return an error here.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 10:50         ` Peter Maydell
@ 2018-01-18 13:06           ` Igor Mammedov
  2018-01-18 13:10             ` Peter Maydell
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 13:06 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Thu, 18 Jan 2018 10:50:19 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 18 January 2018 at 10:43, Igor Mammedov <imammedo@redhat.com> wrote:
> > Peter Maydell <peter.maydell@linaro.org> wrote:  
> >> That usage must want a different name, though, surely?
> >> For Arm the default CPU for linux-user is 'any' but that
> >> is usermode only and won't work for system emulation so
> >> null-machine.c will need to pick something else.  
> 
> > not really in general as boards set their own default types
> > and secondly it applies only to null-machine.
> > Though in both cases it work the same just fine because
> > current API works like this (system emulation)
> >  vl.c:
> >         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);
> >             ...
> >         }
> >
> > which would result for null-machine (patch 20/24) in:
> >
> >        cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model):
> >             oc = cpu_class_by_name(TARGET_DEFAULT_CPU_TYPE, cpu_model):
> >                  cc = CPU_CLASS(object_class_by_name(TARGET_DEFAULT_CPU_TYPE))
> >                  cc->class_by_name(cpu_model)  
> 
> In system emulation we don't define the "any" cpu type
> at all, so I would expect cpu_class_by_name() to always
> return an error here.

My bad, 'make check' was fine but it looks like we don't test
null-machine with -cpu foo, I should add a patch for that
along with series on respin.

I've looked and such case is rather an exception,
I can fix it up in 2 ways:
1st:
  target/arm/cpu.h
  +#if !defined(CONFIG_USER_ONLY)
  +#define TARGET_DEFAULT_CPU_TYPE TYPE_ARM_CPU
  +else
  +#define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
  +#endif

or 2nd is to compile in "any" type in system mode
(which most targets do), roughly it would amount to:
  target/arm/cpu.c
  @@ -1671,10 +1671,8 @@ static const ARMCPUInfo arm_cpus[] = {
     { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
     { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
     { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
  -#ifdef CONFIG_USER_ONLY
     { .name = "any",         .initfn = arm_any_initfn },
   #endif
  -#endif
     { .name = NULL }
   };

and it would allow us to drop/cleanup more ifdefs in target/arm/cpu.c
I'd prefer 2nd approach, so code would be more consistent
with other targets and as benefit with less ifdefs.

> thanks
> -- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:06           ` Igor Mammedov
@ 2018-01-18 13:10             ` Peter Maydell
  2018-01-18 13:34               ` Igor Mammedov
  2018-01-18 15:31               ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 53+ messages in thread
From: Peter Maydell @ 2018-01-18 13:10 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 18 January 2018 at 13:06, Igor Mammedov <imammedo@redhat.com> wrote:
> I've looked and such case is rather an exception,
> I can fix it up in 2 ways:
> 1st:
>   target/arm/cpu.h
>   +#if !defined(CONFIG_USER_ONLY)
>   +#define TARGET_DEFAULT_CPU_TYPE TYPE_ARM_CPU
>   +else
>   +#define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
>   +#endif

This is weird, because TYPE_ARM_CPU isn't really
a sensible thing to use for anything, so you've really set
it up as a "this is only of any use for null-machine.c",
in which case you should just do that in null-machine.c.

> or 2nd is to compile in "any" type in system mode
> (which most targets do), roughly it would amount to:
>   target/arm/cpu.c
>   @@ -1671,10 +1671,8 @@ static const ARMCPUInfo arm_cpus[] = {
>      { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
>      { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
>      { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
>   -#ifdef CONFIG_USER_ONLY
>      { .name = "any",         .initfn = arm_any_initfn },
>    #endif
>   -#endif
>      { .name = NULL }
>    };

This is definitely wrong. We deliberately don't provide "any"
in system mode, because it's not a sensible thing for users
to try to use with board emulation. We disabled it some while
back to avoid users trying it by accident and getting confused.

In general, for Arm you really need to know which CPU you want
to use and why. So:
 linux-user and bsd-user: should use "any"
 board models: should use whatever CPU that board is designed for
 null-machine: if it genuinely doesn't care, then pick one at random

But there is no single sensible "default CPU type" at an architecture
level, which is why you can't define a TARGET_DEFAULT_CPU_TYPE
in target/arm/cpu.h. Any code that thinks it wants that should
instead be defining it own default that makes sense for that
context.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:10             ` Peter Maydell
@ 2018-01-18 13:34               ` Igor Mammedov
  2018-01-18 13:36                 ` Peter Maydell
  2018-01-18 15:31               ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 13:34 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Thu, 18 Jan 2018 13:10:13 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 18 January 2018 at 13:06, Igor Mammedov <imammedo@redhat.com> wrote:
> > I've looked and such case is rather an exception,
> > I can fix it up in 2 ways:
> > 1st:
> >   target/arm/cpu.h
> >   +#if !defined(CONFIG_USER_ONLY)
> >   +#define TARGET_DEFAULT_CPU_TYPE TYPE_ARM_CPU
> >   +else
> >   +#define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
> >   +#endif  
> 
> This is weird, because TYPE_ARM_CPU isn't really
> a sensible thing to use for anything, so you've really set
> it up as a "this is only of any use for null-machine.c",
> in which case you should just do that in null-machine.c.
yep, that would be only for null-machine.c use as proxy type,
however null-machine.c is build for every target so this
proxy type can't be defined null-machine.c unless we resort
to ifdef ladder there.

How about adding to each $ARCH/cpu.h a null-machine dedicated
define:
  
  #define CPU_RESOLVING_TYPE TYPE_FOO_CPU

using that in null machine and renaming

TARGET_DEFAULT_CPU_TYPE to USERONLY_DEFAULT_CPU_TYPE

but I'd still keep it within $ARCH/cpu.h so we won't
have to create a bunch of new linux-user/$ARCH/target_elf.h
files just for that and duplicate it to bsd-user/$ARCH/target_elf.h

> thanks
> -- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:34               ` Igor Mammedov
@ 2018-01-18 13:36                 ` Peter Maydell
  2018-01-18 13:45                   ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Peter Maydell @ 2018-01-18 13:36 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 18 January 2018 at 13:34, Igor Mammedov <imammedo@redhat.com> wrote:
> and renaming
>
> TARGET_DEFAULT_CPU_TYPE to USERONLY_DEFAULT_CPU_TYPE
>
> but I'd still keep it within $ARCH/cpu.h so we won't
> have to create a bunch of new linux-user/$ARCH/target_elf.h
> files just for that and duplicate it to bsd-user/$ARCH/target_elf.h

We already have linux-user/$ARCH/target_cpu.h, which is exactly
for this kind of define.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:36                 ` Peter Maydell
@ 2018-01-18 13:45                   ` Igor Mammedov
  2018-01-18 13:49                     ` Peter Maydell
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 13:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Thu, 18 Jan 2018 13:36:40 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 18 January 2018 at 13:34, Igor Mammedov <imammedo@redhat.com> wrote:
> > and renaming
> >
> > TARGET_DEFAULT_CPU_TYPE to USERONLY_DEFAULT_CPU_TYPE
> >
> > but I'd still keep it within $ARCH/cpu.h so we won't
> > have to create a bunch of new linux-user/$ARCH/target_elf.h
> > files just for that and duplicate it to bsd-user/$ARCH/target_elf.h  
> 
> We already have linux-user/$ARCH/target_cpu.h, which is exactly
> for this kind of define.
we don't have it for bsd-user though and it would be
code duplication to add such.
Using $ARCH/cpu.h seems to be a better fit for sharing
default across liux/bsd-user.

> thanks
> -- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:45                   ` Igor Mammedov
@ 2018-01-18 13:49                     ` Peter Maydell
  2018-01-18 14:02                       ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Peter Maydell @ 2018-01-18 13:49 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU Developers, Laurent Vivier

On 18 January 2018 at 13:45, Igor Mammedov <imammedo@redhat.com> wrote:
> On Thu, 18 Jan 2018 13:36:40 +0000
> Peter Maydell <peter.maydell@linaro.org> wrote:
>
>> On 18 January 2018 at 13:34, Igor Mammedov <imammedo@redhat.com> wrote:
>> > and renaming
>> >
>> > TARGET_DEFAULT_CPU_TYPE to USERONLY_DEFAULT_CPU_TYPE
>> >
>> > but I'd still keep it within $ARCH/cpu.h so we won't
>> > have to create a bunch of new linux-user/$ARCH/target_elf.h
>> > files just for that and duplicate it to bsd-user/$ARCH/target_elf.h
>>
>> We already have linux-user/$ARCH/target_cpu.h, which is exactly
>> for this kind of define.
> we don't have it for bsd-user though and it would be
> code duplication to add such.
> Using $ARCH/cpu.h seems to be a better fit for sharing
> default across liux/bsd-user.

Yes, bsd-user is a bit unmaintained and behind linux-user in
its structuring. I don't mind bsd-user being a bit of a mess,
but I don't want problems in bsd-user to cause us to put code
where it shouldn't be in other parts of the codebase. (It's
not inherently the case that "best CPU choice for Linux user"
is the same as "best CPU choice for bsd-user" either.)

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:49                     ` Peter Maydell
@ 2018-01-18 14:02                       ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-01-18 14:02 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Laurent Vivier

On Thu, 18 Jan 2018 13:49:25 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 18 January 2018 at 13:45, Igor Mammedov <imammedo@redhat.com> wrote:
> > On Thu, 18 Jan 2018 13:36:40 +0000
> > Peter Maydell <peter.maydell@linaro.org> wrote:
> >  
> >> On 18 January 2018 at 13:34, Igor Mammedov <imammedo@redhat.com> wrote:  
> >> > and renaming
> >> >
> >> > TARGET_DEFAULT_CPU_TYPE to USERONLY_DEFAULT_CPU_TYPE
> >> >
> >> > but I'd still keep it within $ARCH/cpu.h so we won't
> >> > have to create a bunch of new linux-user/$ARCH/target_elf.h
> >> > files just for that and duplicate it to bsd-user/$ARCH/target_elf.h  
> >>
> >> We already have linux-user/$ARCH/target_cpu.h, which is exactly
> >> for this kind of define.  
> > we don't have it for bsd-user though and it would be
> > code duplication to add such.
> > Using $ARCH/cpu.h seems to be a better fit for sharing
> > default across liux/bsd-user.  
> 
> Yes, bsd-user is a bit unmaintained and behind linux-user in
> its structuring. I don't mind bsd-user being a bit of a mess,
> but I don't want problems in bsd-user to cause us to put code
> where it shouldn't be in other parts of the codebase. (It's
> not inherently the case that "best CPU choice for Linux user"
> is the same as "best CPU choice for bsd-user" either.)
Ok, if there isn't objections wrt above mentioned code
duplication in *-user, I surely can implement it as far as
I can remove cpu_model along with it.

> 
> thanks
> -- PMM

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 13:10             ` Peter Maydell
  2018-01-18 13:34               ` Igor Mammedov
@ 2018-01-18 15:31               ` Philippe Mathieu-Daudé
  2018-01-18 15:41                 ` Peter Maydell
  1 sibling, 1 reply; 53+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-18 15:31 UTC (permalink / raw)
  To: Peter Maydell, Igor Mammedov, Laurent Vivier, Aurelien Jarno,
	Michael Tokarev, Riku Voipio, Agustin Henze
  Cc: QEMU Developers, Debian QEMU Team

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

(CC'ing linux-user maintainers)

Hi Peter, Igor,

On 01/18/2018 10:10 AM, Peter Maydell wrote:
> On 18 January 2018 at 13:06, Igor Mammedov <imammedo@redhat.com> wrote:
>> I've looked and such case is rather an exception,
>> I can fix it up in 2 ways:
>> 1st:
>>   target/arm/cpu.h
>>   +#if !defined(CONFIG_USER_ONLY)
>>   +#define TARGET_DEFAULT_CPU_TYPE TYPE_ARM_CPU
>>   +else
>>   +#define TARGET_DEFAULT_CPU_TYPE ARM_CPU_TYPE_NAME("any")
>>   +#endif
> 
> This is weird, because TYPE_ARM_CPU isn't really
> a sensible thing to use for anything, so you've really set
> it up as a "this is only of any use for null-machine.c",
> in which case you should just do that in null-machine.c.
> 
>> or 2nd is to compile in "any" type in system mode
>> (which most targets do), roughly it would amount to:
>>   target/arm/cpu.c
>>   @@ -1671,10 +1671,8 @@ static const ARMCPUInfo arm_cpus[] = {
>>      { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
>>      { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
>>      { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
>>   -#ifdef CONFIG_USER_ONLY
>>      { .name = "any",         .initfn = arm_any_initfn },
>>    #endif
>>   -#endif
>>      { .name = NULL }
>>    };
> 
> This is definitely wrong. We deliberately don't provide "any"
> in system mode, because it's not a sensible thing for users
> to try to use with board emulation. We disabled it some while
> back to avoid users trying it by accident and getting confused.
> 
> In general, for Arm you really need to know which CPU you want
> to use and why. So:
>  linux-user and bsd-user: should use "any"

I disagree on this, since userland binaries are compiled for a specific
arch/ABI/FPU.
Even without worrying about the FPU, it is unlikely the "any" cpu can
run indifferently ARMv6 and ARMv7 binaries.

IMHO ARMv5 should default to arm946, ARMv6  arm1176 and ARMv7 to cortex-a7.

I think we should do the same for linux-user than system and remove the
'any' cpu for ARM.

>  board models: should use whatever CPU that board is designed for
>  null-machine: if it genuinely doesn't care, then pick one at random

Should work :)

Maybe pick the latest/best implemented, hoping this has more features to
cover?

> But there is no single sensible "default CPU type" at an architecture
> level, which is why you can't define a TARGET_DEFAULT_CPU_TYPE
> in target/arm/cpu.h. Any code that thinks it wants that should
> instead be defining it own default that makes sense for that
> context.
> 
> thanks
> -- PMM
> 


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

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

* Re: [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4)
  2018-01-18 15:31               ` Philippe Mathieu-Daudé
@ 2018-01-18 15:41                 ` Peter Maydell
  0 siblings, 0 replies; 53+ messages in thread
From: Peter Maydell @ 2018-01-18 15:41 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Igor Mammedov, Laurent Vivier, Aurelien Jarno, Michael Tokarev,
	Riku Voipio, Agustin Henze, QEMU Developers, Debian QEMU Team

On 18 January 2018 at 15:31, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> I disagree on this, since userland binaries are compiled for a specific
> arch/ABI/FPU.
> Even without worrying about the FPU, it is unlikely the "any" cpu can
> run indifferently ARMv6 and ARMv7 binaries.

In practice this works fine. Generally for userspace the Arm
architecture retains backwards compatibility. (This is not the
case for kernel mode, obviously.)

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-18 10:10     ` Igor Mammedov
@ 2018-01-18 19:18       ` Eduardo Habkost
  2018-01-19 10:14         ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-01-18 19:18 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Thu, Jan 18, 2018 at 11:10:35AM +0100, Igor Mammedov wrote:
> On Wed, 17 Jan 2018 23:48:46 -0200
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:
> > > The last user of it was machine type 'none', which used field
> > > to create CPU id user requested it on CLI with -cpu option.
> > > 
> > > We could compare pointers of MachineState::cpu_type and
> > > MachineClass::default_cpu_type to check for the same condition,
> > > and drop cpu_model concept completly from machine/boards code
> > > So that no one would try to reuse obsolete field and only
> > > place to deal with cpu model would be vl.c and
> > > foo_cpu_class_by_name() callbacks.
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > ---
> > > CC: Eduardo Habkost <ehabkost@redhat.com>
> > > CC: Marcel Apfelbaum <marcel@redhat.com>
> > > CC: Paolo Bonzini <pbonzini@redhat.com>
> > > ---
> > >  include/hw/boards.h    |  1 -
> > >  hw/core/null-machine.c | 10 +++++++---
> > >  vl.c                   |  8 +++++++-
> > >  3 files changed, 14 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > > index 156b16f..decd0ec 100644
> > > --- a/include/hw/boards.h
> > > +++ b/include/hw/boards.h
> > > @@ -246,7 +246,6 @@ struct MachineState {
> > >      char *kernel_filename;
> > >      char *kernel_cmdline;
> > >      char *initrd_filename;
> > > -    const char *cpu_model;
> > >      const char *cpu_type;
> > >      AccelState *accelerator;
> > >      CPUArchIdList *possible_cpus;
> > > diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
> > > index 864832d..c2e466c 100644
> > > --- a/hw/core/null-machine.c
> > > +++ b/hw/core/null-machine.c
> > > @@ -23,10 +23,13 @@
> > >  static void machine_none_init(MachineState *mch)
> > >  {
> > >      CPUState *cpu = NULL;
> > > +    MachineClass *mc = MACHINE_GET_CLASS(mch);
> > >  
> > > -    /* Initialize CPU (if a model has been specified) */
> > > -    if (mch->cpu_model) {
> > > -        cpu = cpu_init(mch->cpu_model);
> > > +    /* Initialize CPU if cpu_type pointer is user provided
> > > +     * (i.e. != to pointer tot static default cpu type string)
> > > +     */
> > > +    if (mch->cpu_type != mc->default_cpu_type) {
> > > +        cpu = cpu_create(mch->cpu_type);  
> > 
> > This is a big assumption about the code that sets mch->cpu_type.
> > A simple g_strdup(machine_class->default_cpu_type) would break
> > this silently (as it won't trigger the assert() below).
> Yes, it's a bit of a hack to figure out is user has requested
> cpu type explicitly. But so far there isn't need to do
>    g_strdup(machine_class->default_cpu_type)
> when copying default in vl.c and guarding against it
> looks like overkill currently.
> 
> Cleaner way would be to make cpu_type property, add new property
> API to set/check flags and use that here, there are other places
> that would benefit from such API as well.
> But it looks beyond scope of this series, so I used simple
> hackish way to make it work with current code.
> 
> I can amend comment here:
>     /* Initialize CPU if cpu_type pointer is user provided
>      * (i.e. != to pointer to static default cpu type string)
>      * MachineClass::default_cpu_type must be assigned to
>      * MachineState::cpu_type directly for this to work.
>      * TODO:
>      *   - make cpu_type a property
>      *   - add API to add/check user_set flag to property
>      *   - use new API to check if property was user set
>      */
> 
> > 
> > 
> > >          if (!cpu) {
> > >              error_report("Unable to initialize CPU");
> > >              exit(1);
> > > @@ -54,6 +57,7 @@ static void machine_none_machine_init(MachineClass *mc)
> > >      mc->init = machine_none_init;
> > >      mc->max_cpus = 1;
> > >      mc->default_ram_size = 0;
> > > +    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;  
> > 
> > Why do you need this?  Isn't it simpler to just leave
> > default_cpu_type=NULL here?
> vl.c "-cpu" parsing depends on default_cpu_type being set
>  ...
>  if (machine_class->default_cpu_type) {
>    ...
>  }

Right, this makes sense now.

It looks like default_cpu_type is being overloaded for two
different roles: 1) specifying the default CPU type; 2) finding
the arch-specific class to be used to parse -cpu.

In the case of null-machine, these two roles conflict with each
other.  I believe we can find other solutions instead of this
hack that involves lying on MachineClass::default_cpu_type (and
then having to work around the lie on machine_none_init()).

I see multiple options: adding a new MachineClass field for that
(e.g.  resolving_cpu_type, which defaults to default_cpu_type if
NULL); moving the CPU parsing code to arch_init.c (so it could
use CPU_RESOLVING_TYPE or something similar); adding a optional
MachineClass::parse_cpu_model hook.  We could even try to get rid
of CPUClass::parse_features completely


> when we get rid of requirement for proxy type in
>  cpu_parse_cpu_model()
> we can drop this ugliness in null-machine.

I'd prefer to not introduce this ugliness in the first place.

> 
> I'm doing it dirty way to prevent cpu_model resurgence
> in boards code as it happened with nios2, even though
> I've tried to monitor list for such patches.

To be honest, I don't think the harm in having new code using
MachineState::cpu_model is so big to justify this hack.


>  
> > >  }
> > >  
> > >  DEFINE_MACHINE("none", machine_none_machine_init)
> > > diff --git a/vl.c b/vl.c
> > > index 2586f25..8aa0131 100644
> > > --- a/vl.c
> > > +++ b/vl.c
> > > @@ -4609,7 +4609,6 @@ 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_numa_opts(current_machine);
> > >  
> > > @@ -4619,6 +4618,13 @@ int main(int argc, char **argv, char **envp)
> > >          if (cpu_model) {
> > >              current_machine->cpu_type =
> > >                  cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
> > > +
> > > +            /* machine 'none' depends on default cpu type pointer not being
> > > +             * equal to resolved type name pointer to fugure out if type was
> > > +             * user provided, make sure that if it becomes not true in future
> > > +             * it won't beark silently */
> > > +            g_assert(
> > > +                current_machine->cpu_type != machine_class->default_cpu_type);
> > >          }
> > >      }
> > >  
> > > -- 
> > > 2.7.4
> > >   
> > 
> 

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-18 19:18       ` Eduardo Habkost
@ 2018-01-19 10:14         ` Igor Mammedov
  2018-01-19 13:14           ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-19 10:14 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Thu, 18 Jan 2018 17:18:09 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Thu, Jan 18, 2018 at 11:10:35AM +0100, Igor Mammedov wrote:
> > On Wed, 17 Jan 2018 23:48:46 -0200
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> >   
> > > On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:  
> > > > The last user of it was machine type 'none', which used field
> > > > to create CPU id user requested it on CLI with -cpu option.
[...]

> It looks like default_cpu_type is being overloaded for two
> different roles: 1) specifying the default CPU type; 2) finding
> the arch-specific class to be used to parse -cpu.
> 
> In the case of null-machine, these two roles conflict with each
> other.  I believe we can find other solutions instead of this
> hack that involves lying on MachineClass::default_cpu_type (and
> then having to work around the lie on machine_none_init()).
> 
> I see multiple options: adding a new MachineClass field for that
> (e.g.  resolving_cpu_type, which defaults to default_cpu_type if
> NULL); moving the CPU parsing code to arch_init.c (so it could
> use CPU_RESOLVING_TYPE or something similar); adding a optional
> MachineClass::parse_cpu_model hook.  We could even try to get rid
> of CPUClass::parse_features completely
Adding hooks just for the sake on null-machine seems to be overkill,
I'd go for arch_init.c but it won't work for linux-user, how about
exec.c as following:

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 93bd546..0185589 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
[...]

diff --git a/exec.c b/exec.c
index d28fc0c..4543f06 100644
--- a/exec.c
+++ b/exec.c
@@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
 #endif
 }
 
+const char *parse_cpu_model(const char *cpu_model)
+{
+    ObjectClass *oc;
+    CPUClass *cc;
+    gchar **model_pieces;
+    const char *cpu_type;
+
+    model_pieces = g_strsplit(cpu_model, ",", 2);
+
+    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
+    if (oc == NULL) {
+        error_report("unable to find CPU model '%s'", model_pieces[0]);
+        g_strfreev(model_pieces);
+        exit(EXIT_FAILURE);
+    }
+
+    cpu_type = object_class_get_name(oc);
+    cc = CPU_CLASS(oc);
+    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
+    g_strfreev(model_pieces);
+    return cpu_type;
+}
+
 #if defined(CONFIG_USER_ONLY)
 static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
 {
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index 864832d..cde4d3e 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -24,9 +24,9 @@ static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
 
-    /* Initialize CPU (if a model has been specified) */
-    if (mch->cpu_model) {
-        cpu = cpu_init(mch->cpu_model);
+    /* Initialize CPU (if user asked for it) */
+    if (mch->cpu_type) {
+        cpu = cpu_create(mch->cpu_type);
         if (!cpu) {
             error_report("Unable to initialize CPU");
             exit(1);
diff --git a/linux-user/main.c b/linux-user/main.c
index a35477e..0afb3f4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4357,10 +4358,13 @@ int main(int argc, char **argv, char **envp)
         cpu_model = "any";
 #endif
     }
+    cpu_type = parse_cpu_model(cpu_model);
+
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+
+    cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
     cpu_reset(cpu);
 
diff --git a/qom/cpu.c b/qom/cpu.c
index e42d9a7..aab8437 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -67,37 +67,6 @@ CPUState *cpu_create(const char *typename)
     return cpu;
 }
 
-const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
-{
[...]
-}
-
-CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
-{
[...]
-}
-
 bool cpu_paging_enabled(const CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
diff --git a/vl.c b/vl.c
index 2586f25..178bca3 100644
--- a/vl.c
+++ b/vl.c
@@ -4609,17 +4609,13 @@ 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_numa_opts(current_machine);
 
     /* 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);
     }
 
     machine_run_board_init(current_machine);

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-19 10:14         ` Igor Mammedov
@ 2018-01-19 13:14           ` Eduardo Habkost
  2018-01-19 13:39             ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-01-19 13:14 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Fri, Jan 19, 2018 at 11:14:39AM +0100, Igor Mammedov wrote:
> On Thu, 18 Jan 2018 17:18:09 -0200
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Thu, Jan 18, 2018 at 11:10:35AM +0100, Igor Mammedov wrote:
> > > On Wed, 17 Jan 2018 23:48:46 -0200
> > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >   
> > > > On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:  
> > > > > The last user of it was machine type 'none', which used field
> > > > > to create CPU id user requested it on CLI with -cpu option.
> [...]
> 
> > It looks like default_cpu_type is being overloaded for two
> > different roles: 1) specifying the default CPU type; 2) finding
> > the arch-specific class to be used to parse -cpu.
> > 
> > In the case of null-machine, these two roles conflict with each
> > other.  I believe we can find other solutions instead of this
> > hack that involves lying on MachineClass::default_cpu_type (and
> > then having to work around the lie on machine_none_init()).
> > 
> > I see multiple options: adding a new MachineClass field for that
> > (e.g.  resolving_cpu_type, which defaults to default_cpu_type if
> > NULL); moving the CPU parsing code to arch_init.c (so it could
> > use CPU_RESOLVING_TYPE or something similar); adding a optional
> > MachineClass::parse_cpu_model hook.  We could even try to get rid
> > of CPUClass::parse_features completely
> Adding hooks just for the sake on null-machine seems to be overkill,
> I'd go for arch_init.c but it won't work for linux-user, how about
> exec.c as following:
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 93bd546..0185589 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
> [...]
> 
> diff --git a/exec.c b/exec.c
> index d28fc0c..4543f06 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
>  #endif
>  }
>  
> +const char *parse_cpu_model(const char *cpu_model)
> +{
> +    ObjectClass *oc;
> +    CPUClass *cc;
> +    gchar **model_pieces;
> +    const char *cpu_type;
> +
> +    model_pieces = g_strsplit(cpu_model, ",", 2);
> +
> +    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
> +    if (oc == NULL) {
> +        error_report("unable to find CPU model '%s'", model_pieces[0]);
> +        g_strfreev(model_pieces);
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    cpu_type = object_class_get_name(oc);
> +    cc = CPU_CLASS(oc);
> +    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
> +    g_strfreev(model_pieces);
> +    return cpu_type;
> +}

Sounds good to me.  Only two comments:

This looks like duplication of cpu_parse_cpu_model().  Should
this function body be replaced with:
  cpu_parse_cpu_model(CPU_RESOLVING_TYPE, cpu_model)
?

I would move this to arch_init.c, because that's where existing
target-dependent initialization code lives.


> [...]

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-19 13:14           ` Eduardo Habkost
@ 2018-01-19 13:39             ` Igor Mammedov
  2018-01-19 14:23               ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-01-19 13:39 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Fri, 19 Jan 2018 11:14:30 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Fri, Jan 19, 2018 at 11:14:39AM +0100, Igor Mammedov wrote:
> > On Thu, 18 Jan 2018 17:18:09 -0200
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > 
> > > On Thu, Jan 18, 2018 at 11:10:35AM +0100, Igor Mammedov wrote:
> > > > On Wed, 17 Jan 2018 23:48:46 -0200
> > > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > >   
> > > > > On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:  
> > > > > > The last user of it was machine type 'none', which used field
> > > > > > to create CPU id user requested it on CLI with -cpu option.
> > [...]
> > 
> > > It looks like default_cpu_type is being overloaded for two
> > > different roles: 1) specifying the default CPU type; 2) finding
> > > the arch-specific class to be used to parse -cpu.
> > > 
> > > In the case of null-machine, these two roles conflict with each
> > > other.  I believe we can find other solutions instead of this
> > > hack that involves lying on MachineClass::default_cpu_type (and
> > > then having to work around the lie on machine_none_init()).
> > > 
> > > I see multiple options: adding a new MachineClass field for that
> > > (e.g.  resolving_cpu_type, which defaults to default_cpu_type if
> > > NULL); moving the CPU parsing code to arch_init.c (so it could
> > > use CPU_RESOLVING_TYPE or something similar); adding a optional
> > > MachineClass::parse_cpu_model hook.  We could even try to get rid
> > > of CPUClass::parse_features completely
> > Adding hooks just for the sake on null-machine seems to be overkill,
> > I'd go for arch_init.c but it won't work for linux-user, how about
> > exec.c as following:
> > 
> > diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> > index 93bd546..0185589 100644
> > --- a/include/qom/cpu.h
> > +++ b/include/qom/cpu.h
> > @@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
> > [...]
> > 
> > diff --git a/exec.c b/exec.c
> > index d28fc0c..4543f06 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
> >  #endif
> >  }
> >  
> > +const char *parse_cpu_model(const char *cpu_model)
> > +{
> > +    ObjectClass *oc;
> > +    CPUClass *cc;
> > +    gchar **model_pieces;
> > +    const char *cpu_type;
> > +
> > +    model_pieces = g_strsplit(cpu_model, ",", 2);
> > +
> > +    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
> > +    if (oc == NULL) {
> > +        error_report("unable to find CPU model '%s'", model_pieces[0]);
> > +        g_strfreev(model_pieces);
> > +        exit(EXIT_FAILURE);
> > +    }
> > +
> > +    cpu_type = object_class_get_name(oc);
> > +    cc = CPU_CLASS(oc);
> > +    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
> > +    g_strfreev(model_pieces);
> > +    return cpu_type;
> > +}
> 
> Sounds good to me.  Only two comments:
> 
> This looks like duplication of cpu_parse_cpu_model().  Should
> this function body be replaced with:
>   cpu_parse_cpu_model(CPU_RESOLVING_TYPE, cpu_model)
it's cpu_parse_cpu_model() which is moved to exec.c
and first typename argument is replaced by inline CPU_RESOLVING_TYPE


> I would move this to arch_init.c, because that's where existing
> target-dependent initialization code lives.
arch_init.c doesn't fit linux-user, it has only sys emulation code
while exec.c is used by both and still target depended so CPU_RESOLVING_TYPE
could be used there

> 
> 
> > [...]
> 

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

* Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
  2018-01-19 13:39             ` Igor Mammedov
@ 2018-01-19 14:23               ` Eduardo Habkost
  0 siblings, 0 replies; 53+ messages in thread
From: Eduardo Habkost @ 2018-01-19 14:23 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum, Paolo Bonzini

On Fri, Jan 19, 2018 at 02:39:49PM +0100, Igor Mammedov wrote:
> On Fri, 19 Jan 2018 11:14:30 -0200
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Fri, Jan 19, 2018 at 11:14:39AM +0100, Igor Mammedov wrote:
> > > On Thu, 18 Jan 2018 17:18:09 -0200
> > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > 
> > > > On Thu, Jan 18, 2018 at 11:10:35AM +0100, Igor Mammedov wrote:
> > > > > On Wed, 17 Jan 2018 23:48:46 -0200
> > > > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > >   
> > > > > > On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:  
> > > > > > > The last user of it was machine type 'none', which used field
> > > > > > > to create CPU id user requested it on CLI with -cpu option.
> > > [...]
> > > 
> > > > It looks like default_cpu_type is being overloaded for two
> > > > different roles: 1) specifying the default CPU type; 2) finding
> > > > the arch-specific class to be used to parse -cpu.
> > > > 
> > > > In the case of null-machine, these two roles conflict with each
> > > > other.  I believe we can find other solutions instead of this
> > > > hack that involves lying on MachineClass::default_cpu_type (and
> > > > then having to work around the lie on machine_none_init()).
> > > > 
> > > > I see multiple options: adding a new MachineClass field for that
> > > > (e.g.  resolving_cpu_type, which defaults to default_cpu_type if
> > > > NULL); moving the CPU parsing code to arch_init.c (so it could
> > > > use CPU_RESOLVING_TYPE or something similar); adding a optional
> > > > MachineClass::parse_cpu_model hook.  We could even try to get rid
> > > > of CPUClass::parse_features completely
> > > Adding hooks just for the sake on null-machine seems to be overkill,
> > > I'd go for arch_init.c but it won't work for linux-user, how about
> > > exec.c as following:
> > > 
> > > diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> > > index 93bd546..0185589 100644
> > > --- a/include/qom/cpu.h
> > > +++ b/include/qom/cpu.h
> > > @@ -661,8 +661,7 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
> > > [...]
> > > 
> > > diff --git a/exec.c b/exec.c
> > > index d28fc0c..4543f06 100644
> > > --- a/exec.c
> > > +++ b/exec.c
> > > @@ -817,6 +817,29 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
> > >  #endif
> > >  }
> > >  
> > > +const char *parse_cpu_model(const char *cpu_model)
> > > +{
> > > +    ObjectClass *oc;
> > > +    CPUClass *cc;
> > > +    gchar **model_pieces;
> > > +    const char *cpu_type;
> > > +
> > > +    model_pieces = g_strsplit(cpu_model, ",", 2);
> > > +
> > > +    oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
> > > +    if (oc == NULL) {
> > > +        error_report("unable to find CPU model '%s'", model_pieces[0]);
> > > +        g_strfreev(model_pieces);
> > > +        exit(EXIT_FAILURE);
> > > +    }
> > > +
> > > +    cpu_type = object_class_get_name(oc);
> > > +    cc = CPU_CLASS(oc);
> > > +    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
> > > +    g_strfreev(model_pieces);
> > > +    return cpu_type;
> > > +}
> > 
> > Sounds good to me.  Only two comments:
> > 
> > This looks like duplication of cpu_parse_cpu_model().  Should
> > this function body be replaced with:
> >   cpu_parse_cpu_model(CPU_RESOLVING_TYPE, cpu_model)
> it's cpu_parse_cpu_model() which is moved to exec.c
> and first typename argument is replaced by inline CPU_RESOLVING_TYPE
> 
> 
> > I would move this to arch_init.c, because that's where existing
> > target-dependent initialization code lives.
> arch_init.c doesn't fit linux-user, it has only sys emulation code
> while exec.c is used by both and still target depended so CPU_RESOLVING_TYPE
> could be used there

I don't really like adding more code to the mess that is exec.c,
but this looks like the simplest solution.

-- 
Eduardo

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

end of thread, other threads:[~2018-01-19 14:23 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 02/24] alpha: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 03/24] cris: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 04/24] lm32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 05/24] m68k: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 06/24] microblaze: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 07/24] mips: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 08/24] moxie: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 09/24] nios2: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 10/24] openrisc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
2018-01-18  0:30   ` David Gibson
2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
2018-01-17 16:04   ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2018-01-17 19:20     ` Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 13/24] sh4: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 14/24] sparc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
2018-01-17 16:34   ` Bastian Koppelmann
2018-01-17 15:43 ` [Qemu-devel] [PATCH 16/24] unicore32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
2018-01-17 17:35   ` Max Filippov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 19/24] tilegx: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
2018-01-18  1:48   ` Eduardo Habkost
2018-01-18 10:10     ` Igor Mammedov
2018-01-18 19:18       ` Eduardo Habkost
2018-01-19 10:14         ` Igor Mammedov
2018-01-19 13:14           ` Eduardo Habkost
2018-01-19 13:39             ` Igor Mammedov
2018-01-19 14:23               ` Eduardo Habkost
2018-01-17 15:43 ` [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 22/24] cpu: get rid of unused cpu_init() defines Igor Mammedov
2018-01-18  0:28   ` David Gibson
2018-01-18  1:50   ` Eduardo Habkost
2018-01-17 15:43 ` [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init() Igor Mammedov
2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
2018-01-17 19:15   ` Igor Mammedov
2018-01-17 20:30     ` Peter Maydell
2018-01-18 10:43       ` Igor Mammedov
2018-01-18 10:50         ` Peter Maydell
2018-01-18 13:06           ` Igor Mammedov
2018-01-18 13:10             ` Peter Maydell
2018-01-18 13:34               ` Igor Mammedov
2018-01-18 13:36                 ` Peter Maydell
2018-01-18 13:45                   ` Igor Mammedov
2018-01-18 13:49                     ` Peter Maydell
2018-01-18 14:02                       ` Igor Mammedov
2018-01-18 15:31               ` Philippe Mathieu-Daudé
2018-01-18 15:41                 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.