From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Glenn Miles" <milesg@linux.ibm.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Nicholas Piggin" <npiggin@gmail.com>,
qemu-ppc@nongnu.org,
"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-riscv@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Anton Johansson" <anjo@rev.ng>, "Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY
Date: Wed, 25 Mar 2026 22:17:27 +0100 [thread overview]
Message-ID: <20260325211728.89204-10-philmd@linaro.org> (raw)
In-Reply-To: <20260325211728.89204-1-philmd@linaro.org>
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
next prev parent reply other threads:[~2026-03-25 21:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Philippe Mathieu-Daudé [this message]
2026-03-25 21:44 ` [PATCH-for-11.1 09/10] target/sparc: Replace VMSTATE_VARRAY_MULTIPLY -> VMSTATE_UINTTL_ARRAY 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325211728.89204-10-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=anjo@rev.ng \
--cc=atar4qemu@gmail.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=farosas@suse.de \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox