Skip to contentSkip to conversation

target/arm: Allow CONFIG_TCG=n builds

RFC PATCH Superseded Fabiano Rosas 5 participants 18 messages Jan 20, 2023 – Feb 1, 2023 Arm/Amlogic Meson SoC support

v5 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v5 cover target/arm: Allow CONFIG_TCG=n builds

This series makes the necessary changes to allow the use of --disable-tcg for arm.

Based on "target/arm: CONFIG_TCG=n part 1":
https://lore.kernel.org/r/[email protected]

Since v4:

- Used "max" as the default CPU for KVM-only builds. This allows me to drop all the clunky qtest changes and it keeps disabling TCG separate from changing cpu defaults.

I'm neutral towards removing the defaults for arm. We can do that in a separate series. It would be nice to make the TCG default equal to the non-TCG one. Otherwise we're bound to get reports that "this command line used to work" if users switch from: 'CONFIG_TCG=n -accel kvm' to 'CONFIG_TCG=y -accel kvm' (the latter would try to use the cortex-a15 as default).

- Move the ifdef around valid_cpus into the patches that move the respective cpus. Patches 1 & 2.

v4:
https://lore.kernel.org/r/[email protected]

v3:
https://lore.kernel.org/r/[email protected]

v2:
https://lore.kernel.org/r/[email protected]

v1:
https://lore.kernel.org/r/[email protected]

Claudio Fontana (1):
target/arm: move cpu_tcg to tcg/cpu32.c

Fabiano Rosas (8):
target/arm: Move 64-bit TCG CPUs into tcg/
target/arm: Use "max" as default cpu for the virt machine with KVM tests/qtest: arm-cpu-features: Match tests to required accelerators tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG tests/tcg: Do not build/run TCG tests if TCG is disabled target/avocado: Pass parameters to migration test on aarch64 arm/Kconfig: Always select SEMIHOSTING when TCG is present arm/Kconfig: Do not build TCG-only boards on a KVM-only build

 configs/devices/aarch64-softmmu/default.mak |   4 -
 configs/devices/arm-softmmu/default.mak     |  39 --
 configure                                   |   6 +-
 hw/arm/Kconfig                              |  43 +-
 hw/arm/virt.c                               |  10 +-
 target/arm/Kconfig                          |   7 +
 target/arm/cpu64.c                          | 632 +------------------
 target/arm/internals.h                      |   4 +
 target/arm/meson.build                      |   1 -
 target/arm/{cpu_tcg.c => tcg/cpu32.c}       |  13 +-
 target/arm/tcg/cpu64.c                      | 654 ++++++++++++++++++++
 target/arm/tcg/meson.build                  |   2 +
 tests/avocado/migration.py                  |  10 +
 tests/qtest/arm-cpu-features.c              |  34 +-
 tests/qtest/meson.build                     |   4 +-
 15 files changed, 772 insertions(+), 691 deletions(-)
 rename target/arm/{cpu_tcg.c => tcg/cpu32.c} (99%)
 create mode 100644 target/arm/tcg/cpu64.c
Signature · 1 line
2.35.3
#1 lore raw

RFC PATCH v5 1/9 target/arm: Move 64-bit TCG CPUs into tcg/

Move the 64-bit CPUs that are TCG-only:
- cortex-a35
- cortex-a55
- cortex-a72
- cortex-a76
- a64fx
- neoverse-n1

Keep the CPUs that can be used with KVM:
- cortex-a57
- cortex-a53
- max
- host

For the special case "max" CPU, there's a nuance that while KVM/HVF use the "host" model instead, we still cannot move all of the TCG code into the tcg directory because the qtests might reach the !kvm && !hvf branch. Keep the cortex_a57_initfn() call to cover that scenario.

---
First hunk is new.
Fixed missing return statement in aarch64_max_initfn.

---
 hw/arm/virt.c              |   6 +-
 target/arm/cpu64.c         | 632 +----------------------------------
 target/arm/internals.h     |   4 +
 target/arm/tcg/cpu64.c     | 654 +++++++++++++++++++++++++++++++++++++
 target/arm/tcg/meson.build |   1 +
 5 files changed, 675 insertions(+), 622 deletions(-)
 create mode 100644 target/arm/tcg/cpu64.c
