public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros
@ 2026-03-25 21:17 Philippe Mathieu-Daudé
  2026-03-25 21:17 ` [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c Philippe Mathieu-Daudé
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé

For the single binary (read heterogeneous emulation) project
we are trying to remove the uses of the 'target_ulong' type
in common code (or code that should be common code but is
compiled a target-specific one).

This series aims to reduce the use of migration target-specific
macros. Since there is still a lot of work to be done, we
introduce the TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
definition to protect the targets which are already not using
these legacy migration macros.

Except for the SPARC targets, there should be no functional
change.

Philippe Mathieu-Daudé (10):
  target/avr: Avoid target-specific migration headers in machine.c
  target/loongarch: Avoid target-specific migration headers in machine.c
  migration: Revert "Add VMSTATE_UINTTL_2DARRAY()"
  migration: Remove unused target-specific macros
  target/sparc: Inline qemu_get/put_betl()
  target/mips: Inline qemu_get/put_betls()
  target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers
  target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro
  target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY
  migration: Restrict legacy VMSTATE_UINTTL() macros to few targets

 configs/targets/i386-softmmu.mak     |  1 +
 configs/targets/mips-softmmu.mak     |  1 +
 configs/targets/mips64-softmmu.mak   |  1 +
 configs/targets/mips64el-softmmu.mak |  1 +
 configs/targets/mipsel-softmmu.mak   |  1 +
 configs/targets/ppc-softmmu.mak      |  1 +
 configs/targets/ppc64-softmmu.mak    |  1 +
 configs/targets/riscv32-softmmu.mak  |  1 +
 configs/targets/riscv64-softmmu.mak  |  1 +
 configs/targets/sparc-softmmu.mak    |  1 +
 configs/targets/sparc64-softmmu.mak  |  1 +
 configs/targets/x86_64-softmmu.mak   |  1 +
 include/migration/cpu.h              | 59 ++++++----------------------
 include/migration/vmstate.h          | 22 ++---------
 migration/vmstate.c                  |  4 --
 target/avr/machine.c                 |  3 +-
 target/i386/machine.c                |  8 +++-
 target/loongarch/machine.c           |  2 +-
 target/mips/system/machine.c         | 14 ++++++-
 target/ppc/machine.c                 |  1 +
 target/sparc/machine.c               | 24 +++++++----
 scripts/make-config-poison.sh        |  1 +
 target/avr/meson.build               |  3 +-
 target/loongarch/meson.build         |  2 +-
 24 files changed, 67 insertions(+), 88 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:39   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 02/10] target/loongarch: " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Michael Rolnik

machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum headers required:
"migration/qemu-file-types.h" and "migration/vmstate.h", which
are not target-specific. This allows to build this file as
common object.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/avr/machine.c   | 3 ++-
 target/avr/meson.build | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/avr/machine.c b/target/avr/machine.c
index 4402862fb96..8064a7214a3 100644
--- a/target/avr/machine.c
+++ b/target/avr/machine.c
@@ -20,7 +20,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 static int get_sreg(QEMUFile *f, void *opaque, size_t size,
                     const VMStateField *field)
diff --git a/target/avr/meson.build b/target/avr/meson.build
index af5e7d63741..39e5eb02c2b 100644
--- a/target/avr/meson.build
+++ b/target/avr/meson.build
@@ -15,8 +15,7 @@ avr_ss.add(files(
 
 avr_common_system_ss = ss.source_set()
 avr_common_system_ss.add(files('gdbstub.c'))
-
-avr_system_ss.add(files('machine.c'))
+avr_common_system_ss.add(files('machine.c'))
 
 target_arch += {'avr': avr_ss}
 target_system_arch += {'avr': avr_system_ss}
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 02/10] target/loongarch: Avoid target-specific migration headers in machine.c
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
  2026-03-25 21:17 ` [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:39   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()" Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Song Gao

machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum header required:
"migration/qemu-file-types.h" which is not target-specific.
This allows to build this file as common object.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/loongarch/machine.c   | 2 +-
 target/loongarch/meson.build | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 28b9079d04e..4db53fec267 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -7,7 +7,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/vmstate.h"
 #include "system/tcg.h"
 #include "vec.h"
 
diff --git a/target/loongarch/meson.build b/target/loongarch/meson.build
index 2ae96d68695..c5a2953b29c 100644
--- a/target/loongarch/meson.build
+++ b/target/loongarch/meson.build
@@ -10,6 +10,7 @@ loongarch_user_ss.add(files('gdbstub.c'))
 
 loongarch_common_system_ss = ss.source_set()
 loongarch_common_system_ss.add(files('gdbstub.c'))
+loongarch_common_system_ss.add(files('machine.c'))
 
 loongarch_system_ss = ss.source_set()
 loongarch_system_ss.add(files(
@@ -17,7 +18,6 @@ loongarch_system_ss.add(files(
   'cpu_helper.c',
   'csr.c',
   'loongarch-qmp-cmds.c',
-  'machine.c',
 ))
 
 common_ss.add(when: 'CONFIG_LOONGARCH_DIS', if_true: [files('disas.c'), gen])
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()"
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
  2026-03-25 21:17 ` [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c Philippe Mathieu-Daudé
  2026-03-25 21:17 ` [PATCH-for-11.1 02/10] target/loongarch: " Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:39   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé

The VMSTATE_UINTTL_2DARRAY() macro was never used, remove it.

This reverts commit 4597992f624c015ceb51fedb4628b3fdb1e5bbaa.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/migration/cpu.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index 1335abe2230..e3d6c06b7d4 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -23,8 +23,6 @@
     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)                               \
     VMSTATE_UINT64_TEST(_f, _s, _t)
 #define vmstate_info_uinttl vmstate_info_uint64
@@ -44,8 +42,6 @@
     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)                               \
     VMSTATE_UINT32_TEST(_f, _s, _t)
 #define vmstate_info_uinttl vmstate_info_uint32
@@ -55,8 +51,6 @@
     VMSTATE_UINTTL_V(_f, _s, 0)
 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
-#define VMSTATE_UINTTL_2DARRAY(_f, _s, _n1, _n2)                      \
-    VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, 0)
 
 
 #endif
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()" Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:40   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl() Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé

