From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alistair Francis <alistair.francis@wdc.com>
Subject: [PATCH 3/7] target/riscv: assert argument to set_satp_mode_max_supported is valid
Date: Tue, 18 Feb 2025 17:57:53 +0100 [thread overview]
Message-ID: <20250218165757.554178-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20250218165757.554178-1-pbonzini@redhat.com>
Check that the argument to set_satp_mode_max_supported is valid for
the MXL value of the CPU. It would be a bug in the CPU definition
if it weren't.
In fact, there is such a bug in riscv_bare_cpu_init(): not just
SV32 is not a valid VM mode for 64-bit CPUs, SV64 is not a
valid VM mode at all, not yet at least.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/riscv/cpu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index cca24b9f1fc..7950b6447f8 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -442,6 +442,8 @@ static void set_satp_mode_max_supported(RISCVCPU *cpu,
cpu->cfg.satp_mode.supported |= (1 << i);
}
}
+
+ assert(cpu->cfg.satp_mode.supported & (1 << satp_mode));
}
/* Set the satp mode to the max supported */
@@ -1502,7 +1504,9 @@ static void riscv_bare_cpu_init(Object *obj)
* satp_mode manually (see set_satp_mode_default()).
*/
#ifndef CONFIG_USER_ONLY
- set_satp_mode_max_supported(cpu, VM_1_10_SV64);
+ set_satp_mode_max_supported(RISCV_CPU(obj),
+ riscv_cpu_mxl(&RISCV_CPU(obj)->env) == MXL_RV32 ?
+ VM_1_10_SV32 : VM_1_10_SV57);
#endif
}
--
2.48.1
next prev parent reply other threads:[~2025-02-18 16:59 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 ` [PATCH 2/7] target/riscv: env->misa_mxl is a constant Paolo Bonzini
2025-03-06 1:16 ` 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 ` Paolo Bonzini [this message]
2025-03-06 1:23 ` [PATCH 3/7] target/riscv: assert argument to set_satp_mode_max_supported is valid 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-4-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).