hw/arm/virt.c +4 -2
index ea2413a0ba..d243ae28e2 100644
@@ -205,14 +205,16 @@ static const int a15irqmap[] = {
 static const char *valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a7"),
     ARM_CPU_TYPE_NAME("cortex-a15"),
+#ifdef CONFIG_TCG
     ARM_CPU_TYPE_NAME("cortex-a35"),
-    ARM_CPU_TYPE_NAME("cortex-a53"),
     ARM_CPU_TYPE_NAME("cortex-a55"),
-    ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
     ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("a64fx"),
     ARM_CPU_TYPE_NAME("neoverse-n1"),
+#endif
+    ARM_CPU_TYPE_NAME("cortex-a53"),
+    ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("host"),
     ARM_CPU_TYPE_NAME("max"),
 };
target/arm/cpu64.c +12 -620

700 lines not on this page · raw message

target/arm/internals.h +4 -0
index a8fb8aa363..72e3d2fef2 100644
@@ -1364,6 +1364,10 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp);
 void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp);
 void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp);
 void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp);
+void aarch64_max_tcg_initfn(Object *obj);
+void aarch64_add_pauth_properties(Object *obj);
+void aarch64_add_sve_properties(Object *obj);
+void aarch64_add_sme_properties(Object *obj);
 #endif
 
 bool el_is_in_host(CPUARMState *env, int el);
target/arm/tcg/cpu64.c new file +654 -0

654 lines not on this page · raw message

target/arm/tcg/meson.build +1 -0
index 25bc98999e..8debe81fd5 100644
@@ -36,6 +36,7 @@ arm_ss.add(files(
 ))
 
 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
+  'cpu64.c',
   'translate-a64.c',
   'translate-sve.c',
   'translate-sme.c',
Signature · 1 line
2.35.3
#2 lore raw

RFC PATCH v5 2/9 target/arm: move cpu_tcg to tcg/cpu32.c

In reply to Fabiano Rosas

From: Claudio Fontana <[email protected]>

move the module containing cpu models definitions for 32bit TCG-only CPUs to tcg/ and rename it for clarity.

---
First and last hunks are new.

---
 hw/arm/virt.c                         |  2 +-
 target/arm/meson.build                |  1 -
 target/arm/{cpu_tcg.c => tcg/cpu32.c} | 13 +++----------
 target/arm/tcg/cpu64.c                |  2 +-
 target/arm/tcg/meson.build            |  1 +
 tests/qtest/arm-cpu-features.c        | 12 +++++++++---
 6 files changed, 15 insertions(+), 16 deletions(-)
 rename target/arm/{cpu_tcg.c => tcg/cpu32.c} (99%)
