Commit e25c63c3b3 for qemu.org

commit e25c63c3b368118dc109e49393554f85f1203d1e
Author: Eric Auger <eric.auger@redhat.com>
Date:   Fri Mar 6 09:01:12 2026 +0000

    target/arm/machine: Trace all register mismatches

    At the moment, cpu_post_load() exits with error on the first
    catch of unexpected register in the incoming stream. Let the code
    go further and trace all the issues before exiting.

    Signed-off-by: Eric Auger <eric.auger@redhat.com>
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Message-id: 20260304101625.1962633-7-eric.auger@redhat.com
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

diff --git a/target/arm/machine.c b/target/arm/machine.c
index d9b65b5eed..4d9158e697 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -1061,6 +1061,7 @@ static int cpu_post_load(void *opaque, int version_id)
 {
     ARMCPU *cpu = opaque;
     CPUARMState *env = &cpu->env;
+    bool fail = false;
     int i, v;

     trace_cpu_post_load(cpu->cpreg_vmstate_array_len,
@@ -1093,13 +1094,14 @@ static int cpu_post_load(void *opaque, int version_id)
      */

     for (i = 0, v = 0; i < cpu->cpreg_array_len
-             && v < cpu->cpreg_vmstate_array_len; i++) {
+             && v < cpu->cpreg_vmstate_array_len;) {
         if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) {
             g_autofree gchar *name = print_register_name(cpu->cpreg_indexes[i]);

             warn_report("%s: %s "
                         "expected by the destination but not in the incoming stream: "
                         "skip it", __func__, name);
+            i++;
             continue;
         }
         if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) {
@@ -1107,12 +1109,18 @@ static int cpu_post_load(void *opaque, int version_id)

             error_report("%s: %s in the incoming stream but unknown on the destination: "
                          "fail migration", __func__, name);
-            return -1;
+            v++;
+            fail = true;
+            continue;
         }
         /* matching register, copy the value over */
         cpu->cpreg_values[i] = cpu->cpreg_vmstate_values[v];
+        i++;
         v++;
     }
+    if (fail) {
+        return -1;
+    }

     if (kvm_enabled()) {
         if (!kvm_arm_cpu_post_load(cpu)) {