diff mbox series

[RFC,v4,03/15] target/arm: Remove default cpu for KVM-only builds

Message ID 20230119135424.5417-4-farosas@suse.de
State New
Headers show
Series target/arm: Allow CONFIG_TCG=n builds | expand

Commit Message

Fabiano Rosas Jan. 19, 2023, 1:54 p.m. UTC
We'd prefer if the user always had to specify the machine and cpu
options in the command line instead of relying on defaults.

Since the KVM build already doesn't work with the current default of
cortex-a15, remove the default altogether for KVM builds.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 hw/arm/virt.c                  |  9 +++++++++
 tests/qtest/arm-cpu-features.c | 12 +++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

Comments

Richard Henderson Jan. 19, 2023, 8:19 p.m. UTC | #1
On 1/19/23 03:54, Fabiano Rosas wrote:
> We'd prefer if the user always had to specify the machine and cpu
> options in the command line instead of relying on defaults.
> 
> Since the KVM build already doesn't work with the current default of
> cortex-a15, remove the default altogether for KVM builds.
> 
> Signed-off-by: Fabiano Rosas<farosas@suse.de>
> ---
>   hw/arm/virt.c                  |  9 +++++++++
>   tests/qtest/arm-cpu-features.c | 12 +++++++++---
>   2 files changed, 18 insertions(+), 3 deletions(-)

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

r~
Daniel P. Berrangé Jan. 20, 2023, 12:24 p.m. UTC | #2
On Thu, Jan 19, 2023 at 10:54:12AM -0300, Fabiano Rosas wrote:
> We'd prefer if the user always had to specify the machine and cpu
> options in the command line instead of relying on defaults.
>
> Since the KVM build already doesn't work with the current default of
> cortex-a15, remove the default altogether for KVM builds.

IMHO not having a working default CPU model is a undesirable
state to be in and user hostile, especially so when it makes
aarch64 be a special case compared to other targets.

Can't we just make 'host' be the default model for KVM, if
the named CPU models don't work ?

With regards,
Daniel
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index ea2413a0ba..fa8baf3156 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -203,8 +203,10 @@  static const int a15irqmap[] = {
 };
 
 static const char *valid_cpus[] = {
+#ifdef CONFIG_TCG
     ARM_CPU_TYPE_NAME("cortex-a7"),
     ARM_CPU_TYPE_NAME("cortex-a15"),
+#endif
     ARM_CPU_TYPE_NAME("cortex-a35"),
     ARM_CPU_TYPE_NAME("cortex-a53"),
     ARM_CPU_TYPE_NAME("cortex-a55"),
@@ -2025,6 +2027,11 @@  static void machvirt_init(MachineState *machine)
     unsigned int smp_cpus = machine->smp.cpus;
     unsigned int max_cpus = machine->smp.max_cpus;
 
+    if (!machine->cpu_type) {
+        error_report("No -cpu specified, and there is no default");
+        exit(1);
+    }
+
     if (!cpu_type_valid(machine->cpu_type)) {
         error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
         exit(1);
@@ -3003,7 +3010,9 @@  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");
+#endif
     mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
     mc->kvm_type = virt_kvm_type;
     assert(!mc->get_hotplug_handler);
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 8691802950..4ff2014bea 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -506,9 +506,15 @@  static void test_query_cpu_model_expansion_kvm(const void *data)
         QDict *resp;
         char *error;
 
-        assert_error(qts, "cortex-a15",
-            "We cannot guarantee the CPU type 'cortex-a15' works "
-            "with KVM on this host", NULL);
+        if (qtest_has_accel("tcg")) {
+            assert_error(qts, "cortex-a15",
+                         "We cannot guarantee the CPU type 'cortex-a15' works "
+                         "with KVM on this host", NULL);
+        } else {
+            assert_error(qts, "cortex-a15",
+                         "The CPU type 'cortex-a15' is not a "
+                         "recognized ARM CPU type", NULL);
+        }
 
         assert_has_feature_enabled(qts, "host", "aarch64");