Last use of VMSTATE_UINTTL_TEST() was removed in commit 445d3facffe
("ppc/spapr: remove deprecated machine pseries-2.7").

The following definitions were added in commit b6c4f71f508 ("Resurrect
the safe part of r5274") but never used:

 - qemu_put_sbetl qemu_put_sbe64
 - qemu_get_sbetl qemu_get_sbe64
 - qemu_put_sbetls qemu_put_sbe64s
 - qemu_get_sbetls qemu_get_sbe64s

Remove all as unused.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/migration/cpu.h | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index e3d6c06b7d4..bb8ecfbeea5 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -12,10 +12,6 @@
 #define qemu_get_betl qemu_get_be64
 #define qemu_put_betls qemu_put_be64s
 #define qemu_get_betls qemu_get_be64s
-#define qemu_put_sbetl qemu_put_sbe64
-#define qemu_get_sbetl qemu_get_sbe64
-#define qemu_put_sbetls qemu_put_sbe64s
-#define qemu_get_sbetls qemu_get_sbe64s
 
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT64_V(_f, _s, _v)
@@ -23,18 +19,12 @@
     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_TEST(_f, _s, _t)                               \
-    VMSTATE_UINT64_TEST(_f, _s, _t)
 #define vmstate_info_uinttl vmstate_info_uint64
 #else
 #define qemu_put_betl qemu_put_be32
 #define qemu_get_betl qemu_get_be32
 #define qemu_put_betls qemu_put_be32s
 #define qemu_get_betls qemu_get_be32s
-#define qemu_put_sbetl qemu_put_sbe32
-#define qemu_get_sbetl qemu_get_sbe32
-#define qemu_put_sbetls qemu_put_sbe32s
-#define qemu_get_sbetls qemu_get_sbe32s
 
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT32_V(_f, _s, _v)
@@ -42,8 +32,6 @@
     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_TEST(_f, _s, _t)                               \
-    VMSTATE_UINT32_TEST(_f, _s, _t)
 #define vmstate_info_uinttl vmstate_info_uint32
 #endif
 
@@ -52,5 +40,4 @@
 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
 
-
 #endif
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl()
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:40   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé

Use TargetInfo target_long_bits() helper at runtime to migrate
the FSR register as 32 or 64-bits.

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

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index bb8ecfbeea5..87ca977a3fd 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -8,8 +8,6 @@
 #include "migration/vmstate.h"
 
 #if TARGET_LONG_BITS == 64
-#define qemu_put_betl qemu_put_be64
-#define qemu_get_betl qemu_get_be64
 #define qemu_put_betls qemu_put_be64s
 #define qemu_get_betls qemu_get_be64s
 
@@ -21,8 +19,6 @@
     VMSTATE_UINT64_SUB_ARRAY(_f, _s, _start, _num)
 #define vmstate_info_uinttl vmstate_info_uint64
 #else
-#define qemu_put_betl qemu_put_be32
-#define qemu_get_betl qemu_get_be32
 #define qemu_put_betls qemu_put_be32s
 #define qemu_get_betls qemu_get_be32s
 
diff --git a/target/sparc/machine.c b/target/sparc/machine.c
index 4dd75aff74a..0a449f2f8c6 100644
--- a/target/sparc/machine.c
+++ b/target/sparc/machine.c
@@ -1,8 +1,10 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
+#include "qemu/target-info.h"
 #include "qemu/timer.h"
 
 #include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
 
 #ifdef TARGET_SPARC64
 static const VMStateDescription vmstate_cpu_timer = {
@@ -86,9 +88,13 @@ static int get_fsr(QEMUFile *f, void *opaque, size_t size,
                    const VMStateField *field)
 {
     SPARCCPU *cpu = opaque;
-    target_ulong val = qemu_get_betl(f);
 
-    cpu_put_fsr(&cpu->env, val);
+    if (target_long_bits() == 64) {
+        cpu_put_fsr(&cpu->env, qemu_get_be64(f));
+    } else {
+        cpu_put_fsr(&cpu->env, qemu_get_be32(f));
+    }
+
     return 0;
 }
 
@@ -96,9 +102,12 @@ static int put_fsr(QEMUFile *f, void *opaque, size_t size,
                    const VMStateField *field, JSONWriter *vmdesc)
 {
     SPARCCPU *cpu = opaque;
-    target_ulong val = cpu_get_fsr(&cpu->env);
 
-    qemu_put_betl(f, val);
+    if (target_long_bits() == 64) {
+        qemu_put_be64(f, cpu_get_fsr(&cpu->env));
+    } else {
+        qemu_put_be32(f, cpu_get_fsr(&cpu->env));
+    }
     return 0;
 }
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls()
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl() Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:40   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Huacai Chen, Aurelien Jarno,
	Jiaxun Yang, Aleksandar Rikalo

Use TargetInfo target_long_bits() helper at runtime to migrate
the VPN register as 32 or 64-bits.

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

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index 87ca977a3fd..82a81b5d895 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -8,9 +8,6 @@
 #include "migration/vmstate.h"
 
 #if TARGET_LONG_BITS == 64
-#define qemu_put_betls qemu_put_be64s
-#define qemu_get_betls qemu_get_be64s
-
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT64_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
@@ -19,9 +16,6 @@
     VMSTATE_UINT64_SUB_ARRAY(_f, _s, _start, _num)
 #define vmstate_info_uinttl vmstate_info_uint64
 #else
-#define qemu_put_betls qemu_put_be32s
-#define qemu_get_betls qemu_get_be32s
-
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT32_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
diff --git a/target/mips/system/machine.c b/target/mips/system/machine.c
index 8af11fd896b..20de322385b 100644
--- a/target/mips/system/machine.c
+++ b/target/mips/system/machine.c
@@ -1,7 +1,9 @@
 #include "qemu/osdep.h"
+#include "qemu/target-info.h"
 #include "cpu.h"
 #include "internal.h"
 #include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
 #include "fpu_helper.h"
 
 static int cpu_post_load(void *opaque, int version_id)
@@ -139,7 +141,11 @@ static int get_tlb(QEMUFile *f, void *pv, size_t size,
     r4k_tlb_t *v = pv;
     uint16_t flags;
 
-    qemu_get_betls(f, &v->VPN);
+    if (target_long_bits() == 64) {
+        v->VPN = qemu_get_be64(f);
+    } else {
+        v->VPN = qemu_get_be32(f);
+    }
     qemu_get_be32s(f, &v->PageMask);
     qemu_get_be16s(f, &v->ASID);
     qemu_get_be32s(f, &v->MMID);
@@ -182,7 +188,11 @@ static int put_tlb(QEMUFile *f, void *pv, size_t size,
                       (v->D0 << 1) |
                       (v->D1 << 0));
 
-    qemu_put_betls(f, &v->VPN);
+    if (target_long_bits() == 64) {
+        qemu_put_be64(f, v->VPN);
+    } else {
+        qemu_put_be32(f, v->VPN);
+    }
     qemu_put_be32s(f, &v->PageMask);
     qemu_put_be16s(f, &asid);
     qemu_put_be32s(f, &mmid);
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls() Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:40   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Zhao Liu

APX registers are only migrated for 64-bit binaries, so
VMSTATE_UINTTL_SUB_ARRAY() expands to VMSTATE_UINT64_SUB_ARRAY().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/machine.c b/target/i386/machine.c
index 48a2a4b3190..1f5c517e562 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -1756,7 +1756,7 @@ static const VMStateDescription vmstate_apx = {
     .minimum_version_id = 1,
     .needed = apx_needed,
     .fields = (VMStateField[]) {
-        VMSTATE_UINTTL_SUB_ARRAY(env.regs, X86CPU, CPU_NB_REGS,
+        VMSTATE_UINT64_SUB_ARRAY(env.regs, X86CPU, CPU_NB_REGS,
                                  CPU_NB_EREGS - CPU_NB_REGS),
         VMSTATE_END_OF_LIST()
     }
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:43   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY Philippe Mathieu-Daudé
  2026-03-25 21:17 ` [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets Philippe Mathieu-Daudé
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Zhao Liu

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



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:44   ` Pierrick Bouvier
  2026-03-25 21:17 ` [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets Philippe Mathieu-Daudé
  9 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé

VMSTATE_VARRAY_MULTIPLY() seems to be an "optimized" version
of VMSTATE_UINTTL_ARRAY(), and is only used once. Prefer the
generic macro, removing the need for the VMS_MULTIPLY_ELEMENTS
field.

Bump the SPARC CPU migration stream version.

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

diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index ea411d863ad..05a1ddde343 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -12,13 +12,11 @@
     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_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_info_uinttl vmstate_info_uint32
 #endif
 
 #define VMSTATE_UINTTL(_f, _s)                                        \
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 62c2abd0c49..663b0c8ae06 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -94,7 +94,7 @@ enum VMStateFlags {
     VMS_ARRAY_OF_POINTER = 0x040,
 
     /* The field is an array of variable size. The uint16_t at opaque
-     * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
+     * + VMStateField.num_offset
      * contains the number of entries in the array. See the VMS_ARRAY
      * description regarding array handling in general. May not be
      * combined with VMS_ARRAY or any other VMS_VARRAY*. */
@@ -115,14 +115,14 @@ enum VMStateFlags {
     VMS_MULTIPLY         = 0x200,
 
     /* The field is an array of variable size. The uint8_t at opaque +
-     * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
+     * VMStateField.num_offset
      * contains the number of entries in the array. See the VMS_ARRAY
      * description regarding array handling in general. May not be
      * combined with VMS_ARRAY or any other VMS_VARRAY*. */
     VMS_VARRAY_UINT8     = 0x400,
 
     /* The field is an array of variable size. The uint32_t at opaque
-     * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS)
+     * + VMStateField.num_offset
      * contains the number of entries in the array. See the VMS_ARRAY
      * description regarding array handling in general. May not be
      * combined with VMS_ARRAY or any other VMS_VARRAY*. */
@@ -139,12 +139,6 @@ enum VMStateFlags {
      * cause the individual entries to be allocated. */
     VMS_ALLOC            = 0x2000,
 
-    /* Multiply the number of entries given by the integer at opaque +
-     * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num
-     * to determine the number of entries in the array. Only valid in
-     * combination with one of VMS_VARRAY*. */
-    VMS_MULTIPLY_ELEMENTS = 0x4000,
-
     /* A structure field that is like VMS_STRUCT, but uses
      * VMStateField.struct_version_id to tell which version of the
      * structure we are referencing to use. */
@@ -398,16 +392,6 @@ extern const VMStateInfo vmstate_info_qlist;
     .offset     = vmstate_offset_2darray(_state, _field, _type, _n1, _n2),  \
 }
 
-#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
-    .name       = (stringify(_field)),                               \
-    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
-    .num        = (_multiply),                                       \
-    .info       = &(_info),                                          \
-    .size       = sizeof(_type),                                     \
-    .flags      = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS,           \
-    .offset     = vmstate_offset_varray(_state, _field, _type),      \
-}
-
 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 4d28364f7ba..e960bc7a7c4 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -97,10 +97,6 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field)
         n_elems = *(uint8_t *)(opaque + field->num_offset);
     }
 
-    if (field->flags & VMS_MULTIPLY_ELEMENTS) {
-        n_elems *= field->num;
-    }
-
     trace_vmstate_n_elems(field->name, n_elems);
     return n_elems;
 }
diff --git a/target/sparc/machine.c b/target/sparc/machine.c
index 0a449f2f8c6..5f402e098cf 100644
--- a/target/sparc/machine.c
+++ b/target/sparc/machine.c
@@ -189,9 +189,9 @@ static int cpu_pre_save(void *opaque)
  * versions are different.
  */
 #ifndef TARGET_SPARC64
-#define SPARC_VMSTATE_VER 7
+#define SPARC_VMSTATE_VER 8
 #else
-#define SPARC_VMSTATE_VER 9
+#define SPARC_VMSTATE_VER 10
 #endif
 
 const VMStateDescription vmstate_sparc_cpu = {
@@ -202,8 +202,7 @@ const VMStateDescription vmstate_sparc_cpu = {
     .fields = (const VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(env.gregs, SPARCCPU, 8),
         VMSTATE_UINT32(env.nwindows, SPARCCPU),
-        VMSTATE_VARRAY_MULTIPLY(env.regbase, SPARCCPU, env.nwindows, 16,
-                                vmstate_info_uinttl, target_ulong),
+        VMSTATE_UINTTL_ARRAY(env.regbase, SPARCCPU, MAX_NWINDOWS * 16 + 8),
         VMSTATE_CPUDOUBLE_ARRAY(env.fpr, SPARCCPU, TARGET_DPREGS),
         VMSTATE_UINTTL(env.pc, SPARCCPU),
         VMSTATE_UINTTL(env.npc, SPARCCPU),
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets
  2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2026-03-25 21:17 ` [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY Philippe Mathieu-Daudé
@ 2026-03-25 21:17 ` Philippe Mathieu-Daudé
  2026-03-25 21:20   ` Philippe Mathieu-Daudé
  2026-03-25 21:49   ` Pierrick Bouvier
  9 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu,
	Philippe Mathieu-Daudé, Zhao Liu, Jiaxun Yang,
	Palmer Dabbelt, Weiwei Li, Liu Zhiwei, Chao Liu, Chinmay Rath

Only 5 base targets use VMSTATE_UINTTL (MIPS, PPC, X86, SPARC and
RISCV). In order to build a single binary (preliminary step toward
heterogeneous emulation) we need to remove it, but it will take some
time. Add a temporary TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
definition to keep targets not using these macros clean while we keep
cleaning the last few targets one by one, preventing legacy uses to
creep back in.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 configs/targets/i386-softmmu.mak     |  1 +
 configs/targets/mips-softmmu.mak     |  1 +
 configs/targets/mips64-softmmu.mak   |  1 +
 configs/targets/mips64el-softmmu.mak |  1 +
 configs/targets/mipsel-softmmu.mak   |  1 +
 configs/targets/ppc-softmmu.mak      |  1 +
 configs/targets/ppc64-softmmu.mak    |  1 +
 configs/targets/riscv32-softmmu.mak  |  1 +
 configs/targets/riscv64-softmmu.mak  |  1 +
 configs/targets/sparc-softmmu.mak    |  1 +
 configs/targets/sparc64-softmmu.mak  |  1 +
 configs/targets/x86_64-softmmu.mak   |  1 +
 include/migration/cpu.h              | 24 +++++++++++-------------
 target/ppc/machine.c                 |  1 +
 scripts/make-config-poison.sh        |  1 +
 15 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/configs/targets/i386-softmmu.mak b/configs/targets/i386-softmmu.mak
index 38a8f85201f..048ae17fdc5 100644
--- a/configs/targets/i386-softmmu.mak
+++ b/configs/targets/i386-softmmu.mak
@@ -4,3 +4,4 @@ TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-32bit.xml
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/mips-softmmu.mak b/configs/targets/mips-softmmu.mak
index 95397af9442..81990d21880 100644
--- a/configs/targets/mips-softmmu.mak
+++ b/configs/targets/mips-softmmu.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=mips
 TARGET_BIG_ENDIAN=y
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/mips64-softmmu.mak b/configs/targets/mips64-softmmu.mak
index f9cc41b9ed4..2f7873af06d 100644
--- a/configs/targets/mips64-softmmu.mak
+++ b/configs/targets/mips64-softmmu.mak
@@ -3,3 +3,4 @@ TARGET_BASE_ARCH=mips
 TARGET_BIG_ENDIAN=y
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/mips64el-softmmu.mak b/configs/targets/mips64el-softmmu.mak
index 4e7dedc5f30..62e74f77ba5 100644
--- a/configs/targets/mips64el-softmmu.mak
+++ b/configs/targets/mips64el-softmmu.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=mips64
 TARGET_BASE_ARCH=mips
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/mipsel-softmmu.mak b/configs/targets/mipsel-softmmu.mak
index b0fba8a9d0a..57e556b93b8 100644
--- a/configs/targets/mipsel-softmmu.mak
+++ b/configs/targets/mipsel-softmmu.mak
@@ -1,3 +1,4 @@
 TARGET_ARCH=mips
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/ppc-softmmu.mak b/configs/targets/ppc-softmmu.mak
index 867898bd47c..1e28d40b440 100644
--- a/configs/targets/ppc-softmmu.mak
+++ b/configs/targets/ppc-softmmu.mak
@@ -3,3 +3,4 @@ TARGET_BIG_ENDIAN=y
 TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= power-core.xml power-fpu.xml power-altivec.xml power-spe.xml
 TARGET_LONG_BITS=32
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/ppc64-softmmu.mak b/configs/targets/ppc64-softmmu.mak
index 10d7a2681e7..8c7171f9d5e 100644
--- a/configs/targets/ppc64-softmmu.mak
+++ b/configs/targets/ppc64-softmmu.mak
@@ -6,3 +6,4 @@ TARGET_XML_FILES= power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml
 # all boards require libfdt
 TARGET_NEED_FDT=y
 TARGET_LONG_BITS=64
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/riscv32-softmmu.mak b/configs/targets/riscv32-softmmu.mak
index 26080599be7..a9cd8ae89ee 100644
--- a/configs/targets/riscv32-softmmu.mak
+++ b/configs/targets/riscv32-softmmu.mak
@@ -5,3 +5,4 @@ TARGET_XML_FILES= riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml ri
 TARGET_NEED_FDT=y
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/riscv64-softmmu.mak b/configs/targets/riscv64-softmmu.mak
index 5059c550480..3f97cd6dfa5 100644
--- a/configs/targets/riscv64-softmmu.mak
+++ b/configs/targets/riscv64-softmmu.mak
@@ -6,3 +6,4 @@ TARGET_XML_FILES= riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml ri
 TARGET_NEED_FDT=y
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/sparc-softmmu.mak b/configs/targets/sparc-softmmu.mak
index 126ce12abb0..0630fa54b43 100644
--- a/configs/targets/sparc-softmmu.mak
+++ b/configs/targets/sparc-softmmu.mak
@@ -4,3 +4,4 @@ TARGET_XML_FILES=sparc32-cpu.xml sparc32-fpu.xml sparc32-cp0.xml
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/sparc64-softmmu.mak b/configs/targets/sparc64-softmmu.mak
index 4e621fb8e39..500db845ea9 100644
--- a/configs/targets/sparc64-softmmu.mak
+++ b/configs/targets/sparc64-softmmu.mak
@@ -5,3 +5,4 @@ TARGET_XML_FILES=sparc64-cpu.xml sparc64-fpu.xml sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/configs/targets/x86_64-softmmu.mak b/configs/targets/x86_64-softmmu.mak
index c7f8746b4f5..18b3575e4e2 100644
--- a/configs/targets/x86_64-softmmu.mak
+++ b/configs/targets/x86_64-softmmu.mak
@@ -5,3 +5,4 @@ TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-64bit.xml i386-64bit-apx.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
+TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
diff --git a/include/migration/cpu.h b/include/migration/cpu.h
index 05a1ddde343..4c8c9c34cc8 100644
--- a/include/migration/cpu.h
+++ b/include/migration/cpu.h
@@ -3,25 +3,23 @@
 #ifndef MIGRATION_CPU_H
 #define MIGRATION_CPU_H
 
+#ifdef TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
+
 #include "exec/cpu-defs.h"
-#include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
 
 #if TARGET_LONG_BITS == 64
-#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
-    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(_f, _s) \
+    VMSTATE_UINT64_V(_f, _s, 0)
+#define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
+    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
 #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(_f, _s) \
+    VMSTATE_UINT32_V(_f, _s, 0)
+#define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
+    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
 #endif
 
-#define VMSTATE_UINTTL(_f, _s)                                        \
-    VMSTATE_UINTTL_V(_f, _s, 0)
-#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
+#endif /* TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API */
 
 #endif
diff --git a/target/ppc/machine.c b/target/ppc/machine.c
index 49cfdc6d674..f6169a128dc 100644
--- a/target/ppc/machine.c
+++ b/target/ppc/machine.c
@@ -5,6 +5,7 @@
 #include "helper_regs.h"
 #include "mmu-hash64.h"
 #include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
 #include "qapi/error.h"
 #include "kvm_ppc.h"
 #include "power8-pmu.h"
diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
index b4d61e8bc9e..a1c5fa77d9d 100755
--- a/scripts/make-config-poison.sh
+++ b/scripts/make-config-poison.sh
@@ -12,6 +12,7 @@ exec sed -n \
   -e '/CONFIG_SOFTMMU/d' \
   -e '/TARGET_NOT_USING_LEGACY_LDST_PHYS_API/d' \
   -e '/TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API/d' \
+  -e '/TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API/d' \
   -e '/^#define / {' \
   -e    's///' \
   -e    's/ .*//' \
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets
  2026-03-25 21:17 ` [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets Philippe Mathieu-Daudé
@ 2026-03-25 21:20   ` Philippe Mathieu-Daudé
  2026-03-25 21:49   ` Pierrick Bouvier
  1 sibling, 0 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-25 21:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Pierrick Bouvier, Alex Bennée, qemu-riscv, Paolo Bonzini,
	Artyom Tarasenko, Anton Johansson, Peter Xu, Zhao Liu,
	Jiaxun Yang, Palmer Dabbelt, Weiwei Li, Liu Zhiwei, Chao Liu,
	Chinmay Rath

On 25/3/26 22:17, Philippe Mathieu-Daudé wrote:
> Only 5 base targets use VMSTATE_UINTTL (MIPS, PPC, X86, SPARC and
> RISCV). In order to build a single binary (preliminary step toward
> heterogeneous emulation) we need to remove it, but it will take some
> time. Add a temporary TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
> definition to keep targets not using these macros clean while we keep
> cleaning the last few targets one by one, preventing legacy uses to
> creep back in.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h              | 24 +++++++++++-------------
>   target/ppc/machine.c                 |  1 +


> diff --git a/include/migration/cpu.h b/include/migration/cpu.h
> index 05a1ddde343..4c8c9c34cc8 100644
> --- a/include/migration/cpu.h
> +++ b/include/migration/cpu.h
> @@ -3,25 +3,23 @@
>   #ifndef MIGRATION_CPU_H
>   #define MIGRATION_CPU_H
>   
>   #include "exec/cpu-defs.h"
> -#include "migration/qemu-file-types.h"
>   #include "migration/vmstate.h"


> diff --git a/target/ppc/machine.c b/target/ppc/machine.c
> index 49cfdc6d674..f6169a128dc 100644
> --- a/target/ppc/machine.c
> +++ b/target/ppc/machine.c
> @@ -5,6 +5,7 @@
>   #include "helper_regs.h"
>   #include "mmu-hash64.h"
>   #include "migration/cpu.h"
> +#include "migration/qemu-file-types.h"
>   #include "qapi/error.h"
>   #include "kvm_ppc.h"
>   #include "power8-pmu.h"

Oops, this change is part of patch #6 "Inline qemu_get/put_betls()".


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c
  2026-03-25 21:17 ` [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c Philippe Mathieu-Daudé
@ 2026-03-25 21:39   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Michael Rolnik

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> machine.c doesn't use any target-specific macro defined by
> the "migration/cpu.h" header. Use the minimum headers required:
> "migration/qemu-file-types.h" and "migration/vmstate.h", which
> are not target-specific. This allows to build this file as
> common object.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/avr/machine.c   | 3 ++-
>   target/avr/meson.build | 3 +--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 02/10] target/loongarch: Avoid target-specific migration headers in machine.c
  2026-03-25 21:17 ` [PATCH-for-11.1 02/10] target/loongarch: " Philippe Mathieu-Daudé
@ 2026-03-25 21:39   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Song Gao

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> machine.c doesn't use any target-specific macro defined by
> the "migration/cpu.h" header. Use the minimum header required:
> "migration/qemu-file-types.h" which is not target-specific.
> This allows to build this file as common object.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/loongarch/machine.c   | 2 +-
>   target/loongarch/meson.build | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()"
  2026-03-25 21:17 ` [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()" Philippe Mathieu-Daudé
@ 2026-03-25 21:39   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> The VMSTATE_UINTTL_2DARRAY() macro was never used, remove it.
> 
> This reverts commit 4597992f624c015ceb51fedb4628b3fdb1e5bbaa.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h | 6 ------
>   1 file changed, 6 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros
  2026-03-25 21:17 ` [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros Philippe Mathieu-Daudé
@ 2026-03-25 21:40   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> Last use of VMSTATE_UINTTL_TEST() was removed in commit 445d3facffe
> ("ppc/spapr: remove deprecated machine pseries-2.7").
> 
> The following definitions were added in commit b6c4f71f508 ("Resurrect
> the safe part of r5274") but never used:
> 
>   - qemu_put_sbetl qemu_put_sbe64
>   - qemu_get_sbetl qemu_get_sbe64
>   - qemu_put_sbetls qemu_put_sbe64s
>   - qemu_get_sbetls qemu_get_sbe64s
> 
> Remove all as unused.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h | 13 -------------
>   1 file changed, 13 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl()
  2026-03-25 21:17 ` [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl() Philippe Mathieu-Daudé
@ 2026-03-25 21:40   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> Use TargetInfo target_long_bits() helper at runtime to migrate
> the FSR register as 32 or 64-bits.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h |  4 ----
>   target/sparc/machine.c  | 17 +++++++++++++----
>   2 files changed, 13 insertions(+), 8 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls()
  2026-03-25 21:17 ` [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls() Philippe Mathieu-Daudé
@ 2026-03-25 21:40   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Huacai Chen, Aurelien Jarno,
	Jiaxun Yang, Aleksandar Rikalo

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> Use TargetInfo target_long_bits() helper at runtime to migrate
> the VPN register as 32 or 64-bits.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h      |  6 ------
>   target/mips/system/machine.c | 14 ++++++++++++--
>   2 files changed, 12 insertions(+), 8 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers
  2026-03-25 21:17 ` [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers Philippe Mathieu-Daudé
@ 2026-03-25 21:40   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Zhao Liu

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> APX registers are only migrated for 64-bit binaries, so
> VMSTATE_UINTTL_SUB_ARRAY() expands to VMSTATE_UINT64_SUB_ARRAY().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/i386/machine.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro
  2026-03-25 21:17 ` [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro Philippe Mathieu-Daudé
@ 2026-03-25 21:43   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Zhao Liu

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY
  2026-03-25 21:17 ` [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY Philippe Mathieu-Daudé
@ 2026-03-25 21:44   ` Pierrick Bouvier
  0 siblings, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> VMSTATE_VARRAY_MULTIPLY() seems to be an "optimized" version
> of VMSTATE_UINTTL_ARRAY(), and is only used once. Prefer the
> generic macro, removing the need for the VMS_MULTIPLY_ELEMENTS
> field.
> 
> Bump the SPARC CPU migration stream version.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/migration/cpu.h     |  2 --
>   include/migration/vmstate.h | 22 +++-------------------
>   migration/vmstate.c         |  4 ----
>   target/sparc/machine.c      |  7 +++----
>   4 files changed, 6 insertions(+), 29 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets
  2026-03-25 21:17 ` [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets Philippe Mathieu-Daudé
  2026-03-25 21:20   ` Philippe Mathieu-Daudé
@ 2026-03-25 21:49   ` Pierrick Bouvier
  1 sibling, 0 replies; 22+ messages in thread
From: Pierrick Bouvier @ 2026-03-25 21:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Glenn Miles, Mark Cave-Ayland, Nicholas Piggin, qemu-ppc,
	Daniel Henrique Barboza, Fabiano Rosas, Alistair Francis,
	Alex Bennée, qemu-riscv, Paolo Bonzini, Artyom Tarasenko,
	Anton Johansson, Peter Xu, Zhao Liu, Jiaxun Yang, Palmer Dabbelt,
	Weiwei Li, Liu Zhiwei, Chao Liu, Chinmay Rath

On 3/25/26 2:17 PM, Philippe Mathieu-Daudé wrote:
> Only 5 base targets use VMSTATE_UINTTL (MIPS, PPC, X86, SPARC and
> RISCV). In order to build a single binary (preliminary step toward
> heterogeneous emulation) we need to remove it, but it will take some
> time. Add a temporary TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
> definition to keep targets not using these macros clean while we keep
> cleaning the last few targets one by one, preventing legacy uses to
> creep back in.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   configs/targets/i386-softmmu.mak     |  1 +
>   configs/targets/mips-softmmu.mak     |  1 +
>   configs/targets/mips64-softmmu.mak   |  1 +
>   configs/targets/mips64el-softmmu.mak |  1 +
>   configs/targets/mipsel-softmmu.mak   |  1 +
>   configs/targets/ppc-softmmu.mak      |  1 +
>   configs/targets/ppc64-softmmu.mak    |  1 +
>   configs/targets/riscv32-softmmu.mak  |  1 +
>   configs/targets/riscv64-softmmu.mak  |  1 +
>   configs/targets/sparc-softmmu.mak    |  1 +
>   configs/targets/sparc64-softmmu.mak  |  1 +
>   configs/targets/x86_64-softmmu.mak   |  1 +
>   include/migration/cpu.h              | 24 +++++++++++-------------
>   target/ppc/machine.c                 |  1 +
>   scripts/make-config-poison.sh        |  1 +
>   15 files changed, 25 insertions(+), 13 deletions(-)
> 
> diff --git a/configs/targets/i386-softmmu.mak b/configs/targets/i386-softmmu.mak
> index 38a8f85201f..048ae17fdc5 100644
> --- a/configs/targets/i386-softmmu.mak
> +++ b/configs/targets/i386-softmmu.mak
> @@ -4,3 +4,4 @@ TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
>   TARGET_XML_FILES= i386-32bit.xml
>   TARGET_LONG_BITS=32
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/mips-softmmu.mak b/configs/targets/mips-softmmu.mak
> index 95397af9442..81990d21880 100644
> --- a/configs/targets/mips-softmmu.mak
> +++ b/configs/targets/mips-softmmu.mak
> @@ -2,3 +2,4 @@ TARGET_ARCH=mips
>   TARGET_BIG_ENDIAN=y
>   TARGET_LONG_BITS=32
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/mips64-softmmu.mak b/configs/targets/mips64-softmmu.mak
> index f9cc41b9ed4..2f7873af06d 100644
> --- a/configs/targets/mips64-softmmu.mak
> +++ b/configs/targets/mips64-softmmu.mak
> @@ -3,3 +3,4 @@ TARGET_BASE_ARCH=mips
>   TARGET_BIG_ENDIAN=y
>   TARGET_LONG_BITS=64
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/mips64el-softmmu.mak b/configs/targets/mips64el-softmmu.mak
> index 4e7dedc5f30..62e74f77ba5 100644
> --- a/configs/targets/mips64el-softmmu.mak
> +++ b/configs/targets/mips64el-softmmu.mak
> @@ -2,3 +2,4 @@ TARGET_ARCH=mips64
>   TARGET_BASE_ARCH=mips
>   TARGET_LONG_BITS=64
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/mipsel-softmmu.mak b/configs/targets/mipsel-softmmu.mak
> index b0fba8a9d0a..57e556b93b8 100644
> --- a/configs/targets/mipsel-softmmu.mak
> +++ b/configs/targets/mipsel-softmmu.mak
> @@ -1,3 +1,4 @@
>   TARGET_ARCH=mips
>   TARGET_LONG_BITS=32
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/ppc-softmmu.mak b/configs/targets/ppc-softmmu.mak
> index 867898bd47c..1e28d40b440 100644
> --- a/configs/targets/ppc-softmmu.mak
> +++ b/configs/targets/ppc-softmmu.mak
> @@ -3,3 +3,4 @@ TARGET_BIG_ENDIAN=y
>   TARGET_KVM_HAVE_GUEST_DEBUG=y
>   TARGET_XML_FILES= power-core.xml power-fpu.xml power-altivec.xml power-spe.xml
>   TARGET_LONG_BITS=32
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/ppc64-softmmu.mak b/configs/targets/ppc64-softmmu.mak
> index 10d7a2681e7..8c7171f9d5e 100644
> --- a/configs/targets/ppc64-softmmu.mak
> +++ b/configs/targets/ppc64-softmmu.mak
> @@ -6,3 +6,4 @@ TARGET_XML_FILES= power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml
>   # all boards require libfdt
>   TARGET_NEED_FDT=y
>   TARGET_LONG_BITS=64
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/riscv32-softmmu.mak b/configs/targets/riscv32-softmmu.mak
> index 26080599be7..a9cd8ae89ee 100644
> --- a/configs/targets/riscv32-softmmu.mak
> +++ b/configs/targets/riscv32-softmmu.mak
> @@ -5,3 +5,4 @@ TARGET_XML_FILES= riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml ri
>   TARGET_NEED_FDT=y
>   TARGET_LONG_BITS=32
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/riscv64-softmmu.mak b/configs/targets/riscv64-softmmu.mak
> index 5059c550480..3f97cd6dfa5 100644
> --- a/configs/targets/riscv64-softmmu.mak
> +++ b/configs/targets/riscv64-softmmu.mak
> @@ -6,3 +6,4 @@ TARGET_XML_FILES= riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml ri
>   TARGET_NEED_FDT=y
>   TARGET_LONG_BITS=64
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/sparc-softmmu.mak b/configs/targets/sparc-softmmu.mak
> index 126ce12abb0..0630fa54b43 100644
> --- a/configs/targets/sparc-softmmu.mak
> +++ b/configs/targets/sparc-softmmu.mak
> @@ -4,3 +4,4 @@ TARGET_XML_FILES=sparc32-cpu.xml sparc32-fpu.xml sparc32-cp0.xml
>   TARGET_LONG_BITS=32
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
>   TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/sparc64-softmmu.mak b/configs/targets/sparc64-softmmu.mak
> index 4e621fb8e39..500db845ea9 100644
> --- a/configs/targets/sparc64-softmmu.mak
> +++ b/configs/targets/sparc64-softmmu.mak
> @@ -5,3 +5,4 @@ TARGET_XML_FILES=sparc64-cpu.xml sparc64-fpu.xml sparc64-cp0.xml
>   TARGET_LONG_BITS=64
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
>   TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/configs/targets/x86_64-softmmu.mak b/configs/targets/x86_64-softmmu.mak
> index c7f8746b4f5..18b3575e4e2 100644
> --- a/configs/targets/x86_64-softmmu.mak
> +++ b/configs/targets/x86_64-softmmu.mak
> @@ -5,3 +5,4 @@ TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
>   TARGET_XML_FILES= i386-64bit.xml i386-64bit-apx.xml
>   TARGET_LONG_BITS=64
>   TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
> +TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API=y
> diff --git a/include/migration/cpu.h b/include/migration/cpu.h
> index 05a1ddde343..4c8c9c34cc8 100644
> --- a/include/migration/cpu.h
> +++ b/include/migration/cpu.h
> @@ -3,25 +3,23 @@
>   #ifndef MIGRATION_CPU_H
>   #define MIGRATION_CPU_H
>   
> +#ifdef TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API
> +
>   #include "exec/cpu-defs.h"
> -#include "migration/qemu-file-types.h"
>   #include "migration/vmstate.h"
>   
>   #if TARGET_LONG_BITS == 64
> -#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
> -    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(_f, _s) \
> +    VMSTATE_UINT64_V(_f, _s, 0)
> +#define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
> +    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
>   #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(_f, _s) \
> +    VMSTATE_UINT32_V(_f, _s, 0)
> +#define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
> +    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
>   #endif
>   
> -#define VMSTATE_UINTTL(_f, _s)                                        \
> -    VMSTATE_UINTTL_V(_f, _s, 0)
> -#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
> -    VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
> +#endif /* TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API */
>   
>   #endif
> diff --git a/target/ppc/machine.c b/target/ppc/machine.c
> index 49cfdc6d674..f6169a128dc 100644
> --- a/target/ppc/machine.c
> +++ b/target/ppc/machine.c
> @@ -5,6 +5,7 @@
>   #include "helper_regs.h"
>   #include "mmu-hash64.h"
>   #include "migration/cpu.h"
> +#include "migration/qemu-file-types.h"
>   #include "qapi/error.h"
>   #include "kvm_ppc.h"
>   #include "power8-pmu.h"
> diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
> index b4d61e8bc9e..a1c5fa77d9d 100755
> --- a/scripts/make-config-poison.sh
> +++ b/scripts/make-config-poison.sh
> @@ -12,6 +12,7 @@ exec sed -n \
>     -e '/CONFIG_SOFTMMU/d' \
>     -e '/TARGET_NOT_USING_LEGACY_LDST_PHYS_API/d' \
>     -e '/TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API/d' \
> +  -e '/TARGET_USING_LEGACY_MIGRATION_VMSTATE_UINTTL_API/d' \
>     -e '/^#define / {' \
>     -e    's///' \
>     -e    's/ .*//' \

I'm not sure it's needed to have this flag.

Indeed, it's not possible to eradicate VMSTATE_UINTTL because of 
retrocompatibility, so it will never be completely removed. Thus, you 
can leave it as it is and implement the hint mentioned on Patch 8, which 
is retrocompatible by design.

With this, no change will be needed in target code, and only migration 
and include/migration/cpu.h will need a change.

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-03-25 21:50 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 21:17 [PATCH-for-11.1 00/10] migration: Reduce uses of target-specific macros Philippe Mathieu-Daudé
2026-03-25 21:17 ` [PATCH-for-11.1 01/10] target/avr: Avoid target-specific migration headers in machine.c Philippe Mathieu-Daudé
2026-03-25 21:39   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 02/10] target/loongarch: " Philippe Mathieu-Daudé
2026-03-25 21:39   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 03/10] migration: Revert "Add VMSTATE_UINTTL_2DARRAY()" Philippe Mathieu-Daudé
2026-03-25 21:39   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 04/10] migration: Remove unused target-specific macros Philippe Mathieu-Daudé
2026-03-25 21:40   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 05/10] target/sparc: Inline qemu_get/put_betl() Philippe Mathieu-Daudé
2026-03-25 21:40   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 06/10] target/mips: Inline qemu_get/put_betls() Philippe Mathieu-Daudé
2026-03-25 21:40   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 07/10] target/i386: Expand VMSTATE_UINTTL_SUB_ARRAY for APX registers Philippe Mathieu-Daudé
2026-03-25 21:40   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 08/10] target/i386: Inline VMSTATE_UINTTL_SUB_ARRAY() macro Philippe Mathieu-Daudé
2026-03-25 21:43   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY Philippe Mathieu-Daudé
2026-03-25 21:44   ` Pierrick Bouvier
2026-03-25 21:17 ` [PATCH-for-11.1 10/10] migration: Restrict legacy VMSTATE_UINTTL() macros to few targets Philippe Mathieu-Daudé
2026-03-25 21:20   ` Philippe Mathieu-Daudé
2026-03-25 21:49   ` Pierrick Bouvier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox