diff mbox series

[RFC,v4,19/19] hw/arm/virt: Get default CPU type at runtime

Message ID 20250422145502.70770-20-philmd@linaro.org
State New
Headers show
Series single-binary: Make hw/arm/ common | expand

Commit Message

Philippe Mathieu-Daudé April 22, 2025, 2:55 p.m. UTC
Prefer MachineClass::get_default_cpu_type() over
MachineClass::default_cpu_type to get CPU type,
evaluating TCG availability at runtime calling
tcg_enabled().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
This removes the last use of CONFIG_TCG in hw/arm/.
---
 hw/arm/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Richard Henderson April 22, 2025, 6:06 p.m. UTC | #1
On 4/22/25 07:55, Philippe Mathieu-Daudé wrote:
> Prefer MachineClass::get_default_cpu_type() over
> MachineClass::default_cpu_type to get CPU type,
> evaluating TCG availability at runtime calling
> tcg_enabled().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> This removes the last use of CONFIG_TCG in hw/arm/.
> ---
>   hw/arm/virt.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 4e11272a3ac..df8dda812cc 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -3131,6 +3131,12 @@ static int virt_hvf_get_physical_address_range(MachineState *ms)
>       return requested_ipa_size;
>   }
>   
> +static const char *virt_get_default_cpu_type(const MachineState *ms)
> +{
> +    return tcg_enabled() ? ARM_CPU_TYPE_NAME("cortex-a15")
> +                         : ARM_CPU_TYPE_NAME("max");
> +}
> +
>   static GSList *virt_get_valid_cpu_types(const MachineState *ms)
>   {
>       GSList *vct = NULL;
> @@ -3188,11 +3194,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
>       mc->minimum_page_bits = 12;
>       mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
>       mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
> -#ifdef CONFIG_TCG
> -    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
> -#else
> -    mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
> -#endif
> +    mc->get_default_cpu_type = virt_get_default_cpu_type;

It's worth noting that this is a behavior change.
Previously only

   ./configure --disable-tcg --enable-kvm
   ./qemu-system-aarch64 -M virt -accel kvm

would default to 'max' and

   ./configure --enable-tcg --enable-kvm
   ./qemu-system-aarch64 -M virt -accel kvm

would default to 'cortex-a15'.
Afterward, -accel kvm will always default to 'max'.

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


r~
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4e11272a3ac..df8dda812cc 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -3131,6 +3131,12 @@  static int virt_hvf_get_physical_address_range(MachineState *ms)
     return requested_ipa_size;
 }
 
+static const char *virt_get_default_cpu_type(const MachineState *ms)
+{
+    return tcg_enabled() ? ARM_CPU_TYPE_NAME("cortex-a15")
+                         : ARM_CPU_TYPE_NAME("max");
+}
+
 static GSList *virt_get_valid_cpu_types(const MachineState *ms)
 {
     GSList *vct = NULL;
@@ -3188,11 +3194,7 @@  static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->minimum_page_bits = 12;
     mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
-#ifdef CONFIG_TCG
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+    mc->get_default_cpu_type = virt_get_default_cpu_type;
     mc->get_valid_cpu_types = virt_get_valid_cpu_types;
     mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
     mc->kvm_type = virt_kvm_type;