From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com,
alistair.francis@wdc.com, dbarboza@ventanamicro.com,
liwei1518@gmail.com, bmeng.cn@gmail.com,
TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Subject: [PATCH v1 1/7] target/riscv: Fix sstatus read and write
Date: Mon, 7 Oct 2024 11:33:54 +0800 [thread overview]
Message-ID: <20241007033400.50163-2-zhiwei_liu@linux.alibaba.com> (raw)
In-Reply-To: <20241007033400.50163-1-zhiwei_liu@linux.alibaba.com>
From: TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Sstatus is SXLEN bits in length and always has the layout determined by
the SXL configuration, regardless of the current XLEN.
Signed-off-by: TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Fixes: b550f89457 (target/riscv: Compute mstatus.sd on demand)
Fixes: f310df58bd (target/riscv: Enable uxl field write)
---
target/riscv/csr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index ea3560342c..b33cc1ec23 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -2893,7 +2893,7 @@ static RISCVException read_sstatus_i128(CPURISCVState *env, int csrno,
{
uint64_t mask = sstatus_v1_10_mask;
uint64_t sstatus = env->mstatus & mask;
- if (env->xl != MXL_RV32 || env->debugger) {
+ if (riscv_cpu_sxl(env) != MXL_RV32 || env->debugger) {
mask |= SSTATUS64_UXL;
}
@@ -2905,11 +2905,10 @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno,
target_ulong *val)
{
target_ulong mask = (sstatus_v1_10_mask);
- if (env->xl != MXL_RV32 || env->debugger) {
+ if (riscv_cpu_sxl(env) != MXL_RV32 || env->debugger) {
mask |= SSTATUS64_UXL;
}
- /* TODO: Use SXL not MXL. */
- *val = add_status_sd(riscv_cpu_mxl(env), env->mstatus & mask);
+ *val = add_status_sd(riscv_cpu_sxl(env), env->mstatus & mask);
return RISCV_EXCP_NONE;
}
@@ -2918,7 +2917,7 @@ static RISCVException write_sstatus(CPURISCVState *env, int csrno,
{
target_ulong mask = (sstatus_v1_10_mask);
- if (env->xl != MXL_RV32 || env->debugger) {
+ if (riscv_cpu_sxl(env) != MXL_RV32 || env->debugger) {
if ((val & SSTATUS64_UXL) != 0) {
mask |= SSTATUS64_UXL;
}
--
2.43.0
next prev parent reply other threads:[~2024-10-07 3:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 3:33 [PATCH v1 0/7] target/riscv: Support SXL32 on RV64 CPU LIU Zhiwei
2024-10-07 3:33 ` LIU Zhiwei [this message]
2024-10-11 3:44 ` [PATCH v1 1/7] target/riscv: Fix sstatus read and write Alistair Francis
2024-10-07 3:33 ` [PATCH v1 2/7] target/riscv: Fix satp read and write implicitly or explicitly LIU Zhiwei
2024-10-11 3:58 ` Alistair Francis
2024-10-07 3:33 ` [PATCH v1 3/7] target/riscv: Read pte and satp based on SXL in PTW LIU Zhiwei
2024-10-11 3:59 ` Alistair Francis
2024-10-07 3:33 ` [PATCH v1 4/7] hw/riscv: Align kernel to 4MB when sxl32 is on LIU Zhiwei
2024-10-07 3:33 ` [PATCH v1 5/7] target/riscv: Enable 32-bit only registers for RV64 with sxl32 LIU Zhiwei
2024-10-11 4:00 ` Alistair Francis
2024-10-07 3:33 ` [PATCH v1 6/7] target/riscv: Reset SXL and UXL according to sxl32 LIU Zhiwei
2024-10-07 3:34 ` [PATCH v1 7/7] target/riscv: Expose sxl32 configuration in RISC-V CPU LIU Zhiwei
2024-10-11 3:56 ` Alistair Francis
2024-10-11 3:55 ` [PATCH v1 0/7] target/riscv: Support SXL32 on RV64 CPU Alistair Francis
2024-10-22 6:41 ` LIU Zhiwei
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=20241007033400.50163-2-zhiwei_liu@linux.alibaba.com \
--to=zhiwei_liu@linux.alibaba.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=tangtiancheng.ttc@alibaba-inc.com \
/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).