qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init()
@ 2024-01-29 15:18 Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 1/9] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé

Series fully reviewed.

Since v2:
- Rebased
- Remove default_cpu_type (Richard)
- Added R-b tags

Since v1:
- Add missing QOM parent for CPU cores
- Dropped Aspeed changes (Cédric)

Following Gavin recent CPU type enforcement cleanups,
restrict more single-CPU ARM machines.

Supersedes: <20240123222508.13826-1-philmd@linaro.org>

Philippe Mathieu-Daudé (9):
  hw/arm/exynos: Add missing QOM parent for CPU cores
  hw/arm/exynos: Check for CPU types in machine_run_board_init()
  hw/arm/highbank: Add missing QOM parent for CPU cores
  hw/arm/highbank: Check for CPU types in machine_run_board_init()
  hw/arm/msf2: Simplify setting MachineClass::valid_cpu_types[]
  hw/arm/musca: Simplify setting MachineClass::valid_cpu_types[]
  hw/arm/npcm7xx_boards: Simplify setting
    MachineClass::valid_cpu_types[]
  hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  hw/arm/zynq: Check for CPU types in machine_run_board_init()

 include/hw/arm/msf2-soc.h |  3 ---
 hw/arm/exynos4210.c       |  1 +
 hw/arm/exynos4_boards.c   |  8 ++++++++
 hw/arm/highbank.c         | 11 +++++++++++
 hw/arm/msf2-soc.c         |  3 +--
 hw/arm/msf2-som.c         |  4 ----
 hw/arm/musca.c            |  1 -
 hw/arm/npcm7xx_boards.c   |  1 -
 hw/arm/vexpress.c         | 12 ++++++++++--
 hw/arm/xilinx_zynq.c      |  6 +++++-
 10 files changed, 36 insertions(+), 14 deletions(-)

-- 
2.41.0



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

* [PATCH v3 1/9] hw/arm/exynos: Add missing QOM parent for CPU cores
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 2/9] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

QDev objects created with qdev_new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
---
 hw/arm/exynos4210.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 6c428d8eeb..57c77b140c 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -556,6 +556,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
     for (n = 0; n < EXYNOS4210_NCPUS; n++) {
         Object *cpuobj = object_new(ARM_CPU_TYPE_NAME("cortex-a9"));
 
+        object_property_add_child(OBJECT(s), "cpu[*]", cpuobj);
         /* By default A9 CPUs have EL3 enabled.  This board does not currently
          * support EL3 so the CPU EL3 property is disabled before realization.
          */
-- 
2.41.0



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

* [PATCH v3 2/9] hw/arm/exynos: Check for CPU types in machine_run_board_init()
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 1/9] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 3/9] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

Restrict MachineClass::valid_cpu_types[] to the single
valid CPU type.

Instead of ignoring invalid CPU type requested by the user:

  $ qemu-system-arm -M nuri -cpu cortex-a7 -S -monitor stdio
  QEMU 8.2.50 monitor - type 'help' for more information
  (qemu) info qom-tree
  /machine (nuri-machine)
    /soc (exynos4210)
      /cpu[0] (cortex-a9-arm-cpu)
      ...

We now display an error:

  $ qemu-system-arm -M nuri -cpu cortex-a7
  qemu-system-arm: Invalid CPU model: cortex-a7
  The only valid type is: cortex-a9

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
---
 hw/arm/exynos4_boards.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index b0e13eb4f0..01c7618a67 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -34,6 +34,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/boards.h"
 #include "hw/irq.h"
+#include "target/arm/cpu-qom.h"
 
 #define SMDK_LAN9118_BASE_ADDR      0x05000000
 
@@ -150,12 +151,18 @@ static void smdkc210_init(MachineState *machine)
     arm_load_kernel(s->soc.cpu[0], machine, &exynos4_board_binfo);
 }
 
+static const char * const valid_cpu_types[] = {
+    ARM_CPU_TYPE_NAME("cortex-a9"),
+    NULL
+};
+
 static void nuri_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Samsung NURI board (Exynos4210)";
     mc->init = nuri_init;
+    mc->valid_cpu_types = valid_cpu_types;
     mc->max_cpus = EXYNOS4210_NCPUS;
     mc->min_cpus = EXYNOS4210_NCPUS;
     mc->default_cpus = EXYNOS4210_NCPUS;
@@ -174,6 +181,7 @@ static void smdkc210_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "Samsung SMDKC210 board (Exynos4210)";
     mc->init = smdkc210_init;
