qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init()
@ 2024-01-23 22:25 Philippe Mathieu-Daudé
  2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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 (here Cortex-A SoC).

Based-on: <20240118200643.29037-1-philmd@linaro.org> (arm-next)

Philippe Mathieu-Daudé (6):
  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/vexpress: Check for CPU types in machine_run_board_init()
  hw/arm/zynq: Check for CPU types in machine_run_board_init()

 hw/arm/exynos4210.c     |  1 +
 hw/arm/exynos4_boards.c |  8 ++++++++
 hw/arm/highbank.c       | 11 +++++++++++
 hw/arm/vexpress.c       | 10 ++++++++++
 hw/arm/xilinx_zynq.c    |  5 +++++
 5 files changed, 35 insertions(+)

-- 
2.41.0



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

* [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:11   ` Richard Henderson
  2024-01-25  2:09   ` Gavin Shan
  2024-01-23 22:25 ` [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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>
---
 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] 20+ messages in thread

* [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:06   ` Richard Henderson
  2024-01-25  2:11   ` Gavin Shan
  2024-01-23 22:25 ` [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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>
---
 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] 20+ messages in thread

* [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
  2024-01-23 22:25 ` [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:11   ` Richard Henderson
  2024-01-25  2:13   ` Gavin Shan
  2024-01-23 22:25 ` [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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>
---
 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] 20+ messages in thread

* [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-01-23 22:25 ` [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:06   ` Richard Henderson
  2024-01-25  2:15   ` Gavin Shan
  2024-01-23 22:25 ` [PATCH v2 5/6] hw/arm/vexpress: " Philippe Mathieu-Daudé
  2024-01-23 22:25 ` [PATCH v2 6/6] hw/arm/zynq: " Philippe Mathieu-Daudé
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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>
---
 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] 20+ messages in thread

* [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2024-01-23 22:25 ` [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:09   ` Richard Henderson
  2024-01-25  2:16   ` Gavin Shan
  2024-01-23 22:25 ` [PATCH v2 6/6] hw/arm/zynq: " Philippe Mathieu-Daudé
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/vexpress.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index f1b45245d5..a3561a1b56 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -783,22 +783,32 @@ 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] 20+ messages in thread

* [PATCH v2 6/6] hw/arm/zynq: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2024-01-23 22:25 ` [PATCH v2 5/6] hw/arm/vexpress: " Philippe Mathieu-Daudé
@ 2024-01-23 22:25 ` Philippe Mathieu-Daudé
  2024-01-24 23:10   ` Richard Henderson
  2024-01-25  2:17   ` Gavin Shan
  5 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-23 22:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov,
	Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/xilinx_zynq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 66d0de139f..6ec65d4780 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -355,6 +355,10 @@ 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;
@@ -362,6 +366,7 @@ static void zynq_machine_class_init(ObjectClass *oc, void *data)
     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] 20+ messages in thread

* Re: [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-24 23:06   ` Richard Henderson
  2024-01-25  2:11   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/exynos4_boards.c | 8 ++++++++
>   1 file changed, 8 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
@ 2024-01-24 23:06   ` Richard Henderson
  2024-01-25  2:15   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/highbank.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 5/6] hw/arm/vexpress: " Philippe Mathieu-Daudé
@ 2024-01-24 23:09   ` Richard Henderson
  2024-01-25  4:49     ` Philippe Mathieu-Daudé
  2024-01-25  2:16   ` Gavin Shan
  1 sibling, 1 reply; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> Restrict MachineClass::valid_cpu_types[] to the single
> valid CPU types.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/vexpress.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index f1b45245d5..a3561a1b56 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -783,22 +783,32 @@ 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;

Repetition of the cpu type here.  Do you still need default_cpu_type?
I didn't see it in the highbank patch, but it might have been outside the patch context.

If it is needed, perhaps "default_cpu_type = valid_cpu_types[0]".

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v2 6/6] hw/arm/zynq: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 6/6] hw/arm/zynq: " Philippe Mathieu-Daudé
@ 2024-01-24 23:10   ` Richard Henderson
  2024-01-25  2:17   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> Restrict MachineClass::valid_cpu_types[] to the single
> valid CPU type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/xilinx_zynq.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index 66d0de139f..6ec65d4780 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -355,6 +355,10 @@ 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;
> @@ -362,6 +366,7 @@ static void zynq_machine_class_init(ObjectClass *oc, void *data)
>       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;

Same comment re default_cpu_type.  Otherwise,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



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

* Re: [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores
  2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-24 23:11   ` Richard Henderson
  2024-01-25  2:09   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/exynos4210.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores
  2024-01-23 22:25 ` [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
@ 2024-01-24 23:11   ` Richard Henderson
  2024-01-25  2:13   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2024-01-24 23:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/highbank.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores
  2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
  2024-01-24 23:11   ` Richard Henderson
@ 2024-01-25  2:09   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/exynos4210.c | 1 +
>   1 file changed, 1 insertion(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-24 23:06   ` Richard Henderson
@ 2024-01-25  2:11   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/exynos4_boards.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores
  2024-01-23 22:25 ` [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
  2024-01-24 23:11   ` Richard Henderson
@ 2024-01-25  2:13   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/highbank.c | 1 +
>   1 file changed, 1 insertion(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
  2024-01-24 23:06   ` Richard Henderson
@ 2024-01-25  2:15   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   hw/arm/highbank.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 5/6] hw/arm/vexpress: " Philippe Mathieu-Daudé
  2024-01-24 23:09   ` Richard Henderson
@ 2024-01-25  2:16   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> Restrict MachineClass::valid_cpu_types[] to the single
> valid CPU types.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/vexpress.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 6/6] hw/arm/zynq: Check for CPU types in machine_run_board_init()
  2024-01-23 22:25 ` [PATCH v2 6/6] hw/arm/zynq: " Philippe Mathieu-Daudé
  2024-01-24 23:10   ` Richard Henderson
@ 2024-01-25  2:17   ` Gavin Shan
  1 sibling, 0 replies; 20+ messages in thread
From: Gavin Shan @ 2024-01-25  2:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Alistair Francis, Igor Mammedov

On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
> Restrict MachineClass::valid_cpu_types[] to the single
> valid CPU type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/xilinx_zynq.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
  2024-01-24 23:09   ` Richard Henderson
@ 2024-01-25  4:49     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-25  4:49 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel
  Cc: Peter Maydell, qemu-arm, Igor Mitsyanko, Rob Herring,
	Joel Stanley, Edgar E. Iglesias, Cédric Le Goater,
	Andrew Jeffery, Gavin Shan, Alistair Francis, Igor Mammedov

On 25/1/24 00:09, Richard Henderson wrote:
> On 1/24/24 08:25, Philippe Mathieu-Daudé wrote:
>> Restrict MachineClass::valid_cpu_types[] to the single
>> valid CPU types.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/arm/vexpress.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
>> index f1b45245d5..a3561a1b56 100644
>> --- a/hw/arm/vexpress.c
>> +++ b/hw/arm/vexpress.c
>> @@ -783,22 +783,32 @@ 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;
> 
> Repetition of the cpu type here.  Do you still need default_cpu_type?
> I didn't see it in the highbank patch, but it might have been outside 
> the patch context.
> 
> If it is needed, perhaps "default_cpu_type = valid_cpu_types[0]".

The plan is to eventually get there applying
https://lore.kernel.org/qemu-devel/20231116163726.28952-1-philmd@linaro.org/

> Otherwise,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Thanks!



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

end of thread, other threads:[~2024-01-25  4:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 22:25 [PATCH v2 0/6] hw/arm/cortex-a: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-23 22:25 ` [PATCH v2 1/6] hw/arm/exynos: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
2024-01-24 23:11   ` Richard Henderson
2024-01-25  2:09   ` Gavin Shan
2024-01-23 22:25 ` [PATCH v2 2/6] hw/arm/exynos: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-24 23:06   ` Richard Henderson
2024-01-25  2:11   ` Gavin Shan
2024-01-23 22:25 ` [PATCH v2 3/6] hw/arm/highbank: Add missing QOM parent for CPU cores Philippe Mathieu-Daudé
2024-01-24 23:11   ` Richard Henderson
2024-01-25  2:13   ` Gavin Shan
2024-01-23 22:25 ` [PATCH v2 4/6] hw/arm/highbank: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-24 23:06   ` Richard Henderson
2024-01-25  2:15   ` Gavin Shan
2024-01-23 22:25 ` [PATCH v2 5/6] hw/arm/vexpress: " Philippe Mathieu-Daudé
2024-01-24 23:09   ` Richard Henderson
2024-01-25  4:49     ` Philippe Mathieu-Daudé
2024-01-25  2:16   ` Gavin Shan
2024-01-23 22:25 ` [PATCH v2 6/6] hw/arm/zynq: " Philippe Mathieu-Daudé
2024-01-24 23:10   ` Richard Henderson
2024-01-25  2:17   ` Gavin Shan

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