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é <phi...@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.hender...@linaro.org>
r~