From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Fabiano Rosas <farosas@suse.de>,
peterx@redhat.com, qemu-arm@nongnu.org
Subject: [PATCH for-12.0 4/6] arm/machine: Move all VMSTATE_VALIDATE() usages into post_load
Date: Fri, 20 Nov 2026 07:49:21 -0500 [thread overview]
Message-ID: <20261120124923.1656220-5-peterx@redhat.com> (raw)
In-Reply-To: <20261120124923.1656220-1-peterx@redhat.com>
To pave way removing VMSTATE_VALIDATE(), move all four such uses into a
post_load hook instead.
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Peter Xu <peterx@redhat.com>
---
target/arm/machine.c | 45 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/target/arm/machine.c b/target/arm/machine.c
index c3aef3f330..ec6daf1ab9 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -11,6 +11,7 @@
#include "migration/qemu-file-types.h"
#include "migration/vmstate.h"
#include "target/arm/gtimer.h"
+#include "qapi/error.h"
static bool vfp_needed(void *opaque)
{
@@ -421,14 +422,24 @@ static bool m_csselr_needed(void *opaque)
return !arm_v7m_csselr_razwi(cpu);
}
+static bool csselr_post_load(void *opaque, int version_id, Error **errp)
+{
+ if (!csselr_vmstate_validate(opaque, version_id)) {
+ error_setg(errp, "CSSELR is invalid");
+ return false;
+ }
+
+ return true;
+}
+
static const VMStateDescription vmstate_m_csselr = {
.name = "cpu/m/csselr",
.version_id = 1,
.minimum_version_id = 1,
.needed = m_csselr_needed,
+ .post_load_errp = csselr_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS),
- VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate),
VMSTATE_END_OF_LIST()
}
};
@@ -596,11 +607,22 @@ static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id)
return cpu->env.pmsav7.rnr[M_REG_NS] < cpu->pmsav7_dregion;
}
+static bool pmsav7_rgnr_post_load(void *opaque, int version_id, Error **errp)
+{
+ if (!pmsav7_rgnr_vmstate_validate(opaque, version_id)) {
+ error_setg(errp, "rgnr is invalid");
+ return false;
+ }
+
+ return true;
+}
+
static const VMStateDescription vmstate_pmsav7 = {
.name = "cpu/pmsav7",
.version_id = 1,
.minimum_version_id = 1,
.needed = pmsav7_needed,
+ .post_load_errp = pmsav7_rgnr_post_load,
.fields = (const VMStateField[]) {
VMSTATE_VARRAY_UINT32(env.pmsav7.drbar, ARMCPU, pmsav7_dregion, 0,
vmstate_info_uint32, uint32_t),
@@ -608,7 +630,6 @@ static const VMStateDescription vmstate_pmsav7 = {
vmstate_info_uint32, uint32_t),
VMSTATE_VARRAY_UINT32(env.pmsav7.dracr, ARMCPU, pmsav7_dregion, 0,
vmstate_info_uint32, uint32_t),
- VMSTATE_VALIDATE("rgnr is valid", pmsav7_rgnr_vmstate_validate),
VMSTATE_END_OF_LIST()
}
};
@@ -711,11 +732,27 @@ static bool m_security_needed(void *opaque)
return arm_feature(env, ARM_FEATURE_M_SECURITY);
}
+static bool m_security_post_load(void *opaque, int version_id, Error **errp)
+{
+ if (!s_rnr_vmstate_validate(opaque, version_id)) {
+ error_setg(errp, "secure MPU_RNR is invalid");
+ return false;
+ }
+
+ if (!sau_rnr_vmstate_validate(opaque, version_id)) {
+ error_setg(errp, "SAU_RNR is invalid");
+ return false;
+ }
+
+ return true;
+}
+
static const VMStateDescription vmstate_m_security = {
.name = "cpu/m-security",
.version_id = 1,
.minimum_version_id = 1,
.needed = m_security_needed,
+ .post_load_errp = m_security_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT32(env.v7m.secure, ARMCPU),
VMSTATE_UINT32(env.v7m.other_ss_msp, ARMCPU),
@@ -732,7 +769,6 @@ static const VMStateDescription vmstate_m_security = {
VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_S], ARMCPU, pmsav7_dregion,
0, vmstate_info_uint32, uint32_t),
VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU),
- VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate),
VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU),
VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU),
VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU),
@@ -744,7 +780,6 @@ static const VMStateDescription vmstate_m_security = {
VMSTATE_VARRAY_UINT32(env.sau.rlar, ARMCPU, sau_sregion, 0,
vmstate_info_uint32, uint32_t),
VMSTATE_UINT32(env.sau.rnr, ARMCPU),
- VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
/* AIRCR is not secure-only, but our implementation is R/O if the
@@ -1405,7 +1440,7 @@ const VMStateDescription vmstate_arm_cpu = {
&vmstate_m,
&vmstate_thumb2ee,
/* pmsav7_rnr must come before pmsav7 so that we have the
- * region number before we test it in the VMSTATE_VALIDATE
+ * region number before we test it in the post_load_errp()
* in vmstate_pmsav7.
*/
&vmstate_pmsav7_rnr,
--
2.56.0
next prev parent reply other threads:[~2026-11-20 12:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:49 [PATCH for-12.0 0/6] migration: Remove VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 1/6] pcie/aer: Remove the usage of VMSTATE_VALIDATE() Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 2/6] hw/gpio/zaurus: Move VMSTATE_VALIDATE() check into post_load_errp() Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 3/6] hpet: Move VMSTATE_VALIDATE() check into post_load Peter Xu
2026-11-20 12:49 ` Peter Xu [this message]
2026-11-20 12:49 ` [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load Peter Xu
2026-11-20 14:25 ` Zhao Liu
2026-11-20 15:43 ` Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 6/6] migration: Drop VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
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=20261120124923.1656220-5-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.