hw/arm/virt.c +1 -1
index d243ae28e2..b5c711c919 100644
@@ -203,9 +203,9 @@ static const int a15irqmap[] = {
 };
 
 static const char *valid_cpus[] = {
+#ifdef CONFIG_TCG
     ARM_CPU_TYPE_NAME("cortex-a7"),
     ARM_CPU_TYPE_NAME("cortex-a15"),
-#ifdef CONFIG_TCG
     ARM_CPU_TYPE_NAME("cortex-a35"),
     ARM_CPU_TYPE_NAME("cortex-a55"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
target/arm/meson.build +0 -1
index 595d22a099..88f1a5c570 100644
@@ -5,7 +5,6 @@ arm_ss.add(files(
   'gdbstub.c',
   'helper.c',
   'vfp_helper.c',
-  'cpu_tcg.c',
 ))
 arm_ss.add(zlib)
 
target/arm/tcg/cpu32.c renamed from target/arm/cpu_tcg.c +3 -10
similarity index 99%
rename from target/arm/cpu_tcg.c
rename to target/arm/tcg/cpu32.c
index 64d5a785c1..caa5252ad9 100644
@@ -1,5 +1,5 @@
 /*
- * QEMU ARM TCG CPUs.
+ * QEMU ARM TCG-only CPUs.
  *
  * Copyright (c) 2012 SUSE LINUX Products GmbH
  *
@@ -10,9 +10,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#ifdef CONFIG_TCG
 #include "hw/core/tcg-cpu-ops.h"
-#endif /* CONFIG_TCG */
 #include "internals.h"
 #include "target/arm/idau.h"
 #if !defined(CONFIG_USER_ONLY)
@@ -93,7 +91,7 @@ void aa32_max_features(ARMCPU *cpu)
 /* CPU models. These are not needed for the AArch64 linux-user build. */
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
 
-#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
+#if !defined(CONFIG_USER_ONLY)
 static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 {
     CPUClass *cc = CPU_GET_CLASS(cs);
@@ -117,7 +115,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     }
     return ret;
 }
-#endif /* !CONFIG_USER_ONLY && CONFIG_TCG */
+#endif /* !CONFIG_USER_ONLY */
 
 static void arm926_initfn(Object *obj)
 {
@@ -1013,7 +1011,6 @@ static void pxa270c5_initfn(Object *obj)
     cpu->reset_sctlr = 0x00000078;
 }
 
-#ifdef CONFIG_TCG
 static const struct TCGCPUOps arm_v7m_tcg_ops = {
     .initialize = arm_translate_init,
     .synchronize_from_tb = arm_cpu_synchronize_from_tb,
@@ -1034,7 +1031,6 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = {
     .debug_check_breakpoint = arm_debug_check_breakpoint,
 #endif /* !CONFIG_USER_ONLY */
 };
-#endif /* CONFIG_TCG */
 
 static void arm_v7m_class_init(ObjectClass *oc, void *data)
 {
@@ -1042,10 +1038,7 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
     CPUClass *cc = CPU_CLASS(oc);
 
     acc->info = data;
-#ifdef CONFIG_TCG
     cc->tcg_ops = &arm_v7m_tcg_ops;
-#endif /* CONFIG_TCG */
-
     cc->gdb_core_xml_file = "arm-m-profile.xml";
 }
 
target/arm/tcg/cpu64.c +1 -1
index 4d5bdddae4..92943853ce 100644
@@ -457,7 +457,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj)
 
 /*
  * -cpu max: a CPU with as many features enabled as our emulation supports.
- * The version of '-cpu max' for qemu-system-arm is defined in cpu_tcg.c;
+ * The version of '-cpu max' for qemu-system-arm is defined in cpu32.c;
  * this only needs to handle 64 bits.
  */
 void aarch64_max_tcg_initfn(Object *obj)
target/arm/tcg/meson.build +1 -0
index 8debe81fd5..cea1e594c1 100644
@@ -18,6 +18,7 @@ gen = [
 arm_ss.add(gen)
 
 arm_ss.add(files(
+  'cpu32.c',
   'translate.c',
   'translate-m-nocp.c',
   'translate-mve.c',
tests/qtest/arm-cpu-features.c +9 -3
index 8691802950..4ff2014bea 100644
@@ -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");
 
Signature · 1 line
2.35.3
#3 lore raw

RFC PATCH v5 3/9 target/arm: Use "max" as default cpu for the virt machine with KVM

In reply to Fabiano Rosas

Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a KVM-only build the 'max' cpu.

Note that we cannot use 'host' here because the qtests can run without any other accelerator (than qtest) and 'host' depends on KVM being enabled.

Cc Daniel P. Berrangé <[email protected]>
Cc Thomas Huth <[email protected]>
---
 hw/arm/virt.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/virt.c +4 -0
index b5c711c919..8091c74e3d 100644
@@ -3005,7 +3005,11 @@ 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_node_id = virt_get_default_cpu_node_id;
     mc->kvm_type = virt_kvm_type;
     assert(!mc->get_hotplug_handler);
Signature · 1 line
2.35.3
Acked-by on v5 3/9
#4 lore raw

Re: [RFC PATCH v5 3/9] target/arm: Use "max" as default cpu for the virt machine with KVM

Quoted 7 lines · Fabiano Rosas

Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a KVM-only build the 'max' cpu.

Note that we cannot use 'host' here because the qtests can run without any other accelerator (than qtest) and 'host' depends on KVM being enabled.

Quoted 6 lines
Cc Daniel P. Berrangé<[email protected]>
Cc Thomas Huth<[email protected]>
---
  hw/arm/virt.c | 4 ++++
  1 file changed, 4 insertions(+)

It does seem like that path of least resistance.

r~

Reviewed-by on v5 3/9
#5 lore raw

Re: [RFC PATCH v5 3/9] target/arm: Use "max" as default cpu for the virt machine with KVM

In reply to Fabiano Rosas
Quoted 20 lines · Fabiano Rosas

Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a KVM-only build the 'max' cpu.

Note that we cannot use 'host' here because the qtests can run without any other accelerator (than qtest) and 'host' depends on KVM being enabled.

Cc Daniel P. Berrangé <[email protected]>
Cc Thomas Huth <[email protected]>
---
  hw/arm/virt.c | 4 ++++
  1 file changed, 4 insertions(+)
hw/arm/virt.c +0 -0
index b5c711c919..8091c74e3d 100644
@@ -3005,7 +3005,11 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
      mc->minimum_page_bits = 12;

hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 3015

Quoted 10 lines
hw/arm/virt.c +4 -0
      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_node_id = virt_get_default_cpu_node_id;
      mc->kvm_type = virt_kvm_type;
      assert(!mc->get_hotplug_handler);

Thanks for the update, this sounds like the best option to me.

#6 lore raw

RFC PATCH v5 4/9 tests/qtest: arm-cpu-features: Match tests to required accelerators

In reply to Fabiano Rosas
---
 tests/qtest/arm-cpu-features.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
tests/qtest/arm-cpu-features.c +15 -7
index 4ff2014bea..1555b0bab8 100644
@@ -21,7 +21,7 @@
 #define SVE_MAX_VQ 16
 
 #define MACHINE     "-machine virt,gic-version=max -accel tcg "
-#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg "
+#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
 #define QUERY_HEAD  "{ 'execute': 'query-cpu-model-expansion', " \
                     "  'arguments': { 'type': 'full', "
 #define QUERY_TAIL  "}}"
@@ -613,31 +613,39 @@ int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_data_func("/arm/query-cpu-model-expansion",
-                        NULL, test_query_cpu_model_expansion);
+    if (qtest_has_accel("tcg")) {
+        qtest_add_data_func("/arm/query-cpu-model-expansion",
+                            NULL, test_query_cpu_model_expansion);
+    }
+
+    if (!g_str_equal(qtest_get_arch(), "aarch64")) {
+        goto out;
+    }
 
     /*
      * For now we only run KVM specific tests with AArch64 QEMU in
      * order avoid attempting to run an AArch32 QEMU with KVM on
      * AArch64 hosts. That won't work and isn't easy to detect.
      */
-    if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
+    if (qtest_has_accel("kvm")) {
         /*
          * This tests target the 'host' CPU type, so register it only if
          * KVM is available.
          */
         qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
                             NULL, test_query_cpu_model_expansion_kvm);
+
+        qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
+                            NULL, sve_tests_sve_off_kvm);
     }
 
-    if (g_str_equal(qtest_get_arch(), "aarch64")) {
+    if (qtest_has_accel("tcg")) {
         qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
                             NULL, sve_tests_sve_max_vq_8);
         qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
                             NULL, sve_tests_sve_off);
-        qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
-                            NULL, sve_tests_sve_off_kvm);
     }
 
