Skip to contentSkip to conversation

pull-loongarch-20261118 queue

GIT PULL Applied Bibo Mao 2 participants 4 messages Nov 18

lore
Share & tools
lore

Bibo Mao

author
#0 lore raw

The following changes since commit 6883fb508cb7a93e2e7b44c0582bfd9fc2196d4d:

Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2026-11-17 13:09:47 -0800)

are available in the Git repository at:

https://github.com/bibo-mao/qemu.git tags/pull-loongarch-20261118

for you to fetch changes up to 305a62d8493aece79a523572177eee7ca44e5a85:

target/loongarch: Discard vmstate_tlb field (2026-11-18 09:41:57 +0800)

----------------------------------------------------------------
pull-loongarch-20261118 queue

----------------------------------------------------------------
Bibo Mao (2):
Revert "target/loongarch: Remove TLB entry in vmstate" target/loongarch: Discard vmstate_tlb field

 target/loongarch/machine.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
author
#1 lore raw

[PULL 1/2] Revert "target/loongarch: Remove TLB entry in vmstate"

This reverts commit 9e771d547b72d1eecd962725fad7508af3b97183.

The reverted change drops the vmstate_tlb fields on the assumption that LoongArch guests can rebuild TLB entries from scratch. That assumption is functionally valid, but the change was not gated behind a new machine type, so it altered the migration stream layout of the already-released virt-11.1 machine. As a result, migration from QEMU 11.1 to current master fails.

With the revert applied, migration succeeds with:
(receiver, current master)
qemu-system-loongarch64 -M virt-11.1 -m 256M -display none \
-incoming "exec:cat /tmp/loongarch-virt-11.1.mig" -monitor stdio

using the stream produced by QEMU 11.1 (sender):
qemu-system-loongarch64 -M virt-11.1 -m 256M -display none -monitor stdio (qemu) migrate "exec:cat > /tmp/loongarch-virt-11.1.mig"

Revert restores the virt-11.1 migration layout. If the TLB-dropping optimisation is still desirable, it should be re-introduced behind a new machine type (e.g. virt-11.2) so that existing guests remain migratable.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4879

---
 target/loongarch/machine.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
target/loongarch/machine.c +35 -0
index 4acab2a4a3..957dc2ed71 100644
@@ -175,6 +175,38 @@ static const VMStateDescription vmstate_pmu = {
     },
 };
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
+static bool tlb_needed(void *opaque)
+{
+    return tcg_enabled();
+}
+
+/* TLB state */
+static const VMStateDescription vmstate_tlb_entry = {
+    .name = "cpu/tlb_entry",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT64(tlb_misc, LoongArchTLB),
+        VMSTATE_UINT64(tlb_entry0, LoongArchTLB),
+        VMSTATE_UINT64(tlb_entry1, LoongArchTLB),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_tlb = {
+    .name = "cpu/tlb",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .needed = tlb_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_STRUCT_ARRAY(env.tlb, LoongArchCPU, LOONGARCH_TLB_MAX,
+                             0, vmstate_tlb_entry, LoongArchTLB),
+        VMSTATE_END_OF_LIST()
+    }
+};
+#endif
+
 /* LoongArch CPU state */
 const VMStateDescription vmstate_loongarch_cpu = {
     .name = "cpu",
@@ -251,6 +283,9 @@ const VMStateDescription vmstate_loongarch_cpu = {
         &vmstate_fpu,
         &vmstate_lsx,
         &vmstate_lasx,
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
+        &vmstate_tlb,
+#endif
         &vmstate_lbt,
         &vmstate_msgint,
         &vmstate_pmu,
Signature · 1 line
2.54.0
author
#2 lore raw

[PULL 2/2] target/loongarch: Discard vmstate_tlb field

In reply to Bibo Mao

TLB in destination can reconstruct from scratch, it is not necessary to migrate the TLB entries. Here set return value as false in function tlb_needed(), so that vmstate_tlb field is discard during migration.

---
 target/loongarch/machine.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
target/loongarch/machine.c +5 -1
index 957dc2ed71..a91700cbff 100644
@@ -178,7 +178,11 @@ static const VMStateDescription vmstate_pmu = {
 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool tlb_needed(void *opaque)
 {
-    return tcg_enabled();
+    /*
+     * Not needed, will remove field of vmstate_tlb when virt-11.1 is
+     * deprecated.
+     */
+    return false;
 }
 
 /* TLB state */
Signature · 1 line
2.54.0
#3 lore raw
In reply to Bibo Mao
Quoted 6 lines · Bibo Mao

The following changes since commit 6883fb508cb7a93e2e7b44c0582bfd9fc2196d4d:

   Merge tag 'for-upstream' ofhttps://repo.or.cz/qemu/kevin into staging (2026-11-17 13:09:47 -0800)

are available in the Git repository at:

Quoted 8 lines
   https://github.com/bibo-mao/qemu.git tags/pull-loongarch-20261118

for you to fetch changes up to 305a62d8493aece79a523572177eee7ca44e5a85:

   target/loongarch: Discard vmstate_tlb field (2026-11-18 09:41:57 +0800)

----------------------------------------------------------------
pull-loongarch-20261118 queue

Applied, thanks.

r~