qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/3] Add migration test for loongarch64
@ 2024-05-11  3:42 Bibo Mao
  2024-05-11  3:42 ` [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1 Bibo Mao
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bibo Mao @ 2024-05-11  3:42 UTC (permalink / raw)
  To: Song Gao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

Migration test case is added for loongarch64 here. Since compat machine
type is required for migration test case, also compat machine qemu 9.1
is added for loongarch virt machine.

Migration test case passes to run in both tcg and kvm mode with the
patch, 54 migration subtests passes in 188 seconds.

---
v4 ... v5:
  1. Rename loongarch virt compat qemu 9.0 with 9.1
  2. Remove default memory size setting and minimum memory size checking

v3 ... v4:
  1. Rename VIRT_MACHINE with LOONGARCH_VIRT_MACHINE since other
architectures have the same machine type.

v2 ... v3:
  1. Refresh the patch based on the latest qemu version, solve the
confliction issue.

v1 ... v2:
  1. Keep the default memory size unchanged with 1GB, only modify minimum
memory size with 256MB
  2. Remove tab char in file tests/migration/loongarch64/a-b-kernel.S
---
Bibo Mao (3):
  hw/loongarch: Add compat machine for 9.1
  hw/loongarch: Remove minimum and default memory size
  tests: Add migration test for loongarch64

 hw/loongarch/virt.c                      | 66 +++++++++++++++++-------
 tests/migration/Makefile                 |  2 +-
 tests/migration/loongarch64/Makefile     | 18 +++++++
 tests/migration/loongarch64/a-b-kernel.S | 49 ++++++++++++++++++
 tests/migration/loongarch64/a-b-kernel.h | 16 ++++++
 tests/migration/migration-test.h         |  3 ++
 tests/qtest/meson.build                  |  2 +-
 tests/qtest/migration-test.c             | 10 ++++
 8 files changed, 146 insertions(+), 20 deletions(-)
 create mode 100644 tests/migration/loongarch64/Makefile
 create mode 100644 tests/migration/loongarch64/a-b-kernel.S
 create mode 100644 tests/migration/loongarch64/a-b-kernel.h


base-commit: dafec285bdbfe415ac6823abdc510e0b92c3f094
-- 
2.39.3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1
  2024-05-11  3:42 [PATCH v5 0/3] Add migration test for loongarch64 Bibo Mao
@ 2024-05-11  3:42 ` Bibo Mao
  2024-05-15  8:30   ` gaosong
  2024-05-11  3:42 ` [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size Bibo Mao
  2024-05-11  3:42 ` [PATCH v5 3/3] tests: Add migration test for loongarch64 Bibo Mao
  2 siblings, 1 reply; 7+ messages in thread
From: Bibo Mao @ 2024-05-11  3:42 UTC (permalink / raw)
  To: Song Gao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

Since migration test case requires compat machine type support,
compat machine is added for qemu 9.1 here.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c | 61 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 48 insertions(+), 13 deletions(-)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index f0640d2d80..f24ff5fcf4 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -1231,18 +1231,53 @@ static void virt_class_init(ObjectClass *oc, void *data)
 #endif
 }
 
-static const TypeInfo virt_machine_types[] = {
-    {
-        .name           = TYPE_LOONGARCH_VIRT_MACHINE,
-        .parent         = TYPE_MACHINE,
-        .instance_size  = sizeof(LoongArchVirtMachineState),
-        .class_init     = virt_class_init,
-        .instance_init  = virt_initfn,
-        .interfaces = (InterfaceInfo[]) {
-         { TYPE_HOTPLUG_HANDLER },
-         { }
-        },
-    }
+#define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
+    static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
+                                                    void *data) \
+    { \
+        MachineClass *mc = MACHINE_CLASS(oc); \
+        virt_machine_##major##_##minor##_options(mc); \
+        mc->desc = "QEMU " # major "." # minor " LoongArch Virtual Machine"; \
+        if (latest) { \
+            mc->alias = "virt"; \
+        } \
+    } \
+    static const TypeInfo machvirt_##major##_##minor##_info = { \
+        .name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \
+        .parent = TYPE_LOONGARCH_VIRT_MACHINE, \
+        .class_init = virt_##major##_##minor##_class_init, \
+    }; \
+    static void machvirt_machine_##major##_##minor##_init(void) \
+    { \
+        type_register_static(&machvirt_##major##_##minor##_info); \
+    } \
+    type_init(machvirt_machine_##major##_##minor##_init);
+
+#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
+    DEFINE_VIRT_MACHINE_LATEST(major, minor, true)
+#define DEFINE_VIRT_MACHINE(major, minor) \
+    DEFINE_VIRT_MACHINE_LATEST(major, minor, false)
+
+static const TypeInfo virt_machine_info = {
+    .name           = TYPE_LOONGARCH_VIRT_MACHINE,
+    .parent         = TYPE_MACHINE,
+    .abstract       = true,
+    .instance_size  = sizeof(LoongArchVirtMachineState),
+    .class_init     = virt_class_init,
+    .instance_init  = virt_initfn,
+    .interfaces = (InterfaceInfo[]) {
+    { TYPE_HOTPLUG_HANDLER },
+    { }
+    },
 };
 
-DEFINE_TYPES(virt_machine_types)
+static void machvirt_machine_init(void)
+{
+    type_register_static(&virt_machine_info);
+}
+type_init(machvirt_machine_init);
+
+static void virt_machine_9_1_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(9, 1)
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size
  2024-05-11  3:42 [PATCH v5 0/3] Add migration test for loongarch64 Bibo Mao
  2024-05-11  3:42 ` [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1 Bibo Mao
@ 2024-05-11  3:42 ` Bibo Mao
  2024-05-15  8:37   ` gaosong
  2024-05-11  3:42 ` [PATCH v5 3/3] tests: Add migration test for loongarch64 Bibo Mao
  2 siblings, 1 reply; 7+ messages in thread
From: Bibo Mao @ 2024-05-11  3:42 UTC (permalink / raw)
  To: Song Gao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

Some qtest test cases such as numa use default memory size of generic
machine class, which is 128M by fault.

Here generic default memory size is used, and also remove minimum memory
size which is 1G originally.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index f24ff5fcf4..d87d9be576 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -890,10 +890,6 @@ static void virt_init(MachineState *machine)
         cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
     }
 
-    if (ram_size < 1 * GiB) {
-        error_report("ram_size must be greater than 1G.");
-        exit(1);
-    }
     create_fdt(lvms);
 
     /* Create IOCSR space */
@@ -1198,7 +1194,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
 
     mc->init = virt_init;
-    mc->default_ram_size = 1 * GiB;
     mc->default_cpu_type = LOONGARCH_CPU_TYPE_NAME("la464");
     mc->default_ram_id = "loongarch.ram";
     mc->max_cpus = LOONGARCH_MAX_CPUS;
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v5 3/3] tests: Add migration test for loongarch64
  2024-05-11  3:42 [PATCH v5 0/3] Add migration test for loongarch64 Bibo Mao
  2024-05-11  3:42 ` [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1 Bibo Mao
  2024-05-11  3:42 ` [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size Bibo Mao
@ 2024-05-11  3:42 ` Bibo Mao
  2024-05-15  8:40   ` gaosong
  2 siblings, 1 reply; 7+ messages in thread
From: Bibo Mao @ 2024-05-11  3:42 UTC (permalink / raw)
  To: Song Gao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

This patch adds migration test support for loongarch64. The test code
comes from aarch64 mostly, only that it booted as bios in qemu since
kernel requires elf format and bios uses binary format.

In addition to providing the binary, this patch also includes the source
code and the build script in tests/migration/loongarch64. So users can
change the source and/or re-compile the binary as they wish.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Thomas Huth <thuth@redhat.com>
Acked-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
---
 tests/migration/Makefile                 |  2 +-
 tests/migration/loongarch64/Makefile     | 18 +++++++++
 tests/migration/loongarch64/a-b-kernel.S | 49 ++++++++++++++++++++++++
 tests/migration/loongarch64/a-b-kernel.h | 16 ++++++++
 tests/migration/migration-test.h         |  3 ++
 tests/qtest/meson.build                  |  2 +-
 tests/qtest/migration-test.c             | 10 +++++
 7 files changed, 98 insertions(+), 2 deletions(-)
 create mode 100644 tests/migration/loongarch64/Makefile
 create mode 100644 tests/migration/loongarch64/a-b-kernel.S
 create mode 100644 tests/migration/loongarch64/a-b-kernel.h

diff --git a/tests/migration/Makefile b/tests/migration/Makefile
index 13e99b1692..cfebfe23f8 100644
--- a/tests/migration/Makefile
+++ b/tests/migration/Makefile
@@ -5,7 +5,7 @@
 # See the COPYING file in the top-level directory.
 #
 
-TARGET_LIST = i386 aarch64 s390x
+TARGET_LIST = i386 aarch64 s390x loongarch64
 
 SRC_PATH = ../..
 
diff --git a/tests/migration/loongarch64/Makefile b/tests/migration/loongarch64/Makefile
new file mode 100644
index 0000000000..5d8719205f
--- /dev/null
+++ b/tests/migration/loongarch64/Makefile
@@ -0,0 +1,18 @@
+# To specify cross compiler prefix, use CROSS_PREFIX=
+#   $ make CROSS_PREFIX=loongarch64-linux-gnu-
+
+.PHONY: all clean
+all: a-b-kernel.h
+
+a-b-kernel.h: loongarch64.kernel
+	echo "$$__note" > $@
+	xxd -i $< | sed -e 's/.*int.*//' >> $@
+
+loongarch64.kernel: loongarch64.elf
+	$(CROSS_PREFIX)objcopy -j .text -O binary $< $@
+
+loongarch64.elf: a-b-kernel.S
+	$(CROSS_PREFIX)gcc -o $@ -nostdlib -Wl,--build-id=none $<
+
+clean:
+	$(RM) *.kernel *.elf
diff --git a/tests/migration/loongarch64/a-b-kernel.S b/tests/migration/loongarch64/a-b-kernel.S
new file mode 100644
index 0000000000..cd543345fe
--- /dev/null
+++ b/tests/migration/loongarch64/a-b-kernel.S
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2024 Loongson Technology Corporation Limited
+ */
+#include "../migration-test.h"
+
+#define LOONGARCH_CSR_CRMD          0
+#define LOONGARCH_VIRT_UART         0x1FE001E0
+.section .text
+
+    .globl  _start
+_start:
+    /* output char 'A' to UART16550 */
+    li.d    $t0, LOONGARCH_VIRT_UART
+    li.w    $t1, 'A'
+    st.b    $t1, $t0, 0
+
+    /* traverse test memory region */
+    li.d    $t0, LOONGARCH_TEST_MEM_START
+    li.d    $t1, LOONGARCH_TEST_MEM_END
+    li.d    $t2, TEST_MEM_PAGE_SIZE
+    li.d    $t4, LOONGARCH_VIRT_UART
+    li.w    $t5, 'B'
+
+clean:
+    st.b    $zero, $t0, 0
+    add.d   $t0,   $t0, $t2
+    bne     $t0,   $t1, clean
+    /* keeps a counter so we can limit the output speed */
+    addi.d  $t6,   $zero, 0
+
+mainloop:
+    li.d    $t0, LOONGARCH_TEST_MEM_START
+
+innerloop:
+    ld.bu   $t3, $t0, 0
+    addi.w  $t3, $t3, 1
+    ext.w.b $t3, $t3
+    st.b    $t3, $t0, 0
+    add.d   $t0, $t0, $t2
+    bne     $t0, $t1, innerloop
+
+    addi.d  $t6, $t6, 1
+    andi    $t6, $t6, 31
+    bnez    $t6, mainloop
+
+    st.b    $t5, $t4, 0
+    b       mainloop
+    nop
diff --git a/tests/migration/loongarch64/a-b-kernel.h b/tests/migration/loongarch64/a-b-kernel.h
new file mode 100644
index 0000000000..b3fe466754
--- /dev/null
+++ b/tests/migration/loongarch64/a-b-kernel.h
@@ -0,0 +1,16 @@
+/* This file is automatically generated from the assembly file in
+* tests/migration/loongarch64. Edit that file and then run "make all"
+* inside tests/migration to update, and then remember to send both
+* the header and the assembler differences in your patch submission.
+*/
+unsigned char loongarch64_kernel[] = {
+  0x0c, 0xc0, 0x3f, 0x14, 0x8c, 0x81, 0x87, 0x03, 0x0d, 0x04, 0x81, 0x03,
+  0x8d, 0x01, 0x00, 0x29, 0x0c, 0x00, 0x04, 0x14, 0x0d, 0x80, 0x0c, 0x14,
+  0x2e, 0x00, 0x00, 0x14, 0x10, 0xc0, 0x3f, 0x14, 0x10, 0x82, 0x87, 0x03,
+  0x11, 0x08, 0x81, 0x03, 0x80, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00,
+  0x8d, 0xf9, 0xff, 0x5f, 0x12, 0x00, 0xc0, 0x02, 0x0c, 0x00, 0x04, 0x14,
+  0x8f, 0x01, 0x00, 0x2a, 0xef, 0x05, 0x80, 0x02, 0xef, 0x5d, 0x00, 0x00,
+  0x8f, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00, 0x8d, 0xed, 0xff, 0x5f,
+  0x52, 0x06, 0xc0, 0x02, 0x52, 0x7e, 0x40, 0x03, 0x5f, 0xde, 0xff, 0x47,
+  0x11, 0x02, 0x00, 0x29, 0xff, 0xd7, 0xff, 0x53, 0x00, 0x00, 0x40, 0x03
+};
diff --git a/tests/migration/migration-test.h b/tests/migration/migration-test.h
index 68512c0b1b..f402e48349 100644
--- a/tests/migration/migration-test.h
+++ b/tests/migration/migration-test.h
@@ -32,4 +32,7 @@
  */
 #define ARM_TEST_MAX_KERNEL_SIZE (512 * 1024)
 
+/* LoongArch64 */
+#define LOONGARCH_TEST_MEM_START (32 * 1024 * 1024)
+#define LOONGARCH_TEST_MEM_END   (100 * 1024 * 1024)
 #endif /* MIGRATION_TEST_H */
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 86293051dc..8d5d8a05d7 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -140,7 +140,7 @@ qtests_hppa = ['boot-serial-test'] + \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
 qtests_loongarch64 = qtests_filter + \
-  ['boot-serial-test']
+  ['boot-serial-test', 'migration-test']
 
 qtests_m68k = ['boot-serial-test'] + \
   qtests_filter
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 7a1345f80f..95bd4e9756 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -128,6 +128,7 @@ static char *bootpath;
 #include "tests/migration/i386/a-b-bootblock.h"
 #include "tests/migration/aarch64/a-b-kernel.h"
 #include "tests/migration/s390x/a-b-bios.h"
+#include "tests/migration/loongarch64/a-b-kernel.h"
 
 static void bootfile_create(char *dir, bool suspend_me)
 {
@@ -154,6 +155,9 @@ static void bootfile_create(char *dir, bool suspend_me)
         content = aarch64_kernel;
         len = sizeof(aarch64_kernel);
         g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
+    } else if (strcmp(arch, "loongarch64") == 0) {
+        content = loongarch64_kernel;
+        len = sizeof(loongarch64_kernel);
     } else {
         g_assert_not_reached();
     }
@@ -750,6 +754,12 @@ static int test_migrate_start(QTestState **from, QTestState **to,
         arch_opts = g_strdup_printf("-cpu max -kernel %s", bootpath);
         start_address = ARM_TEST_MEM_START;
         end_address = ARM_TEST_MEM_END;
+    } else if (strcmp(arch, "loongarch64") == 0) {
+        memory_size = "256M";
+        machine_alias = "virt";
+        arch_opts = g_strdup_printf("-cpu la464 -bios %s", bootpath);
+        start_address = LOONGARCH_TEST_MEM_START;
+        end_address = LOONGARCH_TEST_MEM_END;
     } else {
         g_assert_not_reached();
     }
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1
  2024-05-11  3:42 ` [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1 Bibo Mao
@ 2024-05-15  8:30   ` gaosong
  0 siblings, 0 replies; 7+ messages in thread
From: gaosong @ 2024-05-15  8:30 UTC (permalink / raw)
  To: Bibo Mao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

在 2024/5/11 上午11:42, Bibo Mao 写道:
> Since migration test case requires compat machine type support,
> compat machine is added for qemu 9.1 here.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
>   hw/loongarch/virt.c | 61 +++++++++++++++++++++++++++++++++++----------
>   1 file changed, 48 insertions(+), 13 deletions(-)
>
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index f0640d2d80..f24ff5fcf4 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -1231,18 +1231,53 @@ static void virt_class_init(ObjectClass *oc, void *data)
>   #endif
>   }
>   
> -static const TypeInfo virt_machine_types[] = {
> -    {
> -        .name           = TYPE_LOONGARCH_VIRT_MACHINE,
> -        .parent         = TYPE_MACHINE,
> -        .instance_size  = sizeof(LoongArchVirtMachineState),
> -        .class_init     = virt_class_init,
> -        .instance_init  = virt_initfn,
> -        .interfaces = (InterfaceInfo[]) {
> -         { TYPE_HOTPLUG_HANDLER },
> -         { }
> -        },
> -    }
> +#define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
> +    static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
> +                                                    void *data) \
> +    { \
> +        MachineClass *mc = MACHINE_CLASS(oc); \
> +        virt_machine_##major##_##minor##_options(mc); \
> +        mc->desc = "QEMU " # major "." # minor " LoongArch Virtual Machine"; \
> +        if (latest) { \
> +            mc->alias = "virt"; \
> +        } \
> +    } \
> +    static const TypeInfo machvirt_##major##_##minor##_info = { \
> +        .name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \
> +        .parent = TYPE_LOONGARCH_VIRT_MACHINE, \
> +        .class_init = virt_##major##_##minor##_class_init, \
> +    }; \
> +    static void machvirt_machine_##major##_##minor##_init(void) \
> +    { \
> +        type_register_static(&machvirt_##major##_##minor##_info); \
> +    } \
> +    type_init(machvirt_machine_##major##_##minor##_init);
> +
> +#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
> +    DEFINE_VIRT_MACHINE_LATEST(major, minor, true)
> +#define DEFINE_VIRT_MACHINE(major, minor) \
> +    DEFINE_VIRT_MACHINE_LATEST(major, minor, false)
> +
> +static const TypeInfo virt_machine_info = {
> +    .name           = TYPE_LOONGARCH_VIRT_MACHINE,
> +    .parent         = TYPE_MACHINE,
> +    .abstract       = true,
> +    .instance_size  = sizeof(LoongArchVirtMachineState),
> +    .class_init     = virt_class_init,
> +    .instance_init  = virt_initfn,
> +    .interfaces = (InterfaceInfo[]) {
> +    { TYPE_HOTPLUG_HANDLER },
> +    { }
> +    },
>   };
>   
> -DEFINE_TYPES(virt_machine_types)
> +static void machvirt_machine_init(void)
> +{
> +    type_register_static(&virt_machine_info);
> +}
> +type_init(machvirt_machine_init);
> +
> +static void virt_machine_9_1_options(MachineClass *mc)
> +{
> +}
> +DEFINE_VIRT_MACHINE_AS_LATEST(9, 1)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size
  2024-05-11  3:42 ` [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size Bibo Mao
@ 2024-05-15  8:37   ` gaosong
  0 siblings, 0 replies; 7+ messages in thread
From: gaosong @ 2024-05-15  8:37 UTC (permalink / raw)
  To: Bibo Mao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

在 2024/5/11 上午11:42, Bibo Mao 写道:
> Some qtest test cases such as numa use default memory size of generic
> machine class, which is 128M by fault.
>
> Here generic default memory size is used, and also remove minimum memory
> size which is 1G originally.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
This patch has already appeared in the numa series.

but again.
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
>   hw/loongarch/virt.c | 5 -----
>   1 file changed, 5 deletions(-)
>
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index f24ff5fcf4..d87d9be576 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -890,10 +890,6 @@ static void virt_init(MachineState *machine)
>           cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
>       }
>   
> -    if (ram_size < 1 * GiB) {
> -        error_report("ram_size must be greater than 1G.");
> -        exit(1);
> -    }
>       create_fdt(lvms);
>   
>       /* Create IOCSR space */
> @@ -1198,7 +1194,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
>       HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
>   
>       mc->init = virt_init;
> -    mc->default_ram_size = 1 * GiB;
>       mc->default_cpu_type = LOONGARCH_CPU_TYPE_NAME("la464");
>       mc->default_ram_id = "loongarch.ram";
>       mc->max_cpus = LOONGARCH_MAX_CPUS;



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 3/3] tests: Add migration test for loongarch64
  2024-05-11  3:42 ` [PATCH v5 3/3] tests: Add migration test for loongarch64 Bibo Mao
@ 2024-05-15  8:40   ` gaosong
  0 siblings, 0 replies; 7+ messages in thread
From: gaosong @ 2024-05-15  8:40 UTC (permalink / raw)
  To: Bibo Mao, Peter Xu, Fabiano Rosas, Thomas Huth, Laurent Vivier
  Cc: qemu-devel, Paolo Bonzini

在 2024/5/11 上午11:42, Bibo Mao 写道:
> This patch adds migration test support for loongarch64. The test code
> comes from aarch64 mostly, only that it booted as bios in qemu since
> kernel requires elf format and bios uses binary format.
>
> In addition to providing the binary, this patch also includes the source
> code and the build script in tests/migration/loongarch64. So users can
> change the source and/or re-compile the binary as they wish.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> Acked-by: Thomas Huth <thuth@redhat.com>
> Acked-by: Peter Xu <peterx@redhat.com>
> Reviewed-by: Fabiano Rosas <farosas@suse.de>
> ---
Tested-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
>   tests/migration/Makefile                 |  2 +-
>   tests/migration/loongarch64/Makefile     | 18 +++++++++
>   tests/migration/loongarch64/a-b-kernel.S | 49 ++++++++++++++++++++++++
>   tests/migration/loongarch64/a-b-kernel.h | 16 ++++++++
>   tests/migration/migration-test.h         |  3 ++
>   tests/qtest/meson.build                  |  2 +-
>   tests/qtest/migration-test.c             | 10 +++++
>   7 files changed, 98 insertions(+), 2 deletions(-)
>   create mode 100644 tests/migration/loongarch64/Makefile
>   create mode 100644 tests/migration/loongarch64/a-b-kernel.S
>   create mode 100644 tests/migration/loongarch64/a-b-kernel.h
>
> diff --git a/tests/migration/Makefile b/tests/migration/Makefile
> index 13e99b1692..cfebfe23f8 100644
> --- a/tests/migration/Makefile
> +++ b/tests/migration/Makefile
> @@ -5,7 +5,7 @@
>   # See the COPYING file in the top-level directory.
>   #
>   
> -TARGET_LIST = i386 aarch64 s390x
> +TARGET_LIST = i386 aarch64 s390x loongarch64
>   
>   SRC_PATH = ../..
>   
> diff --git a/tests/migration/loongarch64/Makefile b/tests/migration/loongarch64/Makefile
> new file mode 100644
> index 0000000000..5d8719205f
> --- /dev/null
> +++ b/tests/migration/loongarch64/Makefile
> @@ -0,0 +1,18 @@
> +# To specify cross compiler prefix, use CROSS_PREFIX=
> +#   $ make CROSS_PREFIX=loongarch64-linux-gnu-
> +
> +.PHONY: all clean
> +all: a-b-kernel.h
> +
> +a-b-kernel.h: loongarch64.kernel
> +	echo "$$__note" > $@
> +	xxd -i $< | sed -e 's/.*int.*//' >> $@
> +
> +loongarch64.kernel: loongarch64.elf
> +	$(CROSS_PREFIX)objcopy -j .text -O binary $< $@
> +
> +loongarch64.elf: a-b-kernel.S
> +	$(CROSS_PREFIX)gcc -o $@ -nostdlib -Wl,--build-id=none $<
> +
> +clean:
> +	$(RM) *.kernel *.elf
> diff --git a/tests/migration/loongarch64/a-b-kernel.S b/tests/migration/loongarch64/a-b-kernel.S
> new file mode 100644
> index 0000000000..cd543345fe
> --- /dev/null
> +++ b/tests/migration/loongarch64/a-b-kernel.S
> @@ -0,0 +1,49 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2024 Loongson Technology Corporation Limited
> + */
> +#include "../migration-test.h"
> +
> +#define LOONGARCH_CSR_CRMD          0
> +#define LOONGARCH_VIRT_UART         0x1FE001E0
> +.section .text
> +
> +    .globl  _start
> +_start:
> +    /* output char 'A' to UART16550 */
> +    li.d    $t0, LOONGARCH_VIRT_UART
> +    li.w    $t1, 'A'
> +    st.b    $t1, $t0, 0
> +
> +    /* traverse test memory region */
> +    li.d    $t0, LOONGARCH_TEST_MEM_START
> +    li.d    $t1, LOONGARCH_TEST_MEM_END
> +    li.d    $t2, TEST_MEM_PAGE_SIZE
> +    li.d    $t4, LOONGARCH_VIRT_UART
> +    li.w    $t5, 'B'
> +
> +clean:
> +    st.b    $zero, $t0, 0
> +    add.d   $t0,   $t0, $t2
> +    bne     $t0,   $t1, clean
> +    /* keeps a counter so we can limit the output speed */
> +    addi.d  $t6,   $zero, 0
> +
> +mainloop:
> +    li.d    $t0, LOONGARCH_TEST_MEM_START
> +
> +innerloop:
> +    ld.bu   $t3, $t0, 0
> +    addi.w  $t3, $t3, 1
> +    ext.w.b $t3, $t3
> +    st.b    $t3, $t0, 0
> +    add.d   $t0, $t0, $t2
> +    bne     $t0, $t1, innerloop
> +
> +    addi.d  $t6, $t6, 1
> +    andi    $t6, $t6, 31
> +    bnez    $t6, mainloop
> +
> +    st.b    $t5, $t4, 0
> +    b       mainloop
> +    nop
> diff --git a/tests/migration/loongarch64/a-b-kernel.h b/tests/migration/loongarch64/a-b-kernel.h
> new file mode 100644
> index 0000000000..b3fe466754
> --- /dev/null
> +++ b/tests/migration/loongarch64/a-b-kernel.h
> @@ -0,0 +1,16 @@
> +/* This file is automatically generated from the assembly file in
> +* tests/migration/loongarch64. Edit that file and then run "make all"
> +* inside tests/migration to update, and then remember to send both
> +* the header and the assembler differences in your patch submission.
> +*/
> +unsigned char loongarch64_kernel[] = {
> +  0x0c, 0xc0, 0x3f, 0x14, 0x8c, 0x81, 0x87, 0x03, 0x0d, 0x04, 0x81, 0x03,
> +  0x8d, 0x01, 0x00, 0x29, 0x0c, 0x00, 0x04, 0x14, 0x0d, 0x80, 0x0c, 0x14,
> +  0x2e, 0x00, 0x00, 0x14, 0x10, 0xc0, 0x3f, 0x14, 0x10, 0x82, 0x87, 0x03,
> +  0x11, 0x08, 0x81, 0x03, 0x80, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00,
> +  0x8d, 0xf9, 0xff, 0x5f, 0x12, 0x00, 0xc0, 0x02, 0x0c, 0x00, 0x04, 0x14,
> +  0x8f, 0x01, 0x00, 0x2a, 0xef, 0x05, 0x80, 0x02, 0xef, 0x5d, 0x00, 0x00,
> +  0x8f, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00, 0x8d, 0xed, 0xff, 0x5f,
> +  0x52, 0x06, 0xc0, 0x02, 0x52, 0x7e, 0x40, 0x03, 0x5f, 0xde, 0xff, 0x47,
> +  0x11, 0x02, 0x00, 0x29, 0xff, 0xd7, 0xff, 0x53, 0x00, 0x00, 0x40, 0x03
> +};
> diff --git a/tests/migration/migration-test.h b/tests/migration/migration-test.h
> index 68512c0b1b..f402e48349 100644
> --- a/tests/migration/migration-test.h
> +++ b/tests/migration/migration-test.h
> @@ -32,4 +32,7 @@
>    */
>   #define ARM_TEST_MAX_KERNEL_SIZE (512 * 1024)
>   
> +/* LoongArch64 */
> +#define LOONGARCH_TEST_MEM_START (32 * 1024 * 1024)
> +#define LOONGARCH_TEST_MEM_END   (100 * 1024 * 1024)
>   #endif /* MIGRATION_TEST_H */
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 86293051dc..8d5d8a05d7 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -140,7 +140,7 @@ qtests_hppa = ['boot-serial-test'] + \
>     (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
>   
>   qtests_loongarch64 = qtests_filter + \
> -  ['boot-serial-test']
> +  ['boot-serial-test', 'migration-test']
>   
>   qtests_m68k = ['boot-serial-test'] + \
>     qtests_filter
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index 7a1345f80f..95bd4e9756 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -128,6 +128,7 @@ static char *bootpath;
>   #include "tests/migration/i386/a-b-bootblock.h"
>   #include "tests/migration/aarch64/a-b-kernel.h"
>   #include "tests/migration/s390x/a-b-bios.h"
> +#include "tests/migration/loongarch64/a-b-kernel.h"
>   
>   static void bootfile_create(char *dir, bool suspend_me)
>   {
> @@ -154,6 +155,9 @@ static void bootfile_create(char *dir, bool suspend_me)
>           content = aarch64_kernel;
>           len = sizeof(aarch64_kernel);
>           g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
> +    } else if (strcmp(arch, "loongarch64") == 0) {
> +        content = loongarch64_kernel;
> +        len = sizeof(loongarch64_kernel);
>       } else {
>           g_assert_not_reached();
>       }
> @@ -750,6 +754,12 @@ static int test_migrate_start(QTestState **from, QTestState **to,
>           arch_opts = g_strdup_printf("-cpu max -kernel %s", bootpath);
>           start_address = ARM_TEST_MEM_START;
>           end_address = ARM_TEST_MEM_END;
> +    } else if (strcmp(arch, "loongarch64") == 0) {
> +        memory_size = "256M";
> +        machine_alias = "virt";
> +        arch_opts = g_strdup_printf("-cpu la464 -bios %s", bootpath);
> +        start_address = LOONGARCH_TEST_MEM_START;
> +        end_address = LOONGARCH_TEST_MEM_END;
>       } else {
>           g_assert_not_reached();
>       }



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-15  8:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-11  3:42 [PATCH v5 0/3] Add migration test for loongarch64 Bibo Mao
2024-05-11  3:42 ` [PATCH v5 1/3] hw/loongarch: Add compat machine for 9.1 Bibo Mao
2024-05-15  8:30   ` gaosong
2024-05-11  3:42 ` [PATCH v5 2/3] hw/loongarch: Remove minimum and default memory size Bibo Mao
2024-05-15  8:37   ` gaosong
2024-05-11  3:42 ` [PATCH v5 3/3] tests: Add migration test for loongarch64 Bibo Mao
2024-05-15  8:40   ` gaosong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).