+out:
     return g_test_run();
 }
Signature · 1 line
2.35.3
#7 lore raw

RFC PATCH v5 5/9 tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG

In reply to Fabiano Rosas

These tests set -accel tcg, so restrict them to when TCG is present.

---
Removed unneeded hunk restricting dependencies
Use config_all instead of config_devices_all to check for TCG

---
 tests/qtest/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/meson.build +2 -2
index 1af63f8bd2..26d8cc4222 100644
@@ -204,8 +204,8 @@ qtests_arm = \
 # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
 qtests_aarch64 = \
   (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) +                            \
-  (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) +        \
-  (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) +  \
+  (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ?            \
+    ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) +                                         \
   (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
   (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) +  \
   ['arm-cpu-features',
Signature · 1 line
2.35.3
#8 lore raw

RFC PATCH v5 6/9 tests/tcg: Do not build/run TCG tests if TCG is disabled

In reply to Fabiano Rosas

The tests under tests/tcg depend on the TCG accelerator. Do not build them if --disable-tcg was given in the configure line.

---
 configure | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
configure +5 -1
index 9e407ce2e3..64960c6000 100755
@@ -2483,7 +2483,11 @@ for target in $target_list; do
       tcg_tests_targets="$tcg_tests_targets $target"
   fi
 done
-echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak)
+
+if test "$tcg" = "enabled"; then
+    echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
+fi
+)
 
 if test "$skip_meson" = no; then
   cross="config-meson.cross.new"
Signature · 1 line
2.35.3
#9 lore raw

RFC PATCH v5 7/9 target/avocado: Pass parameters to migration test on aarch64

In reply to Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

Add these options to the test class in case the test is being executed in an aarch64 host.

---
 tests/avocado/migration.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
tests/avocado/migration.py +10 -0
index 4b25680c50..ffd3db0f35 100644
@@ -11,6 +11,8 @@
 
 
 import tempfile
+import os
+
 from avocado_qemu import QemuSystemTest
 from avocado import skipUnless
 
@@ -26,6 +28,14 @@ class Migration(QemuSystemTest):
 
     timeout = 10
 
