From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alistair Francis <alistair.francis@wdc.com>
Subject: [PATCH 2/7] target/riscv: env->misa_mxl is a constant
Date: Tue, 18 Feb 2025 17:57:52 +0100 [thread overview]
Message-ID: <20250218165757.554178-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20250218165757.554178-1-pbonzini@redhat.com>
There is nothing that overwrites env->misa_mxl, so it is a constant. Do
not let a corrupted migration stream change the value; changing misa_mxl
would have a snowball effect on, for example, the valid VM modes.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/riscv/machine.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index d8445244ab2..c3d8e7c4005 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -375,6 +375,18 @@ static const VMStateDescription vmstate_ssp = {
}
};
+static bool riscv_validate_misa_mxl(void *opaque, int version_id)
+{
+ RISCVCPU *cpu = RISCV_CPU(opaque);
+ CPURISCVState *env = &cpu->env;
+ RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
+ uint32_t misa_mxl_saved = env->misa_mxl;
+
+ /* Preserve misa_mxl even if the migration stream corrupted it */
+ env->misa_mxl = mcc->misa_mxl_max;
+ return misa_mxl_saved == mcc->misa_mxl_max;
+}
+
const VMStateDescription vmstate_riscv_cpu = {
.name = "cpu",
.version_id = 10,
@@ -394,6 +406,7 @@ const VMStateDescription vmstate_riscv_cpu = {
VMSTATE_UINTTL(env.priv_ver, RISCVCPU),
VMSTATE_UINTTL(env.vext_ver, RISCVCPU),
VMSTATE_UINT32(env.misa_mxl, RISCVCPU),
+ VMSTATE_VALIDATE("MXL must match", riscv_validate_misa_mxl),
VMSTATE_UINT32(env.misa_ext, RISCVCPU),
VMSTATE_UNUSED(4),
VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU),
--
2.48.1
next prev parent reply other threads:[~2025-02-18 16:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 16:57 [PATCH 0/7] target/riscv: store max SATP mode as a single integer in RISCVCPUConfig Paolo Bonzini
2025-02-18 16:57 ` [PATCH 1/7] hw/riscv: acpi: only create RHCT MMU entry for supported types Paolo Bonzini
2025-03-06 1:13 ` Alistair Francis
2025-03-06 12:11 ` Paolo Bonzini
2025-02-18 16:57 ` Paolo Bonzini [this message]
2025-03-06 1:16 ` [PATCH 2/7] target/riscv: env->misa_mxl is a constant Alistair Francis
2025-03-06 13:00 ` Paolo Bonzini
2025-03-07 0:44 ` Alistair Francis
2025-03-10 17:34 ` Paolo Bonzini
2025-03-10 22:18 ` Alistair Francis
2025-03-11 6:17 ` Paolo Bonzini
2025-03-19 1:35 ` Alistair Francis
2025-02-18 16:57 ` [PATCH 3/7] target/riscv: assert argument to set_satp_mode_max_supported is valid Paolo Bonzini
2025-03-06 1:23 ` Alistair Francis
2025-02-18 16:57 ` [PATCH 4/7] target/riscv: cpu: store max SATP mode as a single integer Paolo Bonzini
2025-03-06 1:30 ` Alistair Francis
2025-03-06 2:57 ` Alistair Francis
2025-02-18 16:57 ` [PATCH 5/7] target/riscv: update max_satp_mode based on QOM properties Paolo Bonzini
2025-03-06 1:41 ` Alistair Francis
2025-02-18 16:57 ` [PATCH 6/7] target/riscv: remove supported from RISCVSATPMap Paolo Bonzini
2025-03-06 2:39 ` Alistair Francis
2025-02-18 16:57 ` [PATCH 7/7] target/riscv: move satp_mode.{map,init} out of CPUConfig Paolo Bonzini
2025-03-06 2:42 ` [PATCH 7/7] target/riscv: move satp_mode.{map, init} " Alistair Francis
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=20250218165757.554178-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=alistair.francis@wdc.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).