Skip to contentSkip to conversation

hw/arm/virt: Set default machine and CPU types for mach-virt

PATCH In review Wei Huang 3 participants 6 messages Feb 1, 2018

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

PATCH 1/4 hw/arm/virt: Set default machine and CPU types for mach-virt

Unlike most other QEMU architectures, the default machine type for mach-virt is not set. This causes problems in situations where the default machine types are not provided (e.g. qtest_start() function in many QEMU tests). This patch designates the latest mach-virt machine type (alias of "virt") as the default machine type. It also changes the default CPU depending on the target.

---
 hw/arm/virt.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/arm/virt.c +6 -0
index b334c82..f6b1408 100644
@@ -68,6 +68,7 @@
         mc->desc = "QEMU " # major "." # minor " ARM Virtual Machine"; \
         if (latest) { \
             mc->alias = "virt"; \
+            mc->is_default = 1; \
         } \
     } \
     static const TypeInfo machvirt_##major##_##minor##_info = { \
@@ -1603,7 +1604,12 @@ 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 TARGET_AARCH64
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57");
+#else
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
+#endif
+
     mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
 }
 
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 2/4 tests/boot-serial-test: Add support for the aarch64 virt machine

This patch adds a small binary kernel to test aarch64 virt machine's UART.

---
 tests/Makefile.include   | 1 +
 tests/boot-serial-test.c | 9 +++++++++
 2 files changed, 10 insertions(+)
tests/Makefile.include +1 -0
index ca82e0c..ebdb151 100644
@@ -367,6 +367,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
+check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
tests/boot-serial-test.c +9 -0
index 418c5b9..66f7a84 100644
@@ -55,6 +55,13 @@ static const uint8_t bios_raspi2[] = {
     0x00, 0x10, 0x20, 0x3f,                 /* 0x3f201000 = UART0 base addr */
 };
 
+static const uint8_t kernel_aarch64[] = {
+    0x81, 0x0a, 0x80, 0x52,                 /* mov     w1, #0x54 */
+    0x02, 0x20, 0xa1, 0xd2,                 /* mov     x2, #0x9000000 */
+    0x41, 0x00, 0x00, 0x39,                 /* strb    w1, [x2] */
+    0xfd, 0xff, 0xff, 0x17,                 /* b       -12 (loop) */
+};
+
 typedef struct testdef {
     const char *arch;       /* Target architecture */
     const char *machine;    /* Name of the machine */
@@ -87,6 +94,8 @@ static testdef_t tests[] = {
       sizeof(kernel_plml605), kernel_plml605 },
     { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxiesim },
     { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 },
+    { "aarch64", "virt", "-cpu cortex-a57", "TT", sizeof(kernel_aarch64),
+      kernel_aarch64 },
 
     { NULL }
 };
Signature · 1 line
1.8.3.1
Acked-by on v1 2/4
#2 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH 2/4] tests/boot-serial-test: Add support for the aarch64 virt machine

Quoted 41 lines · Wei Huang

This patch adds a small binary kernel to test aarch64 virt machine's UART.

---
 tests/Makefile.include   | 1 +
 tests/boot-serial-test.c | 9 +++++++++
 2 files changed, 10 insertions(+)
tests/Makefile.include +1 -0
index ca82e0c..ebdb151 100644
@@ -367,6 +367,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
+check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
tests/boot-serial-test.c +7 -0
index 418c5b9..66f7a84 100644
@@ -55,6 +55,13 @@ static const uint8_t bios_raspi2[] = {
     0x00, 0x10, 0x20, 0x3f,                 /* 0x3f201000 = UART0 base addr */
 };
 
+static const uint8_t kernel_aarch64[] = {
+    0x81, 0x0a, 0x80, 0x52,                 /* mov     w1, #0x54 */
+    0x02, 0x20, 0xa1, 0xd2,                 /* mov     x2, #0x9000000 */
+    0x41, 0x00, 0x00, 0x39,                 /* strb    w1, [x2] */
+    0xfd, 0xff, 0xff, 0x17,                 /* b       -12 (loop) */
+};
+
 typedef struct testdef {
     const char *arch;       /* Target architecture */
     const char *machine;    /* Name of the machine */

tests/boot-serial-test.c static testdef_t tests[] = { · line 101

Quoted 8 lines
tests/boot-serial-test.c +2 -0
@@ -87,6 +94,8 @@ static testdef_t tests[] = {
       sizeof(kernel_plml605), kernel_plml605 },
     { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxiesim },
     { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 },
+    { "aarch64", "virt", "-cpu cortex-a57", "TT", sizeof(kernel_aarch64),
+      kernel_aarch64 },
 
     { NULL }
 };
author
#3 lore raw

PATCH 3/4 tests: Enable drive_del-test on arm/aarch64

In reply to Wei Huang
---
 tests/Makefile.include | 2 ++
 tests/drive_del-test.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
tests/Makefile.include +2 -0
index ebdb151..e28277c 100644
@@ -365,9 +365,11 @@ gcov-files-arm-y += arm-softmmu/hw/block/virtio-blk.c
 check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF)
 gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
+check-qtest-arm-y += tests/drive_del-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
+check-qtest-aarch64-y += tests/drive_del-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
tests/drive_del-test.c +2 -1
index c9ac997..2e39442 100644
@@ -123,7 +123,8 @@ int main(int argc, char **argv)
     /* TODO I guess any arch with a hot-pluggable virtio bus would do */
     if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64") ||
         !strcmp(arch, "ppc") || !strcmp(arch, "ppc64") ||
-        !strcmp(arch, "s390x")) {
+        !strcmp(arch, "s390x") || !strcmp(arch, "arm") ||
+        !strcmp(arch, "aarch64")) {
         qtest_add_func("/drive_del/after_failed_device_add",
                        test_after_failed_device_add);
         qtest_add_func("/blockdev/drive_del_device_del",
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH 4/4 tests: Enable xhci test arm/aarch64

In reply to Wei Huang
---
 tests/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
tests/Makefile.include +2 -0
index e28277c..a79a7b8 100644
@@ -366,10 +366,12 @@ check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF)
 gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
 check-qtest-arm-y += tests/drive_del-test$(EXESUF)
+check-qtest-arm-y += tests/usb-hcd-xhci-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/drive_del-test$(EXESUF)
+check-qtest-aarch64-y += tests/usb-hcd-xhci-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
Signature · 1 line
1.8.3.1
#5 lore raw
In reply to Wei Huang
Quoted 2 lines · Wei Huang

Unlike most other QEMU architectures, the default machine type for mach-virt is not set.

This is deliberate. There is no single "right" choice for a machine type for Arm boards. We had a bunch of problems back when we did have a default type, because it was the ancient integratorcp board, and users got confused expecting QEMU to just work without specifying a machine type.

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

Quoted 11 lines

This causes problems in situations where the
default machine types are not provided (e.g. qtest_start() function in many QEMU tests). This patch designates the latest mach-virt machine type (alias of "virt") as the default machine type. It also changes the default CPU depending on the target.

hw/arm/virt.c +4 -0
+#ifdef TARGET_AARCH64
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57");
+#else
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
+#endif

This makes the behaviour be different depending whether you're running qemu-system-arm or qemu-system-aarch64. The two are supposed to behave the same way if you give them the same command line options (like x86 QEMU).

thanks
-- PMM