+    def setUp(self):
+        super().setUp()
+
+        arch = os.uname()[4]
+        if arch == 'aarch64':
+            self.machine = 'virt'
+            self.cpu = 'max'
+
     @staticmethod
     def migration_finished(vm):
         return vm.command('query-migrate')['status'] in ('completed', 'failed')
Signature · 1 line
2.35.3
Acked-by on v5 7/9
#10 lore raw

Re: [RFC PATCH v5 7/9] target/avocado: Pass parameters to migration test on aarch64

Quoted 4 lines · Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

There was some discussions around that in the past:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/CAFEAcA9NBu+L4wHfkLTv93wy90wjnV05EZ12PT6PmLjdZ5h_YA@mail.gmail.com/

Quoted 2 lines

Add these options to the test class in case the test is being executed in an aarch64 host.

I'm not sure what we are aiming to test here.

Migration in general? If so, any random machine should work. By hardcoding the 'virt' machine, at least this test is reproducible.

I'd rather fix that generically as "if a test requires a default machine and the target doesn't provide any default, then SKIP the test". Then adding machine-specific tests. Can be done on top, so

Quoted 34 lines
---
  tests/avocado/migration.py | 10 ++++++++++
  1 file changed, 10 insertions(+)
tests/avocado/migration.py +10 -0
index 4b25680c50..ffd3db0f35 100644
@@ -11,6 +11,8 @@
 
 
  import tempfile
+import os
+
  from avocado_qemu import QemuSystemTest
  from avocado import skipUnless
 
@@ -26,6 +28,14 @@ class Migration(QemuSystemTest):
 
      timeout = 10
 
+    def setUp(self):
+        super().setUp()
+
+        arch = os.uname()[4]
+        if arch == 'aarch64':
+            self.machine = 'virt'
+            self.cpu = 'max'
+
      @staticmethod
      def migration_finished(vm):
          return vm.command('query-migrate')['status'] in ('completed', 'failed')
#11 lore raw

Re: [RFC PATCH v5 7/9] target/avocado: Pass parameters to migration test on aarch64

Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

There was some discussions around that in the past:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/CAFEAcA9NBu+L4wHfkLTv93wy90wjnV05EZ12PT6PmLjdZ5h_YA@mail.gmail.com/

There's more than one topic being discussed, specially in this last thread, but here's my two cents.

About defaults: It's probably best to be explicit in tests. And if we wanted, have a separate test to make sure the lack of an option still does what it's expected, either outputting a message or behaving the same as the explicit version.

About host architecture-specific tests: Unless we're talking about KVM, I see no point. Having to change hosts to test agnostic features makes no sense (the migration test is one example).

About generic tests: If a feature is required to behave the same for all architectures/machines/cpus then sure. But most low level stuff would be quite dependent on specifics.

Quoted 7 lines
Quoted 2 lines

Add these options to the test class in case the test is being executed in an aarch64 host.

I'm not sure what we are aiming to test here.

Migration in general? If so, any random machine should work. By hardcoding the 'virt' machine, at least this test is reproducible.

Yeah, I cannot say for sure there isn't some machine property that gets transferred during migration. It seemed more conservative to define a specific one.

Quoted 3 lines

I'd rather fix that generically as "if a test requires a default machine and the target doesn't provide any default, then SKIP the test". Then adding machine-specific tests. Can be done on top, so

I agree, but the only tests that should *require* a default are the ones that test the command line parsing or adjacent features. We could always test "-machine foo" and then separately test that the lack of a machine option still gives the Foo machine.

The fact that we sometimes use defaults to be able to have the same-ish command line for every case is more of a limitation of our testing infrastructure in my opinion.

#12 lore raw

Re: [RFC PATCH v5 7/9] target/avocado: Pass parameters to migration test on aarch64

Quoted 31 lines · Fabiano Rosas
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

There was some discussions around that in the past:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/CAFEAcA9NBu+L4wHfkLTv93wy90wjnV05EZ12PT6PmLjdZ5h_YA@mail.gmail.com/

There's more than one topic being discussed, specially in this last thread, but here's my two cents.

About defaults: It's probably best to be explicit in tests. And if we wanted, have a separate test to make sure the lack of an option still does what it's expected, either outputting a message or behaving the same as the explicit version.

About host architecture-specific tests: Unless we're talking about KVM, I see no point. Having to change hosts to test agnostic features makes no sense (the migration test is one example).

About generic tests: If a feature is required to behave the same for all architectures/machines/cpus then sure. But most low level stuff would be quite dependent on specifics.

