Currently the check of cpreg index matches fail to detect
a situation where the length of both arrays is same but
- destination has an extra register not found in the incoming stream (idx1)
- source has an extra register not found in the destination (idx2)
where idx1 < = idx2
Normally this should fail but it does not.
Fix the logic to scan all indexes.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Fixes: 721fae12536 ("target-arm: Convert TCG to using (index,value) list for cp migration")
---
target/arm/machine.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/target/arm/machine.c b/target/arm/machine.c
index 7a3b5a87932..9297a8f5b41 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -1107,6 +1107,29 @@ static int cpu_post_load(void *opaque, int version_id)
i++;
v++;
}
+ /*
+ * if we have reached the end of the incoming array but there are
+ * still regs in cpreg, continue parsing the regs which are missing
+ * in the input stream
+ */
+ for ( ; i < cpu->cpreg_array_len; 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);
+ }
+ /*
+ * if we have reached the end of the cpreg array but there are
+ * still regs in the input stream, continue parsing the vmstate array
+ */
+ for ( ; v < cpu->cpreg_vmstate_array_len; v++) {
+ g_autofree gchar *name = print_register_name(cpu->cpreg_vmstate_indexes[v]);
+
+ error_report("%s: %s in the incoming stream but unknown on the destination, "
+ "fail migration", __func__, name);
+ fail = true;
+ }
if (fail) {
return -1;
}
--
2.53.0