From bb9f99e9baffb050fcddd324b31b20dd0a61adbc Mon Sep 17 00:00:00 2001 From: Zhao Liu Date: Thu, 11 Dec 2025 15:09:35 +0800 Subject: [PATCH] i386/machine: Use VMSTATE_UINTTL_SUB_ARRAY for vmstate of CPUX86State.regs Before expanding the number of elements in the CPUX86State.regs array, first use VMSTATE_UINTTL_SUB_ARRAY for the regs' vmstate to avoid the type_check_array failure. VMSTATE_UINTTL_SUB_ARRAY will also be used for subsequently added elements in regs array. Tested-by: Xudong Hao Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20251211070942.3612547-3-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- include/migration/cpu.h | 4 ++++ target/i386/machine.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/migration/cpu.h b/include/migration/cpu.h index ca7cc0479e..1335abe223 100644 --- a/include/migration/cpu.h +++ b/include/migration/cpu.h @@ -21,6 +21,8 @@ VMSTATE_UINT64_V(_f, _s, _v) #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) +#define VMSTATE_UINTTL_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_UINT64_SUB_ARRAY(_f, _s, _start, _num) #define VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, _v) #define VMSTATE_UINTTL_TEST(_f, _s, _t) \ @@ -40,6 +42,8 @@ VMSTATE_UINT32_V(_f, _s, _v) #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) +#define VMSTATE_UINTTL_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) #define VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) #define VMSTATE_UINTTL_TEST(_f, _s, _t) \ diff --git a/target/i386/machine.c b/target/i386/machine.c index 57a968c30d..0882dc3eb0 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -1748,7 +1748,7 @@ const VMStateDescription vmstate_x86_cpu = { .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (const VMStateField[]) { - VMSTATE_UINTTL_ARRAY(env.regs, X86CPU, CPU_NB_REGS), + VMSTATE_UINTTL_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS), VMSTATE_UINTTL(env.eip, X86CPU), VMSTATE_UINTTL(env.eflags, X86CPU), VMSTATE_UINT32(env.hflags, X86CPU),