Quoted 3 lines
Quoted 2 lines

Add these options to the test class in case the test is being executed in an aarch64 host.

Quoted 8 lines
Quoted 4 lines

I'm not sure what we are aiming to test here.

Migration in general? If so, any random machine should work. By hardcoding the 'virt' machine, at least this test is reproducible.

Yeah, I cannot say for sure there isn't some machine property that gets transferred during migration. It seemed more conservative to define a specific one.

Why did you choose 'virt' and not 'xlnx-versal-virt' or 'sbsa-ref'?

What does this test require? Any machine running KVM?

Adding Juan and David for migration since I'm still confused trying to understand what we are trying to test here...

Quoted 12 lines
Quoted 3 lines

I'd rather fix that generically as "if a test requires a default machine and the target doesn't provide any default, then SKIP the test". Then adding machine-specific tests. Can be done on top, so

I agree, but the only tests that should *require* a default are the ones that test the command line parsing or adjacent features. We could always test "-machine foo" and then separately test that the lack of a machine option still gives the Foo machine.

The fact that we sometimes use defaults to be able to have the same-ish command line for every case is more of a limitation of our testing infrastructure in my opinion.

#13 lore raw

Re: [RFC PATCH v5 7/9] target/avocado: Pass parameters to migration test on aarch64

Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 33 lines · Fabiano Rosas
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

There was some discussions around that in the past:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/CAFEAcA9NBu+L4wHfkLTv93wy90wjnV05EZ12PT6PmLjdZ5h_YA@mail.gmail.com/

There's more than one topic being discussed, specially in this last thread, but here's my two cents.

About defaults: It's probably best to be explicit in tests. And if we wanted, have a separate test to make sure the lack of an option still does what it's expected, either outputting a message or behaving the same as the explicit version.

About host architecture-specific tests: Unless we're talking about KVM, I see no point. Having to change hosts to test agnostic features makes no sense (the migration test is one example).

About generic tests: If a feature is required to behave the same for all architectures/machines/cpus then sure. But most low level stuff would be quite dependent on specifics.

Quoted 5 lines
Quoted 2 lines

Add these options to the test class in case the test is being executed in an aarch64 host.

I'm not sure what we are aiming to test here.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Migration in general? If so, any random machine should work. By hardcoding the 'virt' machine, at least this test is reproducible.

Yeah, I cannot say for sure there isn't some machine property that gets transferred during migration. It seemed more conservative to define a specific one.

Why did you choose 'virt' and not 'xlnx-versal-virt' or 'sbsa-ref'?

It is the only one guaranteed to be present with both TCG and KVM.

#14 lore raw

Re: [RFC PATCH v5 7/9] target/avocado: Pass parameters to migration test on aarch64

In reply to Philippe Mathieu-Daudé
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Fabiano Rosas
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Fabiano Rosas

The migration tests are currently broken for an aarch64 host because the tests pass no 'machine' and 'cpu' options on the QEMU command line. Most other architectures define a default value in QEMU for these options, but arm does not.

There was some discussions around that in the past:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/CAFEAcA9NBu+L4wHfkLTv93wy90wjnV05EZ12PT6PmLjdZ5h_YA@mail.gmail.com/

There's more than one topic being discussed, specially in this last thread, but here's my two cents.
About defaults: It's probably best to be explicit in tests. And if we
wanted, have a separate test to make sure the lack of an option still does what it's expected, either outputting a message or behaving the same as the explicit version.
About host architecture-specific tests: Unless we're talking about KVM,
I see no point. Having to change hosts to test agnostic features makes no sense (the migration test is one example).
About generic tests: If a feature is required to behave the same for all
architectures/machines/cpus then sure. But most low level stuff would be quite dependent on specifics.

Quoted 3 lines
Quoted 2 lines

Add these options to the test class in case the test is being executed in an aarch64 host.

Quoted 8 lines
Quoted 4 lines

I'm not sure what we are aiming to test here.

Migration in general? If so, any random machine should work. By hardcoding the 'virt' machine, at least this test is reproducible.

Yeah, I cannot say for sure there isn't some machine property that gets
transferred during migration. It seemed more conservative to define a specific one.

Quoted 6 lines

Why did you choose 'virt' and not 'xlnx-versal-virt' or 'sbsa-ref'?

What does this test require? Any machine running KVM?

Adding Juan and David for migration since I'm still confused trying to understand what we are trying to test here...

No clue really from my side either.

ARM machine types are a mystery. But on one hand:
- arm is a sane architecture when there is no default machine learn x86, learn.
- I don't know either which one to use.

