From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Bibo Mao" <maobibo@loongson.cn>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Subject: [PULL 06/18] tests/qtest/migration: Add migration test on loongarch
Date: Tue, 23 Jun 2026 08:47:47 -0400 [thread overview]
Message-ID: <20260623124759.125399-7-peterx@redhat.com> (raw)
In-Reply-To: <20260623124759.125399-1-peterx@redhat.com>
From: Bibo Mao <maobibo@loongson.cn>
Add migration qtest on loongarch64 system, the test passes to run with
the following result:
qemu:qtest+qtest-loongarch64/qtest-loongarch64/migration-test OK 15.94s 9 subtests passed
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260611084312.70042-1-maobibo@loongson.cn
Signed-off-by: Peter Xu <peterx@redhat.com>
---
MAINTAINERS | 1 +
tests/qtest/migration/bootfile.h | 4 ++
.../qtest/migration/loongarch64/a-b-kernel.h | 20 ++++++++
tests/qtest/migration/bootfile.c | 4 ++
tests/qtest/migration/framework.c | 6 +++
tests/qtest/meson.build | 3 +-
tests/qtest/migration/Makefile | 4 +-
tests/qtest/migration/loongarch64/Makefile | 20 ++++++++
.../qtest/migration/loongarch64/a-b-kernel.S | 46 +++++++++++++++++++
9 files changed, 106 insertions(+), 2 deletions(-)
create mode 100644 tests/qtest/migration/loongarch64/a-b-kernel.h
create mode 100644 tests/qtest/migration/loongarch64/Makefile
create mode 100644 tests/qtest/migration/loongarch64/a-b-kernel.S
diff --git a/MAINTAINERS b/MAINTAINERS
index 93df53d87f..d609692d9a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1359,6 +1359,7 @@ F: hw/intc/loongarch_*.c
F: hw/intc/loongson_ipi_common.c
F: hw/rtc/ls7a_rtc.c
F: gdbstub/gdb-xml/loongarch*.xml
+F: tests/qtest/migration/loongarch64/
M68K Machines
-------------
diff --git a/tests/qtest/migration/bootfile.h b/tests/qtest/migration/bootfile.h
index 0ce5b34433..a4060ea4f7 100644
--- a/tests/qtest/migration/bootfile.h
+++ b/tests/qtest/migration/bootfile.h
@@ -42,6 +42,10 @@
*/
#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)
+
#ifndef MIGRATION_GUEST_CODE
void bootfile_delete(void);
char *bootfile_create(const char *arch, const char *dir, bool suspend_me);
diff --git a/tests/qtest/migration/loongarch64/a-b-kernel.h b/tests/qtest/migration/loongarch64/a-b-kernel.h
new file mode 100644
index 0000000000..6d5d811f79
--- /dev/null
+++ b/tests/qtest/migration/loongarch64/a-b-kernel.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/*
+ * This file is automatically generated from the assembly file in
+ * tests/qtest/migration/loongarch64. Edit that file and then run "make"
+ * inside tests/qtest/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
+};
+
diff --git a/tests/qtest/migration/bootfile.c b/tests/qtest/migration/bootfile.c
index 479c43231d..e46ad09de7 100644
--- a/tests/qtest/migration/bootfile.c
+++ b/tests/qtest/migration/bootfile.c
@@ -19,6 +19,7 @@
#include "bootfile.h"
#include "i386/a-b-bootblock.h"
#include "aarch64/a-b-kernel.h"
+#include "loongarch64/a-b-kernel.h"
#include "ppc64/a-b-kernel.h"
#include "s390x/a-b-bios.h"
@@ -57,6 +58,9 @@ char *bootfile_create(const char *arch, const 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();
}
diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index a9b58d03aa..a830b96f41 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -360,6 +360,12 @@ int migrate_args(char **from, char **to, MigrateStart *args)
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("-bios %s", bootpath);
+ start_address = LOONGARCH_TEST_MEM_START;
+ end_address = LOONGARCH_TEST_MEM_END;
} else {
g_assert_not_reached();
}
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 4897325d84..e154abb05d 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -155,7 +155,8 @@ qtests_loongarch64 = qtests_filter + \
(config_all_devices.has_key('CONFIG_LOONGARCH_VIRT') ? ['numa-test'] : []) + \
(unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
['boot-serial-test',
- 'cpu-plug-test']
+ 'cpu-plug-test',
+ 'migration-test']
qtests_m68k = ['boot-serial-test'] + \
qtests_filter
diff --git a/tests/qtest/migration/Makefile b/tests/qtest/migration/Makefile
index c183b69941..626e3974f7 100644
--- a/tests/qtest/migration/Makefile
+++ b/tests/qtest/migration/Makefile
@@ -5,7 +5,7 @@
# See the COPYING file in the top-level directory.
#
-TARGET_LIST = i386 aarch64 s390x ppc64
+TARGET_LIST = i386 aarch64 s390x ppc64 loongarch64
SRC_PATH = ../../../..
@@ -23,6 +23,8 @@ help:
@echo " Possible targets are: $(TARGET_LIST)"
override define __note
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
/*
* This file is automatically generated from the assembly file in
* tests/qtest/migration/$@. Edit that file and then run "make"
diff --git a/tests/qtest/migration/loongarch64/Makefile b/tests/qtest/migration/loongarch64/Makefile
new file mode 100644
index 0000000000..3c8cfeee86
--- /dev/null
+++ b/tests/qtest/migration/loongarch64/Makefile
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# 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/qtest/migration/loongarch64/a-b-kernel.S b/tests/qtest/migration/loongarch64/a-b-kernel.S
new file mode 100644
index 0000000000..577d4b238c
--- /dev/null
+++ b/tests/qtest/migration/loongarch64/a-b-kernel.S
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "../bootfile.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
--
2.54.0
next prev parent reply other threads:[~2026-06-23 12:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 12:47 [PULL 00/18] Next patches Peter Xu
2026-06-23 12:47 ` [PULL 01/18] thread-pool: Allow at least 1 thread in thread_pool_adjust_max_threads_to_work() Peter Xu
2026-06-23 12:47 ` [PULL 02/18] qapi/migration: Remove @cpr-exec-command doc in MigrationParameter Peter Xu
2026-06-23 12:47 ` [PULL 03/18] system/physmem: Synchronize ram_list accesses Peter Xu
2026-06-23 12:47 ` [PULL 04/18] system/memory: Remove MAX_PHYS_ADDR Peter Xu
2026-06-23 12:47 ` [PULL 05/18] migration: Use OBJECT_DECLARE_SIMPLE_TYPE Peter Xu
2026-06-23 12:47 ` Peter Xu [this message]
2026-06-23 12:47 ` [PULL 07/18] migration/tests: Update a-b-boot images for all archs Peter Xu
2026-06-23 12:47 ` [PULL 08/18] system/memory: split RamDiscardManager into source and manager Peter Xu
2026-06-23 12:47 ` [PULL 09/18] system/memory: move RamDiscardManager to separate compilation unit Peter Xu
2026-06-23 12:47 ` [PULL 10/18] system/memory: constify section arguments Peter Xu
2026-06-23 12:47 ` [PULL 11/18] system/ram-discard-manager: implement replay via is_populated iteration Peter Xu
2026-06-23 12:47 ` [PULL 12/18] virtio-mem: remove replay_populated/replay_discarded implementation Peter Xu
2026-06-23 12:47 ` [PULL 13/18] system/ram-discard-manager: drop replay from source interface Peter Xu
2026-06-23 12:47 ` [PULL 14/18] system/memory: implement RamDiscardManager multi-source aggregation Peter Xu
2026-06-23 12:47 ` [PULL 15/18] system/physmem: destroy ram block attributes before RCU-deferred reclaim Peter Xu
2026-06-23 12:47 ` [PULL 16/18] system/memory: add RamDiscardManager reference counting and cleanup Peter Xu
2026-06-23 12:47 ` [PULL 17/18] tests: add unit tests for RamDiscardManager multi-source aggregation Peter Xu
2026-06-23 12:47 ` [PULL 18/18] system/physmem: make ram_block_discard_range() handle guest_memfd Peter Xu
2026-06-25 20:26 ` [PULL 00/18] Next patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260623124759.125399-7-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=maobibo@loongson.cn \
--cc=pbonzini@redhat.com \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.