[PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro

Philippe Mathieu-Daudé posted 10 patches 1 week, 1 day ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Michael Rolnik <mrolnik@gmail.com>, Song Gao <gaosong@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Aurelien Jarno <aurelien@aurel32.net>, Aleksandar Rikalo <arikalo@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro
Posted by Philippe Mathieu-Daudé 1 week, 1 day ago
The x86 target is the single one using the VMSTATE_UINTTL_SUB_ARRAY
macro. Inline it to avoid further uses of this legacy macro on other
targets.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/migration/cpu.h | 4 ----
 target/i386/machine.c   | 6 +++++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index 82a81b5d895..ea411d863ad 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -12,16 +12,12 @@
     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_info_uinttl vmstate_info_uint64
 #else
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     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_info_uinttl vmstate_info_uint32
 #endif
 
diff --git a/target/i386/machine.c b/target/i386/machine.c
index 1f5c517e562..16b65bddcdd 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -1770,7 +1770,11 @@ const VMStateDescription vmstate_x86_cpu = {
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
     .fields = (const VMStateField[]) {
-        VMSTATE_UINTTL_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
+#if TARGET_LONG_BITS == 64
+        VMSTATE_UINT64_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
+#else
+        VMSTATE_UINT32_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
+#endif
         VMSTATE_UINTTL(env.eip, X86CPU),
         VMSTATE_UINTTL(env.eflags, X86CPU),
         VMSTATE_UINT32(env.hflags, X86CPU),
-- 
2.53.0


Re: [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro
Posted by Pierrick Bouvier 1 week, 1 day ago
On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> The x86 target is the single one using the VMSTATE_UINTTL_SUB_ARRAY
> macro. Inline it to avoid further uses of this legacy macro on other
> targets.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h | 4 ----
>   target/i386/machine.c   | 6 +++++-
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/migration/cpu.h b/include/migration/cpu.h
> index 82a81b5d895..ea411d863ad 100644
> --- a/include/migration/cpu.h
> +++ b/include/migration/cpu.h
> @@ -12,16 +12,12 @@
>       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_info_uinttl vmstate_info_uint64
>   #else
>   #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
>       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_info_uinttl vmstate_info_uint32
>   #endif
>   
> diff --git a/target/i386/machine.c b/target/i386/machine.c
> index 1f5c517e562..16b65bddcdd 100644
> --- a/target/i386/machine.c
> +++ b/target/i386/machine.c
> @@ -1770,7 +1770,11 @@ const VMStateDescription vmstate_x86_cpu = {
>       .pre_save = cpu_pre_save,
>       .post_load = cpu_post_load,
>       .fields = (const VMStateField[]) {
> -        VMSTATE_UINTTL_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
> +#if TARGET_LONG_BITS == 64
> +        VMSTATE_UINT64_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
> +#else
> +        VMSTATE_UINT32_SUB_ARRAY(env.regs, X86CPU, 0, CPU_NB_REGS),
> +#endif
>           VMSTATE_UINTTL(env.eip, X86CPU),
>           VMSTATE_UINTTL(env.eflags, X86CPU),
>           VMSTATE_UINT32(env.hflags, X86CPU),

I think it would be better to exclude this patch, and treat 
VMSTATE_UINTTL_SUB_ARRAY with a generic approach, similar to what we 
talked about VMSTATE_UINTTL*.

In short, to add a field to VMStateField, with .target_long = true, that 
indicates to migration code that size should be read from .size / 
target_long_bits().

Regards,
Pierrick