Later, Juan.

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines

I'd rather fix that generically as "if a test requires a default machine and the target doesn't provide any default, then SKIP the test". Then adding machine-specific tests. Can be done on top, so

I agree, but the only tests that should *require* a default are the ones
that test the command line parsing or adjacent features. We could always test "-machine foo" and then separately test that the lack of a machine option still gives the Foo machine.
The fact that we sometimes use defaults to be able to have the same-ish
command line for every case is more of a limitation of our testing infrastructure in my opinion.

#15 lore raw

RFC PATCH v5 8/9 arm/Kconfig: Always select SEMIHOSTING when TCG is present

In reply to Fabiano Rosas

We are about to enable the build without TCG, so CONFIG_SEMIHOSTING and CONFIG_ARM_COMPATIBLE_SEMIHOSTING cannot be unconditionally set in default.mak anymore. So reflect the change in a Kconfig.

Instead of using semihosting/Kconfig, use a target-specific file, so that the change doesn't affect other architectures which might implement semihosting in a way compatible with KVM.

The selection from ARM_v7M needs to be removed to avoid a cycle during parsing.

---
 configs/devices/arm-softmmu/default.mak | 2 --
 hw/arm/Kconfig                          | 1 -
 target/arm/Kconfig                      | 7 +++++++
 3 files changed, 7 insertions(+), 3 deletions(-)
configs/devices/arm-softmmu/default.mak +0 -2
index 1b49a7830c..cb3e5aea65 100644
@@ -40,6 +40,4 @@ CONFIG_MICROBIT=y
 CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
-CONFIG_SEMIHOSTING=y
-CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 CONFIG_ALLWINNER_H3=y
hw/arm/Kconfig +0 -1
index 19d6b9d95f..e0da8841db 100644
@@ -316,7 +316,6 @@ config ARM_V7M
     # currently v7M must be included in a TCG build due to translate.c
     default y if TCG && (ARM || AARCH64)
     select PTIMER
-    select ARM_COMPATIBLE_SEMIHOSTING
 
 config ALLWINNER_A10
     bool
target/arm/Kconfig +7 -0
index 3f3394a22b..39f05b6420 100644
@@ -4,3 +4,10 @@ config ARM
 config AARCH64
     bool
     select ARM
+
+# This config exists just so we can make SEMIHOSTING default when TCG
+# is selected without also changing it for other architectures.
+config ARM_SEMIHOSTING
+    bool
+    default y if TCG && ARM
+    select ARM_COMPATIBLE_SEMIHOSTING
Signature · 1 line
2.35.3
#16 lore raw

RFC PATCH v5 9/9 arm/Kconfig: Do not build TCG-only boards on a KVM-only build

In reply to Fabiano Rosas

Move all the CONFIG_FOO=y from default.mak into "default y if TCG" statements in Kconfig. That way they won't be selected when CONFIG_TCG=n.

I'm leaving CONFIG_ARM_VIRT in default.mak because it allows us to keep the two default.mak files not empty and keep aarch64-default.mak including arm-default.mak. That way we don't surprise anyone that's used to altering these files.

With this change we can start building with --disable-tcg.

---
 configs/devices/aarch64-softmmu/default.mak |  4 --
 configs/devices/arm-softmmu/default.mak     | 37 ------------------
 hw/arm/Kconfig                              | 42 ++++++++++++++++++++-
 3 files changed, 41 insertions(+), 42 deletions(-)
configs/devices/aarch64-softmmu/default.mak +0 -4
index cf43ac8da1..70e05a197d 100644
@@ -2,7 +2,3 @@
 
 # We support all the 32 bit boards so need all their config
 include ../arm-softmmu/default.mak
-
-CONFIG_XLNX_ZYNQMP_ARM=y
-CONFIG_XLNX_VERSAL=y
-CONFIG_SBSA_REF=y
configs/devices/arm-softmmu/default.mak +0 -37
index cb3e5aea65..647fbce88d 100644
@@ -4,40 +4,3 @@
 # CONFIG_TEST_DEVICES=n
 
 CONFIG_ARM_VIRT=y