+    mc->valid_cpu_types = valid_cpu_types;
     mc->max_cpus = EXYNOS4210_NCPUS;
     mc->min_cpus = EXYNOS4210_NCPUS;
     mc->default_cpus = EXYNOS4210_NCPUS;
-- 
2.41.0



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

* [PATCH v3 3/9] hw/arm/highbank: Add missing QOM parent for CPU cores
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 1/9] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 2/9] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 4/9] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

QDev objects created with qdev_new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
---
 hw/arm/highbank.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index e6e27d69af..b8d702c82c 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -209,6 +209,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
         cpuobj = object_new(machine->cpu_type);
         cpu = ARM_CPU(cpuobj);
 
+        object_property_add_child(OBJECT(machine), "cpu[*]", cpuobj);
         object_property_set_int(cpuobj, "psci-conduit", QEMU_PSCI_CONDUIT_SMC,
                                 &error_abort);
 
-- 
2.41.0



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

* [PATCH v3 4/9] hw/arm/highbank: Check for CPU types in machine_run_board_init()
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 3/9] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 5/9] hw/arm/msf2: Simplify setting MachineClass::valid_cpu_types[] Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

Restrict MachineClass::valid_cpu_types[] to the single
valid CPU types.

Instead of ignoring invalid CPU type requested by the user:

  $ qemu-system-arm -M midway -cpu cortex-a7 -S -monitor stdio
  QEMU 8.2.50 monitor - type 'help' for more information
  (qemu) info qom-tree
  /machine (midway-machine)
    /cpu[0] (cortex-a15-arm-cpu)
    ...

