From: Philippe Mathieu-Daudé Date: Tue, 22 Apr 2025 09:42:19 +0000 (+0200) Subject: hw/arm/virt: Check accelerator availability at runtime X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f5791334ed83b0b25c17d7cac29d583848ecad6;p=thirdparty%2Fqemu.git hw/arm/virt: Check accelerator availability at runtime It is not possible to call accelerator runtime helpers when QOM types are registered, because they depend on the parsing of the '-accel FOO' command line option, which happens after main(). Now than get_valid_cpu_types() is called after accelerator initializations, it is safe to call the accelerator helpers: main + configure_accelerators + qmp_x_exit_preconfig + qemu_init_board + machine_run_board_init + is_cpu_type_supported Replace compile-time check on CONFIG_{ACCEL} by runtime check on {accel}_enabled() helpers. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Peter Maydell Message-Id: <20251021210840.60112-1-philmd@linaro.org> --- diff --git a/hw/arm/virt.c b/hw/arm/virt.c index e19da6fd90..d380975446 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3260,7 +3260,7 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms) { GPtrArray *vct = g_ptr_array_new_with_free_func(g_free); -#ifdef CONFIG_TCG + if (tcg_enabled()) { g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a7"))); g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a15"))); #ifdef TARGET_AARCH64 @@ -3274,13 +3274,13 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms) g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("neoverse-v1"))); g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("neoverse-n2"))); #endif /* TARGET_AARCH64 */ -#endif /* CONFIG_TCG */ + } #ifdef TARGET_AARCH64 g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a53"))); g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a57"))); -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) + if (kvm_enabled() || hvf_enabled()) { g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("host"))); -#endif /* CONFIG_KVM || CONFIG_HVF */ + } #endif /* TARGET_AARCH64 */ g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("max")));