-CONFIG_CUBIEBOARD=y
-CONFIG_EXYNOS4=y
-CONFIG_HIGHBANK=y
-CONFIG_INTEGRATOR=y
-CONFIG_FSL_IMX31=y
-CONFIG_MUSICPAL=y
-CONFIG_MUSCA=y
-CONFIG_CHEETAH=y
-CONFIG_SX1=y
-CONFIG_NSERIES=y
-CONFIG_STELLARIS=y
-CONFIG_STM32VLDISCOVERY=y
-CONFIG_REALVIEW=y
-CONFIG_VERSATILE=y
-CONFIG_VEXPRESS=y
-CONFIG_ZYNQ=y
-CONFIG_MAINSTONE=y
-CONFIG_GUMSTIX=y
-CONFIG_SPITZ=y
-CONFIG_TOSA=y
-CONFIG_Z2=y
-CONFIG_NPCM7XX=y
-CONFIG_COLLIE=y
-CONFIG_ASPEED_SOC=y
-CONFIG_NETDUINO2=y
-CONFIG_NETDUINOPLUS2=y
-CONFIG_OLIMEX_STM32_H405=y
-CONFIG_MPS2=y
-CONFIG_RASPI=y
-CONFIG_DIGIC=y
-CONFIG_SABRELITE=y
-CONFIG_EMCRAFT_SF2=y
-CONFIG_MICROBIT=y
-CONFIG_FSL_IMX25=y
-CONFIG_FSL_IMX7=y
-CONFIG_FSL_IMX6UL=y
-CONFIG_ALLWINNER_H3=y
hw/arm/Kconfig +41 -1

275 lines not on this page · raw message

Signature · 1 line
2.35.3
#17 lore raw
In reply to Fabiano Rosas
Quoted 57 lines · Fabiano Rosas

This series makes the necessary changes to allow the use of --disable-tcg for arm.

Based on "target/arm: CONFIG_TCG=n part 1":
https://lore.kernel.org/r/[email protected]

Since v4:

- Used "max" as the default CPU for KVM-only builds. This allows me to drop all the clunky qtest changes and it keeps disabling TCG separate from changing cpu defaults.

I'm neutral towards removing the defaults for arm. We can do that in a separate series. It would be nice to make the TCG default equal to the non-TCG one. Otherwise we're bound to get reports that "this command line used to work" if users switch from: 'CONFIG_TCG=n -accel kvm' to 'CONFIG_TCG=y -accel kvm' (the latter would try to use the cortex-a15 as default).

- Move the ifdef around valid_cpus into the patches that move the respective cpus. Patches 1 & 2.

v4:
https://lore.kernel.org/r/[email protected]

v3:
https://lore.kernel.org/r/[email protected]

v2:
https://lore.kernel.org/r/[email protected]

v1:
https://lore.kernel.org/r/[email protected]

Claudio Fontana (1):
target/arm: move cpu_tcg to tcg/cpu32.c

Fabiano Rosas (8):
target/arm: Move 64-bit TCG CPUs into tcg/
target/arm: Use "max" as default cpu for the virt machine with KVM tests/qtest: arm-cpu-features: Match tests to required accelerators tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG tests/tcg: Do not build/run TCG tests if TCG is disabled target/avocado: Pass parameters to migration test on aarch64 arm/Kconfig: Always select SEMIHOSTING when TCG is present arm/Kconfig: Do not build TCG-only boards on a KVM-only build

 configs/devices/aarch64-softmmu/default.mak |   4 -
 configs/devices/arm-softmmu/default.mak     |  39 --
 configure                                   |   6 +-
 hw/arm/Kconfig                              |  43 +-
 hw/arm/virt.c                               |  10 +-
 target/arm/Kconfig                          |   7 +
 target/arm/cpu64.c                          | 632 +------------------
 target/arm/internals.h                      |   4 +
 target/arm/meson.build                      |   1 -
 target/arm/{cpu_tcg.c => tcg/cpu32.c}       |  13 +-
Quoted 8 lines
 target/arm/tcg/cpu64.c                      | 654 ++++++++++++++++++++
 target/arm/tcg/meson.build                  |   2 +
 tests/avocado/migration.py                  |  10 +
 tests/qtest/arm-cpu-features.c              |  34 +-
 tests/qtest/meson.build                     |   4 +-
 15 files changed, 772 insertions(+), 691 deletions(-)
 rename target/arm/{cpu_tcg.c => tcg/cpu32.c} (99%)
 create mode 100644 target/arm/tcg/cpu64.c

Hi,

Peter, Richard,

I assume this series is good to go for the time being?

I have rebased the first part of the patches + this series + Philippe's CI patch, all available here:

https://github.com/farosas/qemu/commits/arm-disable-tcg-max

Let me know if it would help to resend it all as one piece.

Thanks