[PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()

Philippe Mathieu-Daudé posted 6 patches 10 months, 1 week ago
Maintainers: Igor Mitsyanko <i.mitsyanko@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Rob Herring <robh@kernel.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>
There is a newer version of this series
[PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
Posted by Philippe Mathieu-Daudé 10 months, 1 week ago
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


Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
Posted by Gavin Shan 10 months ago
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>


Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
Posted by Richard Henderson 10 months ago
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~

Re: [PATCH v2 5/6] hw/arm/vexpress: Check for CPU types in machine_run_board_init()
Posted by Philippe Mathieu-Daudé 10 months ago
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!