we now display an error:

  $ qemu-system-arm -M midway -cpu cortex-a7
  qemu-system-arm: Invalid CPU model: cortex-a7
  The only valid type is: cortex-a15

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
---
 hw/arm/highbank.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index b8d702c82c..0367050697 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -345,10 +345,15 @@ static void midway_init(MachineState *machine)
 
 static void highbank_class_init(ObjectClass *oc, void *data)
 {
+    static const char * const valid_cpu_types[] = {
+        ARM_CPU_TYPE_NAME("cortex-a9"),
+        NULL
+    };
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Calxeda Highbank (ECX-1000)";
     mc->init = highbank_init;
+    mc->valid_cpu_types = valid_cpu_types;
     mc->block_default_type = IF_IDE;
     mc->units_per_default_bus = 1;
     mc->max_cpus = 4;
@@ -364,10 +369,15 @@ static const TypeInfo highbank_type = {
 
 static void midway_class_init(ObjectClass *oc, void *data)
 {
+    static const char * const valid_cpu_types[] = {
+        ARM_CPU_TYPE_NAME("cortex-a15"),
+        NULL
+    };
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Calxeda Midway (ECX-2000)";
     mc->init = midway_init;
+    mc->valid_cpu_types = valid_cpu_types;
     mc->block_default_type = IF_IDE;
     mc->units_per_default_bus = 1;
     mc->max_cpus = 4;
-- 
2.41.0



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

* [PATCH v3 5/9] hw/arm/msf2: Simplify setting MachineClass::valid_cpu_types[]
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 4/9] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 6/9] hw/arm/musca: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson

The M2Sxxx SoC family can only be used with Cortex-M3.
Propagating the CPU type from the board level is pointless.

Hard-code the CPU type at the SoC level.
Remove the now ignored MachineClass::default_cpu_type field.

Use the common code introduced in commit c9cf636d48 ("machine: Add
a valid_cpu_types property") to check for valid CPU type at the
board level.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/arm/msf2-soc.h | 3 ---
 hw/arm/msf2-soc.c         | 3 +--
 hw/arm/msf2-som.c         | 4 ----
 3 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
index ce417a6266..9300664e8e 100644
--- a/include/hw/arm/msf2-soc.h
+++ b/include/hw/arm/msf2-soc.h
@@ -47,13 +47,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(MSF2State, MSF2_SOC)
 #define MSF2_NUM_TIMERS       2
 
 struct MSF2State {
-    /*< private >*/
     SysBusDevice parent_obj;
-    /*< public >*/
 
     ARMv7MState armv7m;
 
-    char *cpu_type;
     char *part_name;
     uint64_t envm_size;
     uint64_t esram_size;
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index b5fe9f364d..d6eb9ec9ac 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -134,7 +134,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
 
     armv7m = DEVICE(&s->armv7m);
     qdev_prop_set_uint32(armv7m, "num-irq", 81);
-    qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
+    qdev_prop_set_string(armv7m, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3"));
     qdev_prop_set_bit(armv7m, "enable-bitband", true);
     qdev_connect_clock_in(armv7m, "cpuclk", s->m3clk);
     qdev_connect_clock_in(armv7m, "refclk", s->refclk);
@@ -231,7 +231,6 @@ static Property m2sxxx_soc_properties[] = {
      * part name specifies the type of SmartFusion2 device variant(this
      * property is for information purpose only.
      */
-    DEFINE_PROP_STRING("cpu-type", MSF2State, cpu_type),
     DEFINE_PROP_STRING("part-name", MSF2State, part_name),
     DEFINE_PROP_UINT64("eNVM-size", MSF2State, envm_size, MSF2_ENVM_MAX_SIZE),
     DEFINE_PROP_UINT64("eSRAM-size", MSF2State, esram_size,
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
index a269cf044b..5c415abe85 100644
--- a/hw/arm/msf2-som.c
+++ b/hw/arm/msf2-som.c
@@ -47,7 +47,6 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
     DeviceState *dev;
     DeviceState *spi_flash;
     MSF2State *soc;
-    MachineClass *mc = MACHINE_GET_CLASS(machine);
     DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
     qemu_irq cs_line;
     BusState *spi_bus;
@@ -62,8 +61,6 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
     dev = qdev_new(TYPE_MSF2_SOC);
     object_property_add_child(OBJECT(machine), "soc", OBJECT(dev));
     qdev_prop_set_string(dev, "part-name", "M2S010");
-    qdev_prop_set_string(dev, "cpu-type", mc->default_cpu_type);
-
     qdev_prop_set_uint64(dev, "eNVM-size", M2S010_ENVM_SIZE);
     qdev_prop_set_uint64(dev, "eSRAM-size", M2S010_ESRAM_SIZE);
 
@@ -108,7 +105,6 @@ static void emcraft_sf2_machine_init(MachineClass *mc)
 
     mc->desc = "SmartFusion2 SOM kit from Emcraft (M2S010)";
     mc->init = emcraft_sf2_s2s010_init;
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
     mc->valid_cpu_types = valid_cpu_types;
 }
 
-- 
2.41.0



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

* [PATCH v3 6/9] hw/arm/musca: Simplify setting MachineClass::valid_cpu_types[]
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 5/9] hw/arm/msf2: Simplify setting MachineClass::valid_cpu_types[] Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 7/9] hw/arm/npcm7xx_boards: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson

Musca boards use the embedded subsystems (SSE) tied to a specific
Cortex core. Our models only use the Cortex-M33.

Use the common code introduced in commit c9cf636d48 ("machine: Add
a valid_cpu_types property") to check for valid CPU type at the
board level.

Remove the now unused MachineClass::default_cpu_type field.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/musca.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/arm/musca.c b/hw/arm/musca.c
index 770ec1a15c..e2c9d49af5 100644
--- a/hw/arm/musca.c
+++ b/hw/arm/musca.c
@@ -605,7 +605,6 @@ static void musca_class_init(ObjectClass *oc, void *data)
     mc->default_cpus = 2;
     mc->min_cpus = mc->default_cpus;
     mc->max_cpus = mc->default_cpus;
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33");
     mc->valid_cpu_types = valid_cpu_types;
     mc->init = musca_init;
 }
-- 
2.41.0



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

* [PATCH v3 7/9] hw/arm/npcm7xx_boards: Simplify setting MachineClass::valid_cpu_types[]
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 6/9] hw/arm/musca: " Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 8/9] hw/arm/vexpress: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson

The npcm7xx Soc is created with a Cortex-A9 core, see in
hw/arm/npcm7xx.c:

  static void npcm7xx_init(Object *obj)
  {
      NPCM7xxState *s = NPCM7XX(obj);

      for (int i = 0; i < NPCM7XX_MAX_NUM_CPUS; i++) {
          object_initialize_child(obj, "cpu[*]", &s->cpu[i],
                                  ARM_CPU_TYPE_NAME("cortex-a9"));
      }

The MachineClass::default_cpu_type field is ignored: delete it.

Use the common code introduced in commit c9cf636d48 ("machine: Add
a valid_cpu_types property") to check for valid CPU type at the
board level.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/npcm7xx_boards.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 2999b8b96d..e229efb447 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -465,7 +465,6 @@ static void npcm7xx_machine_class_init(ObjectClass *oc, void *data)
     mc->no_cdrom = 1;
     mc->no_parallel = 1;
     mc->default_ram_id = "ram";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
     mc->valid_cpu_types = valid_cpu_types;
 }
 
-- 
2.41.0



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

* [PATCH v3 8/9] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 7/9] hw/arm/npcm7xx_boards: " Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-01-29 15:18 ` [PATCH v3 9/9] hw/arm/zynq: " Philippe Mathieu-Daudé
  2024-02-01 14:00 ` [PATCH v3 0/9] hw/arm: " Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

Leverage the common code introduced in commit c9cf636d48 ("machine:
Add a valid_cpu_types property") to check for the single valid CPU
type. Remove the now unused MachineClass::default_cpu_type field.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/vexpress.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index f1b45245d5..1a14c1933e 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -783,22 +783,30 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
 
 static void vexpress_a9_class_init(ObjectClass *oc, void *data)
 {
+    static const char * const valid_cpu_types[] = {
+        ARM_CPU_TYPE_NAME("cortex-a9"),
+        NULL
+    };
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
 
     mc->desc = "ARM Versatile Express for Cortex-A9";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+    mc->valid_cpu_types = valid_cpu_types;
 
     vmc->daughterboard = &a9_daughterboard;
 }
 
 static void vexpress_a15_class_init(ObjectClass *oc, void *data)
 {
+    static const char * const valid_cpu_types[] = {
+        ARM_CPU_TYPE_NAME("cortex-a15"),
+        NULL
+    };
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
 
     mc->desc = "ARM Versatile Express for Cortex-A15";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
+    mc->valid_cpu_types = valid_cpu_types;
 
     vmc->daughterboard = &a15_daughterboard;
 
-- 
2.41.0



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

* [PATCH v3 9/9] hw/arm/zynq: Check for CPU types in machine_run_board_init()
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 8/9] hw/arm/vexpress: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-29 15:18 ` Philippe Mathieu-Daudé
  2024-02-01 14:00 ` [PATCH v3 0/9] hw/arm: " Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-29 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Tyrone Ting, Subbaraya Sundeep, Alistair Francis,
	Igor Mitsyanko, Hao Wu, Edgar E. Iglesias, Peter Maydell,
	Rob Herring, Philippe Mathieu-Daudé, Richard Henderson,
	Gavin Shan

Leverage the common code introduced in commit c9cf636d48 ("machine:
Add a valid_cpu_types property") to check for the single valid CPU
type. Remove the now unused MachineClass::default_cpu_type field.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/xilinx_zynq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 66d0de139f..c57bbccb70 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -355,13 +355,17 @@ static void zynq_init(MachineState *machine)
 
 static void zynq_machine_class_init(ObjectClass *oc, void *data)
 {
+    static const char * const valid_cpu_types[] = {
+        ARM_CPU_TYPE_NAME("cortex-a9"),
+        NULL
+    };
     MachineClass *mc = MACHINE_CLASS(oc);
     mc->desc = "Xilinx Zynq Platform Baseboard for Cortex-A9";
     mc->init = zynq_init;
     mc->max_cpus = 1;
     mc->no_sdcard = 1;
     mc->ignore_memory_transaction_failures = true;
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+    mc->valid_cpu_types = valid_cpu_types;
     mc->default_ram_id = "zynq.ext_ram";
 }
 
-- 
2.41.0



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

* Re: [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init()
  2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2024-01-29 15:18 ` [PATCH v3 9/9] hw/arm/zynq: " Philippe Mathieu-Daudé
@ 2024-02-01 14:00 ` Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2024-02-01 14:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, qemu-arm, Tyrone Ting, Subbaraya Sundeep,
	Alistair Francis, Igor Mitsyanko, Hao Wu, Edgar E. Iglesias,
	Rob Herring

On Mon, 29 Jan 2024 at 15:18, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Series fully reviewed.
>
> Since v2:
> - Rebased
> - Remove default_cpu_type (Richard)
> - Added R-b tags
>
> Since v1:
> - Add missing QOM parent for CPU cores
> - Dropped Aspeed changes (Cédric)
>
> Following Gavin recent CPU type enforcement cleanups,
> restrict more single-CPU ARM machines.
>
> Supersedes: <20240123222508.13826-1-philmd@linaro.org>
>



Applied to target-arm.next, thanks.

-- PMM


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

end of thread, other threads:[~2024-02-01 14:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-29 15:18 [PATCH v3 0/9] hw/arm: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 1/9] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 2/9] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 3/9] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 4/9] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 5/9] hw/arm/msf2: Simplify setting MachineClass::valid_cpu_types[] Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 6/9] hw/arm/musca: " Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 7/9] hw/arm/npcm7xx_boards: " Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 8/9] hw/arm/vexpress: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-29 15:18 ` [PATCH v3 9/9] hw/arm/zynq: " Philippe Mathieu-Daudé
2024-02-01 14:00 ` [PATCH v3 0/9] hw/arm: " Peter Maydell

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